-
Notifications
You must be signed in to change notification settings - Fork 20
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
bad ansi escape sequences parsing? #79
Comments
What is the PS: vimpager is unrelated. |
The full log is not highlighted because nvimpager just checks the first 100 lines to decide if we should highlight terminal escape codes (function |
I don't really understand what it does. But often "less" is used with |
Can we use |
about: io.read: why? I think it reads stdin or we need to open the file again with io.open. But nvim has opened it already so why not use nvim_buf_get_lines? about ignoring unknown sequences: there are quite some of them: https://en.wikipedia.org/wiki/ANSI_escape_code When stripping them from the buffer we match much more than when concealing them: Lines 372 to 379 in 2251f29
Lines 635 to 637 in 2251f29
I have to read through the wiki article a bit and improve these regexes I think (help obviously apreciated :) |
I don't like this limitation of a hundred lines. If we check the whole file, io.read will be faster. simple test: local function with_io_read()
local start = os.clock()
local file = io.open(vim.fn.expand('%'), "r"):read("*all")
file:find('\27%[[;?]*[0-9.;]*[A-Za-z]')
return os.clock() - start
end
local function with_for_loop()
local start = os.clock()
for _, line in ipairs(vim.api.nvim_buf_get_lines(0, 0, -1, false)) do
if line:find('\27%[[;?]*[0-9.;]*[A-Za-z]') ~= nil then
return os.clock() - start
end
end
return os.clock() - start
end
local function test()
local msg = string.format('io.read = %s\nfor-loop = %s\n-----',
with_io_read(), with_for_loop())
vim.api.nvim_echo({ { msg } }, true, {})
end
vim.keymap.set('n', 't', test) |
OR we can simply create an option for this |
I introduced the limit because somebody might use nvimpager with a large log file. At work I have log files that are easily 1-10 GB in size. No idea how long it would take with these. I tested your example with the full.log file you provided and io.read is indead faster. I will have to see with a bigger log file. |
I don't know what it does, but like I mentioned, it needs to be at least hidden.
good idea |
This is part of a solution for #79. The effect of these sequences is explained in https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_(Control_Sequence_Introducer)_sequences
Seems like RGB colors are not parsed either. printf 'normal\e[48:2:0:162:31mgreen\n' and then open that. |
@illfygli currently only color sequences constructed with semicolon are recognized. Reading Wikipedia it is not clear to me if the colon syntax is officially defined by the ansi standard and if so if it is the same as the semicolon syntax. I tested xfce-termial, terminator, konsole, allacritty, kitty and xterm and all of them support your example. st does not. |
Interesting, I didn't notice that it was not using With |
@illfygli thanks for the heads up. I was under the impression that the escape sequences should be concealed but the colors displayed. This is a bug, I think that this did work at some point. |
@illfygli I checked again and it depends on the value of |
Ah yes, that works. Thanks! |
In some cases escape sequences are not converted to colors.
to reproduce:
part.log
full.log
I use fish, many of its man pages have the same problem, e.g.
man fish-doc
I have tried several setups (with alacritty 0.11.0):
nix shell nixos/nixpkgs/nixos-21.11#vim nixpkgs/nixos-21.11#vimpager-latest
)Also, I tried changing
TERM
toxterm-256color
. Everywhere the same result.The text was updated successfully, but these errors were encountered: