Commit: 5764895236c87fcdea9e9a2d1960525feafd9a7c
Parent: d48aba0258c8c6eab671c98a8fcb872dbfbba5f2
Author: Randy Palamar
Date: Fri, 20 Feb 2026 09:47:27 -0700
vis: goto-ref.lua: invert the usage of the filter function
It is much more clear if the function returns true when it wants a
line to be included.
Diffstat:
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/.config/vis/build.lua b/.config/vis/build.lua
@@ -30,7 +30,10 @@ end
local default_error_search = function(error_string)
gf.setup_iterators_from_text(error_string, function(str)
- return not str:find(" error:") and not str:find(": warning:")
+ return str:find(" error:") or
+ str:find(": note:") or
+ str:find(": warning:")
+
end)
end
diff --git a/.config/vis/goto-ref.lua b/.config/vis/goto-ref.lua
@@ -38,11 +38,11 @@ M.generate_iterators = function(file_index_table)
return forward, backward
end
-M.generate_line_indices = function(data, filter)
+M.generate_line_indices = function(data, include)
local ret = {}
for s in data:gmatch("[^\n]*") do
- local skip = filter and filter(s)
- if not skip then
+ local keep = not include or include(s)
+ if keep then
local found, _, file, line, col = s:find('^([^:]+):([%d]+):?([%d]*):?')
if found then table.insert(ret, {file, line, col}) end
end
@@ -50,11 +50,11 @@ M.generate_line_indices = function(data, filter)
return ret
end
-M.setup_iterators_from_text = function(text, filter)
+M.setup_iterators_from_text = function(text, include)
vis:unmap(vis.modes.NORMAL, "gn")
vis:unmap(vis.modes.NORMAL, "gp")
- if text == nil or #text == 0 then return end
- local filepairs = M.generate_line_indices(text, filter)
+ if not text or #text == 0 then return end
+ local filepairs = M.generate_line_indices(text, include)
if #filepairs then
local forward, backward = M.generate_iterators(filepairs)
vis:map(vis.modes.NORMAL, "gn", forward)