diff --git a/rich/text.py b/rich/text.py index d6a4c788..ad5e42d2 100644 --- a/rich/text.py +++ b/rich/text.py @@ -778,7 +778,8 @@ class Text(JupyterMixin): return self def append_text(self, text: "Text") -> "Text": - """Append another Text instance. This method is more performant that Text.append. + """Append another Text instance. This method is more performant that Text.append, but + only works for Text. Returns: Text: Returns self for chaining. diff --git a/tests/test_text.py b/tests/test_text.py index 4fd8f306..520cc2d2 100644 --- a/tests/test_text.py +++ b/tests/test_text.py @@ -275,6 +275,13 @@ def test_append(): test.append(1) +def test_append_text(): + test = Text("foo") + test.append_text(Text("bar", style="bold")) + assert str(test) == "foobar" + assert test._spans == [Span(3, 6, "bold")] + + def test_split(): test = Text() test.append("foo", "red")