mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 02:38:46 +00:00
fix(picker): make pick_win work with split layouts. Closes #834
This commit is contained in:
parent
4c06c24e1b
commit
6dbc26757c
3 changed files with 16 additions and 8 deletions
|
@ -152,18 +152,24 @@ function M.toggle_preview(picker)
|
|||
end
|
||||
|
||||
function M.pick_win(picker, item, action)
|
||||
picker.layout:hide()
|
||||
if not picker.layout.split then
|
||||
picker.layout:hide()
|
||||
end
|
||||
local win = Snacks.picker.util.pick_win({ main = picker.main })
|
||||
if not win then
|
||||
picker.layout:unhide()
|
||||
if not picker.layout.split then
|
||||
picker.layout:unhide()
|
||||
end
|
||||
return true
|
||||
end
|
||||
picker.main = win
|
||||
vim.defer_fn(function()
|
||||
if not picker.closed then
|
||||
picker.layout:unhide()
|
||||
end
|
||||
end, 100)
|
||||
if not picker.layout.split then
|
||||
vim.defer_fn(function()
|
||||
if not picker.closed then
|
||||
picker.layout:unhide()
|
||||
end
|
||||
end, 100)
|
||||
end
|
||||
end
|
||||
|
||||
function M.bufdelete(picker)
|
||||
|
|
|
@ -238,6 +238,7 @@ local defaults = {
|
|||
["<CR>"] = "confirm",
|
||||
["<Down>"] = "list_down",
|
||||
["<Esc>"] = "close",
|
||||
["<S-CR>"] = { { "pick_win", "jump" } },
|
||||
["<S-Tab>"] = { "select_and_prev", mode = { "n", "x" } },
|
||||
["<ScrollWheelDown>"] = "list_scroll_wheel_down",
|
||||
["<ScrollWheelUp>"] = "list_scroll_wheel_up",
|
||||
|
|
|
@ -372,7 +372,8 @@ function M.pick_win(opts)
|
|||
local chars = "asdfghjkl"
|
||||
local wins = {} ---@type number[]
|
||||
for _, win in ipairs(vim.api.nvim_list_wins()) do
|
||||
if vim.api.nvim_win_get_config(win).relative == "" then
|
||||
local buf = vim.api.nvim_win_get_buf(win)
|
||||
if vim.api.nvim_win_get_config(win).relative == "" and not vim.bo[buf].filetype:find("^snacks") then
|
||||
wins[#wins + 1] = win
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue