From d6258a9bad10e97d2582a102750e0e931bb9321a Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sun, 7 Nov 2021 13:12:17 +0000 Subject: vim-patch:8.2.2014: using CTRL-O in a prompt buffer moves cursor to start Problem: Using CTRL-O in a prompt buffer moves cursor to start of the line. Solution: Do not move the cursor when restarting edit. (closes vim/vim#7330) https://github.com/vim/vim/commit/ee8b787bcd15f63a938243770065e704c9b5c85f Test_prompt_editing is skipped, so edit the Lua test in prompt_buffer_spec. --- src/nvim/edit.c | 2 +- src/nvim/testdir/test_prompt_buffer.vim | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/edit.c b/src/nvim/edit.c index dfdefddc20..9bfb8a9d4a 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -1686,7 +1686,7 @@ static void init_prompt(int cmdchar_todo) if (cmdchar_todo == 'A') { coladvance(MAXCOL); } - if (cmdchar_todo == 'I' || curwin->w_cursor.col <= (int)STRLEN(prompt)) { + if (curwin->w_cursor.col < (colnr_T)STRLEN(prompt)) { curwin->w_cursor.col = STRLEN(prompt); } // Make sure the cursor is in a valid position. diff --git a/src/nvim/testdir/test_prompt_buffer.vim b/src/nvim/testdir/test_prompt_buffer.vim index af7231c9c0..4212dcb36e 100644 --- a/src/nvim/testdir/test_prompt_buffer.vim +++ b/src/nvim/testdir/test_prompt_buffer.vim @@ -89,9 +89,12 @@ func Test_prompt_editing() call term_sendkeys(buf, left . left . left . bs . '-') call WaitForAssert({-> assert_equal('cmd: -hel', term_getline(buf, 1))}) + call term_sendkeys(buf, "\lz") + call WaitForAssert({-> assert_equal('cmd: -hzel', term_getline(buf, 1))}) + let end = "\" call term_sendkeys(buf, end . "x") - call WaitForAssert({-> assert_equal('cmd: -helx', term_getline(buf, 1))}) + call WaitForAssert({-> assert_equal('cmd: -hzelx', term_getline(buf, 1))}) call term_sendkeys(buf, "\exit\") call WaitForAssert({-> assert_equal('other buffer', term_getline(buf, 1))}) -- cgit