Skip to content

Commit 11580e9

Browse files
authored
Merge pull request #6109 from Textualize/fix-strip-missing-style
fix issue rendering strips with missing style
2 parents 43485ed + 17cd7e6 commit 11580e9

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2020
- Added `App.viewport_size` https://github.com/Textualize/textual/pull/6105
2121
- Added `Screen.size` https://github.com/Textualize/textual/pull/6105
2222

23+
### Fixed
24+
25+
- Fixed issue where Segments with a style of `None` aren't rendered https://github.com/Textualize/textual/pull/6109
26+
2327
## [6.1.0] - 2025-08-01
2428

2529
### Added

src/textual/strip.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,9 +659,12 @@ def render(self, console: Console) -> str:
659659
render = Style.render
660660
self._render_cache = "".join(
661661
[
662-
render(style, text, color_system=color_system)
662+
(
663+
text
664+
if style is None
665+
else render(style, text, color_system=color_system)
666+
)
663667
for text, style, _ in self._segments
664-
if style is not None
665668
]
666669
)
667670
return self._render_cache

tests/test_strip.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
from rich.console import Console
23
from rich.segment import Segment
34
from rich.style import Style
45

@@ -196,3 +197,9 @@ def test_text():
196197
assert Strip([]).text == ""
197198
assert Strip([Segment("foo")]).text == "foo"
198199
assert Strip([Segment("foo"), Segment("bar")]).text == "foobar"
200+
201+
202+
def test_render_with_missing_style() -> None:
203+
"""Test that render with segments that omit a style still work."""
204+
strip = Strip([Segment("Hello")])
205+
assert strip.render(Console()) == "Hello"

0 commit comments

Comments
 (0)