Crashing of sidebar locate pickers #1960
Unanswered
xavier7179
asked this question in
Q&A
Replies: 1 comment 2 replies
-
I can provide a patch for the problem, but in return, I need you to create an issue or check if a similar one already exists. vim.schedule(function()
local pick = Snacks.picker.pick
---@type fun(source?: string, opts?: snacks.picker.Config)
Snacks.picker.pick = function(source, opts) ---@diagnostic disable-line
local unwrap = function(opt)
return type(opt) == 'function' and opt(source) or opt
end
local get_opts = vim.tbl_deep_extend('keep', opts or {}, {
source = source,
})
local layout = unwrap(Snacks.picker.config.get(get_opts).layout)
if unwrap(layout.preset) == 'sidebar' then
for _, pk in ipairs(Snacks.picker.get { tab = true }) do
if pk.opts.source ~= source and unwrap(pk.resolved_layout.preset) == 'sidebar' then
pk:close()
end
end
end
return pick(source, opts)
end
end) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I noticed that if I have two pickers assigned to the sidebar layout, if one is open and I try to open another one, it results in an error. My guess is that it is because pickers like the explorer have the
auto_close
field set tofalse
. Is there a way to avoid the error? I tried to write a function assigned to the on_show that gets all the pickers (using thepicker.get()
) to try to close the ones withlayout == "sidebar"
, but it didn't work.The function I wrote is the following:
Beta Was this translation helpful? Give feedback.
All reactions