mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-05 11:18:26 +00:00
fix(picker.input): correct cursor position in input when cycling / focus. Fixes #688
This commit is contained in:
parent
3fa2ea3115
commit
93cca7a4b3
2 changed files with 3 additions and 4 deletions
|
@ -349,13 +349,13 @@ function M.cycle_win(picker)
|
||||||
win = wins[idx % #wins + 1] or 1 -- cycle
|
win = wins[idx % #wins + 1] or 1 -- cycle
|
||||||
vim.api.nvim_set_current_win(win)
|
vim.api.nvim_set_current_win(win)
|
||||||
if win == picker.input.win.win then
|
if win == picker.input.win.win then
|
||||||
vim.cmd("startinsert")
|
vim.cmd("startinsert!")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.focus_input(picker)
|
function M.focus_input(picker)
|
||||||
picker.input.win:focus()
|
picker.input.win:focus()
|
||||||
vim.cmd("startinsert")
|
vim.cmd("startinsert!")
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.focus_list(picker)
|
function M.focus_list(picker)
|
||||||
|
|
|
@ -23,11 +23,10 @@ function M.new(picker)
|
||||||
height = 1,
|
height = 1,
|
||||||
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",
|
||||||
vim.cmd.startinsert()
|
|
||||||
vim.api.nvim_win_set_cursor(self.win.win, { 1, #self:get() + 1 })
|
|
||||||
on_win = function(win)
|
on_win = function(win)
|
||||||
vim.fn.prompt_setprompt(win.buf, "")
|
vim.fn.prompt_setprompt(win.buf, "")
|
||||||
win:focus()
|
win:focus()
|
||||||
|
vim.cmd("startinsert!")
|
||||||
end,
|
end,
|
||||||
bo = {
|
bo = {
|
||||||
filetype = "snacks_picker_input",
|
filetype = "snacks_picker_input",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue