cursive icon indicating copy to clipboard operation
cursive copied to clipboard

[BUG] ANSI parsing not complete

Open nahharris opened this issue 4 months ago • 1 comments

Describe the bug I'm trying to render output from delta which contains ansi escape sequences. ansi::parse handles most sequences but not all of them

To Reproduce Try to provide "simple" (if possible) code to reproduce the bug. If you can't simplify your code, a complete code is better than a simple, but incomplete one.

Expected behavior Given:

ESC[34m───────────────────────────────────────────────────────────────ESC[0mESC[34m┐ESC[0m
ESC[34m134ESC[0m:ESC[38;5;231m ESC[38;5;81mintESC[38;5;231m ESC[38;5;149mamdgpu_vcn_sw_initESC[38;5;231m(ESC[38;5;81mstructESC[38;5;231m amdgpu_device ESC[38;5;203m*ESC[38;5;208madevESC[38;5;231m, ESC[38;5;81mintESC[38;5;231m ESC[38;5;208miESC[38;5;231m) ESC[0mESC[34m│ESC[0m
ESC[34m───────────────────────────────────────────────────────────────ESC[0mESC[34m┘ESC[0m
ESC[38;5;231m    ESC[38;5;81mintESC[38;5;231m r;ESC[0m

ESC[38;5;231m    mutex_init(ESC[38;5;203m&ESC[38;5;231madev->vcn.inst[i].vcn1_jpeg1_workaround);ESC[0m
ESC[48;5;52m    mutex_init(&adev->vcn.inst[i].ESC[48;5;124mvcn_pg_lockESC[48;5;52m);ESC[0mESC[48;5;52mESC[0KESC[0m
ESC[48;5;22;38;5;231m    mutex_init(ESC[38;5;203m&ESC[38;5;231madev->vcn.inst[i].ESC[48;5;28mdpg_lockESC[48;5;22m);ESC[0mESC[48;5;22mESC[0KESC[0m
ESC[38;5;231m    mutex_init(ESC[38;5;203m&ESC[38;5;231madev->vcn.inst[i].engine_reset_mutex);ESC[0m
ESC[38;5;231m    atomic_set(ESC[38;5;203m&ESC[38;5;231madev->vcn.inst[i].total_submission_cnt, ESC[38;5;141m0ESC[38;5;231m);ESC[0m
ESC[38;5;231m    INIT_DELAYED_WORK(ESC[38;5;203m&ESC[38;5;231madev->vcn.inst[i].idle_work, amdgpu_vcn_idle_work_handler);ESC[0m

I was expecting:

Image

Screenshots I see: Image

Environment

  • Operating system used: Ubuntu (WSL)
  • Backend used: crossterm
  • Current locale (run locale in a terminal): C.UFT-8
  • Cursive version (from crates.io, from git, ...): crates.io 0.21.1

Additional context The more complex escape sequences that handle both foreground and background seem to be ignored. Also Cursor sequences [0K

nahharris avatar Aug 15 '25 02:08 nahharris

Thanks for the report!

We're currently using ansi-parser to parse that (https://gitlab.com/davidbittner/ansi-parser). It looks like it's indeed not properly parsing some of the escapes output by delta.

Looks like a potentially known issue: https://gitlab.com/davidbittner/ansi-parser/-/issues/9

Unfortunately there's not a lot of options for ansi-parsing crates. One day we might need to go to larger libs geared toward terminal emulators, like termwiz or VSE, especially if we want to support things like a "terminal view". The ansi parsing would then come almost "for free"...

gyscos avatar Sep 22 '25 15:09 gyscos