-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid ANSI escape code insertion for log files with existing multi-attribute escape codes #2281
Comments
Thanks for reporting. I believe this issue may get solved when #2189 is merged, but unfortunately I don't have time to confirm right now. |
Thanks for the suggestion. I just pulled and compiled that branch and I get the same result. |
I just realised that the issue might be more about bat trying to add colour to the It may not be that simple though, since the issue doesn't occur on linux for me; some platform-dependency is at play. |
Thank you for reporting. Like you mention, syntax highlighting for files with ANSI escape codes is out-of-scope for bat though. It is never going to work, because syntax regexes are not written to take ANSI escape characters into account. If we fix your specific case, we are going to break some other case. Properly pre-processing ANSI escape characters is a huge task, with very small benefits, which complicates bug fixing and feature development. It is, by my estimation, not worth it. So I propose we close this issue as "won't fix". |
Fair enough, thanks for the explanation. |
What steps will reproduce the bug?
What happens?
bat attempts to add colour to 'INFO' but inserts the new ANSI escape codes in the middle of the existing escape codes.
In my example, the new escape codes start directly after the first
ESC[
, which corrupts the escape sequence.It looks like this:
The issue does not occur when I replace the multi-attribute escape sequence
\e[1;34m
with a single-attribute escape sequence like\e[34m
:What did you expect to happen instead?
I expect that bat would insert the new escape codes directly before the first character of
INFO
rather than in the middle of the preceding escape sequence.I'm aware that adding highlighting to files which already contain escape code isn't exactly a supported use case (garbled output), but this issue seems quite avoidable.
I would like this to work because I often have log files which already contain colour escape codes (e.g. on the log level word) that I would like to view with bat.
I should also note that I couldn't reproduce the issue in my Ubuntu WSL environment.
How did you install
bat
?Latest version using
chocolatey
.bat version and environment
Software version
bat 0.21.0 (405e5f7)
Operating system
Windows 6.2.9200
Command-line
'C:\ProgramData\chocolatey\lib\Bat\tools\bat-v0.21.0-x86_64-pc-windows-msvc\bat.exe' -l log --diagnostic
Environment variables
Config file
Could not read contents of 'C:\Users\zane\AppData\Roaming\bat\config': The system cannot find the path specified. (os error 3).
Custom assets metadata
Could not read contents of 'C:\Users\zane\AppData\Local\bat\metadata.yaml': The system cannot find the path specified. (os error 3).
Custom assets
'C:\Users\zane\AppData\Local\bat' not found
Compile time information
Less version
The text was updated successfully, but these errors were encountered: