Truncated lines longer than 256 characters, and skipped to the relevant portion of the line to reduce slowdown and increase relevancy. (#185)

This commit is contained in:
Adam 2021-05-17 03:16:20 -04:00 committed by GitHub
parent e54ffc49ea
commit 85d0d684de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -30,7 +30,10 @@ local function find_all_matches_in_file(t, filename, fn)
for line in fp:lines() do for line in fp:lines() do
local s = fn(line) local s = fn(line)
if s then if s then
table.insert(t, { file = filename, text = line, line = n, col = s }) -- Insert maximum 256 characters. If we insert more, for compiled files, which can have very long lines
-- things tend to get sluggish. If our line is longer than 80 characters, begin to truncate the thing.
local start_index = math.max(s - 80, 1)
table.insert(t, { file = filename, text = (start_index > 1 and "..." or "") .. line:sub(start_index, 256 + start_index), line = n, col = s })
core.redraw = true core.redraw = true
end end
if n % 100 == 0 then coroutine.yield() end if n % 100 == 0 then coroutine.yield() end