mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 10:49:08 +00:00
perf(picker): dont use prompt buffer callbacks
This commit is contained in:
parent
790447f3ad
commit
8293add1e5
3 changed files with 11 additions and 7 deletions
|
@ -6,6 +6,16 @@ local SCROLL_WHEEL_DOWN = Snacks.util.keycode("<ScrollWheelDown>")
|
|||
local SCROLL_WHEEL_UP = Snacks.util.keycode("<ScrollWheelUp>")
|
||||
|
||||
function M.jump(picker)
|
||||
-- if we're still in insert mode, stop it and schedule
|
||||
-- it to prevent issues with cursor position
|
||||
if vim.fn.mode():sub(1, 1) == "i" then
|
||||
vim.cmd.stopinsert()
|
||||
vim.schedule(function()
|
||||
M.jump(picker)
|
||||
end)
|
||||
return
|
||||
end
|
||||
|
||||
picker:close()
|
||||
local win = vim.api.nvim_get_current_win()
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ local defaults = {
|
|||
-- to close the picker on ESC instead of going to normal mode,
|
||||
-- add the following keymap to your config
|
||||
-- ["<Esc>"] = { "close", mode = { "n", "i" } },
|
||||
["<CR>"] = "confirm",
|
||||
["<CR>"] = { "confirm", mode = { "n", "i" } },
|
||||
["G"] = "list_bottom",
|
||||
["gg"] = "list_top",
|
||||
["j"] = "list_down",
|
||||
|
|
|
@ -29,12 +29,6 @@ function M.new(picker)
|
|||
self.win:focus()
|
||||
vim.cmd.startinsert()
|
||||
vim.api.nvim_win_set_cursor(self.win.win, { 1, #self:get() + 1 })
|
||||
vim.fn.prompt_setcallback(self.win.buf, function()
|
||||
vim.cmd.stopinsert()
|
||||
vim.schedule(function()
|
||||
self.win:execute("confirm")
|
||||
end)
|
||||
end)
|
||||
end,
|
||||
bo = {
|
||||
filetype = "snacks_picker_input",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue