Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/textual/_border.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ def render_border_label(
return

text_label = Text.from_markup(label)
if not text_label.cell_len:
return
text_label.truncate(width - cells_reserved, overflow="ellipsis")
segments = text_label.render(console)

Expand Down
27 changes: 27 additions & 0 deletions tests/test_border.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,33 @@ def test_render_border_label_wide_plain(label: str):
assert original_text == Segment(label, _EMPTY_STYLE)


@pytest.mark.parametrize(
"label",
[
"[b][/]",
"[i b][/]",
"[white on red][/]",
"[blue]",
],
)
def test_render_border_empty_text_with_markup(label: str):
"""Test label rendering if there is no text but some markup."""
assert [] == list(
render_border_label(
label,
True,
"round",
999,
_EMPTY_STYLE,
_EMPTY_STYLE,
_EMPTY_STYLE,
_WIDE_CONSOLE,
True,
True,
)
)


def test_render_border_label():
"""Test label rendering with styling, with and without overflow."""

Expand Down