mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
@@ -760,10 +760,10 @@ class Content(Visual):
|
|||||||
return content
|
return content
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
|
|
||||||
def __radd__(self, other: Content | str) -> Content:
|
def __radd__(self, other: str) -> Content:
|
||||||
if not isinstance(other, (Content, str)):
|
if not isinstance(other, str):
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
return self + other
|
return Content(other) + self
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _trim_spans(cls, text: str, spans: list[Span]) -> list[Span]:
|
def _trim_spans(cls, text: str, spans: list[Span]) -> list[Span]:
|
||||||
|
|||||||
@@ -136,6 +136,14 @@ def test_add() -> None:
|
|||||||
assert content.spans == [Span(0, 3, "red"), Span(4, 7, "blue")]
|
assert content.spans == [Span(0, 3, "red"), Span(4, 7, "blue")]
|
||||||
assert content.cell_length == 7
|
assert content.cell_length == 7
|
||||||
|
|
||||||
|
def test_radd() -> None:
|
||||||
|
"""Test reverse addition."""
|
||||||
|
assert "foo" + Content("bar") == Content("foobar")
|
||||||
|
|
||||||
|
# Test spans after addition
|
||||||
|
content = "foo " + Content.styled("bar", "blue")
|
||||||
|
assert str(content) == "foo bar"
|
||||||
|
assert content.spans == [Span(4, 7, "blue")]
|
||||||
|
|
||||||
def test_from_markup():
|
def test_from_markup():
|
||||||
"""Test simple parsing of content markup."""
|
"""Test simple parsing of content markup."""
|
||||||
|
|||||||
Reference in New Issue
Block a user