Skip to content

Commit c1ef370

Browse files
Fix border rendering issue. (#2212)
1 parent c527d16 commit c1ef370

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/textual/_border.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,8 @@ def render_border_label(
327327
return
328328

329329
text_label = Text.from_markup(label)
330+
if not text_label.cell_len:
331+
return
330332
text_label.truncate(width - cells_reserved, overflow="ellipsis")
331333
segments = text_label.render(console)
332334

tests/test_border.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,33 @@ def test_render_border_label_wide_plain(label: str):
175175
assert original_text == Segment(label, _EMPTY_STYLE)
176176

177177

178+
@pytest.mark.parametrize(
179+
"label",
180+
[
181+
"[b][/]",
182+
"[i b][/]",
183+
"[white on red][/]",
184+
"[blue]",
185+
],
186+
)
187+
def test_render_border_empty_text_with_markup(label: str):
188+
"""Test label rendering if there is no text but some markup."""
189+
assert [] == list(
190+
render_border_label(
191+
label,
192+
True,
193+
"round",
194+
999,
195+
_EMPTY_STYLE,
196+
_EMPTY_STYLE,
197+
_EMPTY_STYLE,
198+
_WIDE_CONSOLE,
199+
True,
200+
True,
201+
)
202+
)
203+
204+
178205
def test_render_border_label():
179206
"""Test label rendering with styling, with and without overflow."""
180207

0 commit comments

Comments
 (0)