Skip to content

Commit

Permalink
fix(picker): make pick_win work with split layouts. Closes #834
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jan 31, 2025
1 parent 4c06c24 commit 6dbc267
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
20 changes: 13 additions & 7 deletions lua/snacks/picker/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions lua/snacks/picker/config/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion lua/snacks/picker/util/init.lua
Original file line number Diff line number Diff line change
Expand 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
Expand Down

0 comments on commit 6dbc267

Please sign in to comment.