diff --git a/CHANGELOG.md b/CHANGELOG.md index fa947c651b..76f269007d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Added `App.viewport_size` https://github.com/Textualize/textual/pull/6105 - Added `Screen.size` https://github.com/Textualize/textual/pull/6105 +### Fixed + +- Fixed issue where Segments with a style of `None` aren't rendered https://github.com/Textualize/textual/pull/6109 + ## [6.1.0] - 2025-08-01 ### Added diff --git a/src/textual/strip.py b/src/textual/strip.py index b608a92f78..90bbc4df36 100644 --- a/src/textual/strip.py +++ b/src/textual/strip.py @@ -659,9 +659,12 @@ def render(self, console: Console) -> str: render = Style.render self._render_cache = "".join( [ - render(style, text, color_system=color_system) + ( + text + if style is None + else render(style, text, color_system=color_system) + ) for text, style, _ in self._segments - if style is not None ] ) return self._render_cache diff --git a/tests/test_strip.py b/tests/test_strip.py index b88c68ecc5..d3cbf61982 100644 --- a/tests/test_strip.py +++ b/tests/test_strip.py @@ -1,4 +1,5 @@ import pytest +from rich.console import Console from rich.segment import Segment from rich.style import Style @@ -196,3 +197,9 @@ def test_text(): assert Strip([]).text == "" assert Strip([Segment("foo")]).text == "foo" assert Strip([Segment("foo"), Segment("bar")]).text == "foobar" + + +def test_render_with_missing_style() -> None: + """Test that render with segments that omit a style still work.""" + strip = Strip([Segment("Hello")]) + assert strip.render(Console()) == "Hello"