Commit: d48aba0258c8c6eab671c98a8fcb872dbfbba5f2 Parent: 25213ebb02364ea8770b48f0568d4f1fc43491a2 Author: Randy Palamar Date: Fri, 20 Feb 2026 09:45:39 -0700 vis: goto-ref.lua: improve iterator handling Both forward and backward work as expected now. There is no more weird missed movement when the direction changes. Diffstat:
| M | .config/vis/goto-ref.lua | | | 18 | +++++++++--------- |
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/.config/vis/goto-ref.lua b/.config/vis/goto-ref.lua @@ -20,17 +20,17 @@ M.focus_file_at = function(file, line, col) end M.generate_iterators = function(file_index_table) - local current_index = 1; - + local current_index local iterate = function(inc) - M.focus_file_at(table.unpack(file_index_table[current_index])) - current_index = current_index + inc - if current_index > #file_index_table then - current_index = 1 - end - if current_index < 1 then - current_index = #file_index_table + if current_index == nil then + if inc < 0 then current_index = ( inc % #file_index_table) + 1 + else current_index = ((inc - 1) % #file_index_table) + 1 end + else + current_index = current_index + inc + current_index = ((current_index - 1) % #file_index_table) + 1 end + + M.focus_file_at(table.unpack(file_index_table[current_index])) end local forward = function() iterate(1) end