Chaining picker callbacks - reverts to normal mode when opening the next picker #1922
Answered
by
drowning-cat
VishalSubramanyam
asked this question in
Q&A
-
I have something along the lines of
When the second picker opens, it's put in normal mode. How do I preserve the insert mode that I was in in the first picker? |
Beta Was this translation helpful? Give feedback.
Answered by
drowning-cat
May 28, 2025
Replies: 1 comment 1 reply
-
Open in Insert mode: confirm = function(picker)
Snacks.picker.pick(...)
picker:close()
end, Restore previous mode: confirm = function(picker)
local prev_mode = vim.fn.mode()
Snacks.picker.pick {
on_show = function(picker_inner)
if not prev_mode:match '^i' then
vim.schedule(function()
picker_inner.input:stopinsert()
end)
end
end,
}
picker:close()
end, |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
VishalSubramanyam
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Open in Insert mode:
Restore previous mode: