mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-05 03:08:13 +00:00
fix(picker.actions): get win after splitting or tabnew. Fixes #896
This commit is contained in:
parent
e294fd8a27
commit
95d3e7f961
1 changed files with 3 additions and 3 deletions
|
@ -86,18 +86,18 @@ function M.jump(picker, _, action)
|
||||||
local path = assert(Snacks.picker.util.path(item), "Either item.buf or item.file is required")
|
local path = assert(Snacks.picker.util.path(item), "Either item.buf or item.file is required")
|
||||||
buf = vim.fn.bufadd(path)
|
buf = vim.fn.bufadd(path)
|
||||||
end
|
end
|
||||||
|
vim.bo[buf].buflisted = true
|
||||||
|
|
||||||
-- use an existing window if possible
|
-- use an existing window if possible
|
||||||
if #items == 1 and picker.opts.jump.reuse_win and buf ~= current_buf then
|
if cmd == "buffer" and #items == 1 and picker.opts.jump.reuse_win and buf ~= current_buf then
|
||||||
win = vim.fn.win_findbuf(buf)[1] or win
|
win = vim.fn.win_findbuf(buf)[1] or win
|
||||||
vim.api.nvim_set_current_win(win)
|
vim.api.nvim_set_current_win(win)
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.bo[buf].buflisted = true
|
|
||||||
|
|
||||||
-- open the first buffer
|
-- open the first buffer
|
||||||
if i == 1 then
|
if i == 1 then
|
||||||
vim.cmd(("%s %d"):format(cmd, buf))
|
vim.cmd(("%s %d"):format(cmd, buf))
|
||||||
|
win = vim.api.nvim_get_current_win()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue