long placeholder

This commit is contained in:
Will McGugan
2025-09-28 16:20:24 +01:00
parent 2d98a4546e
commit 02fd2451cb
5 changed files with 75 additions and 17 deletions

View File

@@ -4626,3 +4626,27 @@ def test_header_format(snap_compare):
yield Header()
assert snap_compare(HeaderApp())
def test_long_textarea_placeholder(snap_compare) -> None:
TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
I will face my fear.
I will permit it to pass over me and through me.
And when it has gone past, I will turn the inner eye to see its path.
Where the fear has gone there will be nothing. Only I will remain."""
class PlaceholderApp(App):
CSS = """
TextArea {
width: 50%;
}
"""
def compose(self) -> ComposeResult:
yield TextArea(placeholder=TEXT)
assert snap_compare(PlaceholderApp())

View File

@@ -349,3 +349,19 @@ def test_add_spans() -> None:
Span(7, 9, style="blue"),
]
assert content.spans == expected
def test_wrap() -> None:
content = Content.from_markup("[green]Hello, [b]World, One two three[/b]")
wrapped = content.wrap(6)
print(wrapped)
expected = [
Content("Hello,", spans=[Span(0, 6, style="green")]),
Content("World,", spans=[Span(0, 6, style="green"), Span(0, 6, style="b")]),
Content("One", spans=[Span(0, 3, style="green"), Span(0, 3, style="b")]),
Content("two", spans=[Span(0, 3, style="green"), Span(0, 3, style="b")]),
Content("three", spans=[Span(0, 5, style="green"), Span(0, 5, style="b")]),
]
assert len(wrapped) == len(expected)
for line1, line2 in zip(wrapped, expected):
assert line1.is_same(line2)