bat icon indicating copy to clipboard operation
bat copied to clipboard

Support text with embedded ANSI codes for the higlight line

Open nkh opened this issue 2 years ago • 2 comments

screenshot_2023-07-14_11-27-32

nkh avatar Jul 14 '23 09:07 nkh

Good catch!

I suspect what's happening here is that the "tmux" there is actually:

  ^[[33m tmux ^[[0m
  ~~~~~~      ~~~~~
  yellow      reset

The reset (SGR RESET) clears all the style information, which happens to include the background set by the line highlight. It shouldn't be too hard to put the line highlighting styles back after we encounter a reset.

#2544 has some changes that would greatly assist in fixing this, so I'll address this after that gets merged.

eth-p avatar Jul 18 '23 21:07 eth-p

I'm adding the colors, and there can be many added on a single line. Here's how it looks like

screenshot_2023-07-19_00-10-08

screenshot_2023-07-19_00-10-38

nkh avatar Jul 18 '23 22:07 nkh

Hey @nkh, if it's not too much trouble, would you be able to provide me with a text file and theme to reproduce this issue?

I'm using your example above, and I can't seem to get it to break on the latest version of bat :

image

image

eth-p avatar Feb 10 '24 08:02 eth-p

@eth-p I'll check with the latest version and get back to you.

nkh avatar Feb 10 '24 15:02 nkh

Seems to work in 0.24, thanks.

nkh avatar Apr 06 '24 14:04 nkh