mirror of
https://github.com/neovim/neovim.git
synced 2026-03-31 04:42:03 +00:00
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.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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 > ')
|
||||
|
||||
Reference in New Issue
Block a user