mirror of
https://github.com/folke/snacks.nvim
synced 2025-07-24 13:34:09 +00:00
fix(input): put the cursor right after the default prompt (#549)
## Description When the input opens, the cursor is placed two columns to the right after the default prompt, but should be one. The cause is the `vim.api.nvim_win_set_cursor` takes (row, col) with the base of (1, 0) */I hate this/* ## Related Issue(s) No related issue created. ## Screenshots `:lua Snacks.input({ default = "aaa" }, function () end )` gives the input as "aaa |" (where pipe shows the cursor position) Co-authored-by: Igor Iatsenko <igor.iatsenko@here.com>
This commit is contained in:
parent
af559349e5
commit
f904481439
1 changed files with 1 additions and 1 deletions
|
@ -189,7 +189,7 @@ function M.input(opts, on_confirm)
|
|||
vim.cmd.startinsert()
|
||||
if opts.default then
|
||||
vim.api.nvim_buf_set_lines(win.buf, 0, -1, false, { opts.default })
|
||||
vim.api.nvim_win_set_cursor(win.win, { 1, #opts.default + 1 })
|
||||
vim.api.nvim_win_set_cursor(win.win, { 1, #opts.default })
|
||||
end
|
||||
vim.fn.prompt_setcallback(win.buf, function(text)
|
||||
confirm(text)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue