neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 2a5d687cc92b46c7530310f043471b9f7ab2c6aa
parent b3096b5860ca4c9a9b9c15a96026c1da080ac8de
Author: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Date:   Sun, 15 Feb 2026 05:45:57 +0000

fix(prompt): prompt_setprompt sets cursor col unnecessarily

Problem: prompt_setprompt adjusts the cursor's column number even when it's not
on the prompt's line.

Solution: only adjust when on the prompt's line.

Diffstat:
Msrc/nvim/eval/buffer.c | 2+-
Mtest/functional/legacy/prompt_buffer_spec.lua | 17+++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/nvim/eval/buffer.c b/src/nvim/eval/buffer.c @@ -800,7 +800,7 @@ void f_prompt_setprompt(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) cursor_col += new_prompt_len - old_prompt_len; } - if (curwin->w_buffer == buf) { + if (curwin->w_buffer == buf && curwin->w_cursor.lnum == prompt_lno) { coladvance(curwin, cursor_col); } changed_lines_redraw_buf(buf, prompt_lno, prompt_lno + 1, 0); diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua @@ -858,7 +858,24 @@ describe('prompt buffer', function() ]]) eq({ 1, 13 }, api.nvim_buf_get_mark(0, ':')) + -- Cursor not moved when not on the prompt line. + feed('<CR>user input<Esc>k') + screen:expect([[ + new-prompt > user inpu^t | + new-prompt > user input | + {1:~ }|*7 + | + ]]) + set_prompt('<>< ') + screen:expect([[ + new-prompt > user inpu^t | + <>< user input | + {1:~ }|*7 + | + ]]) + -- No crash when setting shorter prompt than curbuf's in other buffer. + feed('i<C-O>zt') command('new | setlocal buftype=prompt') set_prompt('looooooooooooooooooooooooooooooooooooooooooooong > ', '') -- curbuf set_prompt('foo > ')