feat(picker.lines): jump to first position of match. Closes #806

This commit is contained in:
Folke Lemaitre 2025-01-31 14:13:35 +01:00
parent 56db8f14bf
commit ae897f329f
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
4 changed files with 22 additions and 2 deletions

View file

@ -83,8 +83,12 @@ function M.jump(picker, _, action)
vim.api.nvim_win_set_buf(win, buf)
-- set the cursor
if item.pos and item.pos[1] > 0 then
vim.api.nvim_win_set_cursor(win, { item.pos[1], item.pos[2] })
local pos = item.pos
if picker.opts.jump.match then
pos = picker.matcher:bufpos(buf, item) or pos
end
if pos and pos[1] > 0 then
vim.api.nvim_win_set_cursor(win, { pos[1], pos[2] })
elseif item.search then
vim.cmd(item.search)
vim.cmd("noh")