← mined_oracle

rich_2799

failed WRONG_FIX UNSUBMITTED wrong_fix_unsubmitted(None) · None tool calls · 0 s · Textualize/rich

Task input

(not found in data/tasks.jsonl)

Tool calls (0)

#ToolArgumentsResult
No trace captured.

Patch

--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - Use `Console(stderr=True)` in `rich.traceback.install` to support io redirection.
 - Fixes superfluous spaces in html output https://github.com/Textualize/rich/issues/2832
 - Fixed duplicate output in Jupyter https://github.com/Textualize/rich/pulls/2804
+- Filter ANSI character-encoding-change codes in `Text.from_ansi` parser
 - Fixes traceback failing when a frame filename is unreadable https://github.com/Textualize/rich/issues/2821
 
 ### Added
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -64,3 +64,4 @@ The following people have contributed to the development of Rich:
 - [Zhe Huang](https://github.com/onlyacat)
 - [Ke Sun](https://github.com/ksun212)
 - [Qiming Xu](https://github.com/xqm32)
+- [James Addison](https://github.com/jayaddison)
--- a/rich/ansi.py
+++ b/rich/ansi.py
@@ -43,6 +43,9 @@ def _ansi_tokenize(ansi_text: str) -> Iterable[_AnsiToken]:
         if start > position:
             yield _AnsiToken(ansi_text[position:start])
         if sgr:
+            if sgr == "(":
+                position = end + 1
+                continue
             if sgr.endswith("m"):
                 yield _AnsiToken("", sgr[1:-1], osc)
         else:

Test output

show
F
=================================== FAILURES ===================================
_________________________________ test_decode __________________________________

    def test_decode():
        console = Console(
            force_terminal=True, legacy_windows=False, color_system="truecolor"
        )
        console.begin_capture()
        console.print("Hello")
        console.print("[b]foo[/b]")
        console.print("[link http://example.org]bar")
        console.print("[#ff0000 on color(200)]red")
        console.print("[color(200) on #ff0000]red")
        terminal_codes = console.end_capture()
    
        decoder = AnsiDecoder()
        lines = list(decoder.decode(terminal_codes))
    
        expected = [
            Text("Hello"),
            Text("foo", spans=[Span(0, 3, Style.parse("bold"))]),
            Text("bar", spans=[Span(0, 3, Style.parse("link http://example.org"))]),
            Text("red", spans=[Span(0, 3, Style.parse("#ff0000 on color(200)"))]),
            Text("red", spans=[Span(0, 3, Style.parse("color(200) on #ff0000"))]),
        ]
    
>       assert lines == expected
E       AssertionError: assert [<text 'Hello...3, Style())]>] == [<text 'Hello... blue=0))))]>]
E         
E         At index 3 diff: <text 'red' [Span(0, 3, Style())]> != <text 'red' [Span(0, 3, Style(color=Color('#ff0000', ColorType.TRUECOLOR, triplet=ColorTriplet(red=255, green=0, blue=0)), bgcolor=Color('color(200)', ColorType.EIGHT_BIT, number=200)))]>
E         Use -v to get more diff

tests/test_ansi.py:32: AssertionError
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 failed in 0.11s