Skip to content
This repository has been archived by the owner on Dec 24, 2024. It is now read-only.

Commit

Permalink
fix: avoid exception when calling :Reject on last element
Browse files Browse the repository at this point in the history
This commit adds array length check gate before setting the cursor position on list entry removal with `:Reject` command. It allows to avoid the following exception which gets produced otherwise:
```
E5108: Error executing lua .../qf_helper.nvim/lua/qf_helper.lua:180: Cursor position outside buffer
```
  • Loading branch information
mivort authored and alex-moiseyev-d committed Jan 17, 2024
1 parent 582838f commit eab6c9c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lua/qf_helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ M.cmd_filter = function(keep, range_start, range_end)
end
end
util.set_list(qftype, newlist)
if #newlist == 0 then
return
end
lnum = math.min(math.max(1, lnum), #newlist)
vim.api.nvim_win_set_cursor(0, { lnum, cursor[2] })
end
Expand Down

0 comments on commit eab6c9c

Please sign in to comment.