← oracle_full

rich_4076

resolved RESOLVED UNSUBMITTED PASS · None tool calls · 0 s · Textualize/rich

Task input

preserve newlines

Fixes https://github.com/Textualize/rich/issues/3577

Tool calls (0)

#ToolArgumentsResult
No trace captured.

Patch

--- a/rich/ansi.py
+++ b/rich/ansi.py
@@ -127,13 +127,13 @@ def decode(self, terminal_text: str) -> Iterable[Text]:
         """Decode ANSI codes in an iterable of lines.
 
         Args:
-            lines (Iterable[str]): An iterable of lines of terminal output.
+            terminal_text: Output potentially containing ANSI escape sequences.
 
         Yields:
             Text: Marked up Text.
         """
-        for line in terminal_text.splitlines():
-            yield self.decode_line(line)
+        for line in re.split(r"(?<=\n)", terminal_text):
+            yield self.decode_line(line.rstrip("\n"))
 
     def decode_line(self, line: str) -> Text:
         """Decode a line containing ansi codes.

Test output

show
........................                                                 [100%]
24 passed in 0.07s