Skip to content

Commit 01ea051

Browse files
committed
content improvements
1 parent 2d9f2bb commit 01ea051

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/textual/content.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def styled(
363363
New Content instance.
364364
"""
365365
if not text:
366-
return Content("")
366+
return EMPTY_CONTENT
367367
new_content = cls(
368368
text,
369369
[Span(0, len(text), style)] if style else None,
@@ -865,7 +865,7 @@ def append(self, content: Content | str) -> Content:
865865
),
866866
strip_control_codes=False,
867867
)
868-
return Content("").join([self, content])
868+
return EMPTY_CONTENT.join([self, content])
869869

870870
def append_text(self, text: str, style: Style | str = "") -> Content:
871871
"""Append text give as a string, with an optional style.
@@ -1165,7 +1165,7 @@ def right_crop(self, amount: int = 1) -> Content:
11651165
]
11661166
text = self.plain[:-amount]
11671167
length = None if self._cell_length is None else self._cell_length - amount
1168-
return Content(text, spans, length)
1168+
return Content(text, spans, length, strip_control_codes=False)
11691169

11701170
def stylize(
11711171
self, style: Style | str, start: int = 0, end: int | None = None
@@ -1575,7 +1575,7 @@ def expand_tabs(self, tab_size: int = 8) -> Content:
15751575
cell_position += part.cell_length
15761576
append(part)
15771577

1578-
content = Content("").join(new_text)
1578+
content = EMPTY_CONTENT.join(new_text)
15791579
return content
15801580

15811581
def highlight_regex(
@@ -1613,7 +1613,7 @@ def highlight_regex(
16131613
and (count := count + 1) >= maximum_highlights
16141614
):
16151615
break
1616-
return Content(self._text, spans)
1616+
return Content(self._text, spans, cell_length=self._cell_length)
16171617

16181618

16191619
class _FormattedLine:

0 commit comments

Comments
 (0)