From 38cd91de5f0f89daccdcbac16508af830d8001d7 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sun, 7 Nov 2021 21:28:11 +0000 Subject: vim-patch:8.2.1781: writing to prompt buffer interferes with insert mode Problem: Writing to prompt buffer interferes with insert mode. Solution: Use win_enter() instead of just setting "curwin". (Ben Jackson, closes vim/vim#7035) https://github.com/vim/vim/commit/4537bcc88956f86267c25edf8008e0dbde598652 Vim test will be skipped, so add a Lua test. The problem boils down to the use of aucmd_restbuf in a callback, so just test that (via nvim_buf_set_lines). --- test/functional/legacy/prompt_buffer_spec.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua index 513be807be..a987eaf12c 100644 --- a/test/functional/legacy/prompt_buffer_spec.lua +++ b/test/functional/legacy/prompt_buffer_spec.lua @@ -1,9 +1,12 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local feed= helpers.feed +local feed = helpers.feed local source = helpers.source local clear = helpers.clear local feed_command = helpers.feed_command +local poke_eventloop = helpers.poke_eventloop +local meths = helpers.meths +local eq = helpers.eq describe('prompt buffer', function() local screen @@ -150,4 +153,13 @@ describe('prompt buffer', function() ]]) end) + it('keeps insert mode after aucmd_restbuf in callback', function() + source [[ + let s:buf = nvim_create_buf(1, 1) + call timer_start(0, {-> nvim_buf_set_lines(s:buf, -1, -1, 0, ['walrus'])}) + startinsert + ]] + poke_eventloop() + eq({ mode = "i", blocking = false }, meths.get_mode()) + end) end) -- cgit 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. --- test/functional/legacy/prompt_buffer_spec.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua index a987eaf12c..5c077e3f7d 100644 --- a/test/functional/legacy/prompt_buffer_spec.lua +++ b/test/functional/legacy/prompt_buffer_spec.lua @@ -125,9 +125,22 @@ describe('prompt buffer', function() ~ | | ]]) + feed("lz") + screen:expect([[ + % -hz^el | + ~ | + ~ | + ~ | + [Prompt] [+] | + other buffer | + ~ | + ~ | + ~ | + | + ]]) feed("x") screen:expect([[ - % -helx^ | + % -hzelx^ | ~ | ~ | ~ | -- cgit From 0f792b284fbb924d46020a31162a7660fa6dc077 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Fri, 26 Nov 2021 03:34:41 +0000 Subject: test(prompt_buffer_spec): include changes from v8.1.1984 I already ported v8.1.1984 previously, but hadn't updated prompt_buffer_spec to match test_prompt_buffer (which we have but due to Vim features such as term_sendkeys it's mostly skipped). Required for v8.2.3671. --- test/functional/legacy/prompt_buffer_spec.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua index 5c077e3f7d..e689c29dfd 100644 --- a/test/functional/legacy/prompt_buffer_spec.lua +++ b/test/functional/legacy/prompt_buffer_spec.lua @@ -37,6 +37,7 @@ describe('prompt buffer', function() feed_command("new") feed_command("set buftype=prompt") feed_command("call prompt_setcallback(bufnr(''), function('TextEntered'))") + feed_command("eval bufnr('')->prompt_setprompt('cmd: ')") end) after_each(function() @@ -59,10 +60,10 @@ describe('prompt buffer', function() feed("i") feed("hello\n") screen:expect([[ - % hello | + cmd: hello | Command: "hello" | Result: "hello" | - % ^ | + cmd: ^ | [Prompt] [+] | other buffer | ~ | @@ -101,7 +102,7 @@ describe('prompt buffer', function() feed("i") feed("hello") screen:expect([[ - % hel^ | + cmd: hel^ | ~ | ~ | ~ | @@ -114,7 +115,7 @@ describe('prompt buffer', function() ]]) feed("-") screen:expect([[ - % -^hel | + cmd: -^hel | ~ | ~ | ~ | @@ -127,7 +128,7 @@ describe('prompt buffer', function() ]]) feed("lz") screen:expect([[ - % -hz^el | + cmd: -hz^el | ~ | ~ | ~ | @@ -140,7 +141,7 @@ describe('prompt buffer', function() ]]) feed("x") screen:expect([[ - % -hzelx^ | + cmd: -hzelx^ | ~ | ~ | ~ | -- cgit From 361f548437a0a9b620db620356fdd405d24a7b34 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Thu, 25 Nov 2021 22:53:14 +0000 Subject: vim-patch:8.2.3671: restarting Insert mode in prompt buffer too often Problem: Restarting Insert mode in prompt buffer too often when a callback switches windows and comes back. (Sean Dewar) Solution: Do not set "restart_edit" when already in Insert mode. https://github.com/vim/vim/commit/34c20ff85b87be587ea5d0398812441b502ee6a5 As Test_prompt_switch_windows is skipped, implement it in prompt_buffer_spec. Replace the 50ms term_wait calls with poke_eventloop (test seems to work anyway without them, so maybe they're not required?) The new test does include a duplicate screen test that may generate a "screen test succeeded immediately" warning, but this is done to match the Vim test. --- test/functional/legacy/prompt_buffer_spec.lua | 49 +++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'test') diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua index e689c29dfd..47eca19de3 100644 --- a/test/functional/legacy/prompt_buffer_spec.lua +++ b/test/functional/legacy/prompt_buffer_spec.lua @@ -31,6 +31,10 @@ describe('prompt buffer', function() func TimerFunc(text) call append(line("$") - 1, 'Result: "' . a:text .'"') endfunc + + func SwitchWindows() + call timer_start(0, {-> execute("wincmd p|wincmd p", "")}) + endfunc ]]) feed_command("set noshowmode | set laststatus=0") feed_command("call setline(1, 'other buffer')") @@ -167,6 +171,51 @@ describe('prompt buffer', function() ]]) end) + it('switch windows', function() + feed_command("set showmode") + feed("i") + screen:expect([[ + cmd: ^ | + ~ | + ~ | + ~ | + [Prompt] [+] | + other buffer | + ~ | + ~ | + ~ | + -- INSERT -- | + ]]) + feed(":call SwitchWindows()") + poke_eventloop() + screen:expect([[ + cmd: ^ | + ~ | + ~ | + ~ | + [Prompt] [+] | + other buffer | + ~ | + ~ | + ~ | + -- INSERT -- | + ]]) + feed("") + poke_eventloop() + screen:expect([[ + cmd:^ | + ~ | + ~ | + ~ | + [Prompt] [+] | + other buffer | + ~ | + ~ | + ~ | + | + ]]) + end) + it('keeps insert mode after aucmd_restbuf in callback', function() source [[ let s:buf = nvim_create_buf(1, 1) -- cgit