mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-07 12:18:10 +00:00
fix(picker.input): fixed startinsert weirdness with prompt buffers (again)
This commit is contained in:
parent
0add3eb398
commit
c030827d7a
1 changed files with 7 additions and 0 deletions
|
@ -24,6 +24,12 @@ function M.new(picker)
|
||||||
text = picker.opts.live and self.filter.search or self.filter.pattern,
|
text = picker.opts.live and self.filter.search or self.filter.pattern,
|
||||||
ft = "regex",
|
ft = "regex",
|
||||||
on_buf = function(win)
|
on_buf = function(win)
|
||||||
|
-- HACK: this is needed to prevent Neovim from stopping insert mode,
|
||||||
|
-- for any other picker input we are leaving.
|
||||||
|
local buf = vim.api.nvim_get_current_buf()
|
||||||
|
if buf ~= win.buf and vim.bo[buf].filetype == "snacks_picker_input" then
|
||||||
|
vim.bo[buf].buftype = "nofile"
|
||||||
|
end
|
||||||
vim.fn.prompt_setprompt(win.buf, "")
|
vim.fn.prompt_setprompt(win.buf, "")
|
||||||
vim.bo[win.buf].modified = false
|
vim.bo[win.buf].modified = false
|
||||||
end,
|
end,
|
||||||
|
@ -42,6 +48,7 @@ function M.new(picker)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
self.win:on("BufEnter", function()
|
self.win:on("BufEnter", function()
|
||||||
|
vim.bo[self.win.buf].buftype = "prompt"
|
||||||
vim.cmd("startinsert!")
|
vim.cmd("startinsert!")
|
||||||
end, { buf = true })
|
end, { buf = true })
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue