From 1037ce2e461034a20e35ad59969fd05d5ad68b91 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 9 Dec 2023 20:42:00 +0800 Subject: test: avoid repeated screen lines in expected states This is the command invoked repeatedly to make the changes: :%s/^\(.*\)|\%(\*\(\d\+\)\)\?$\n\1|\%(\*\(\d\+\)\)\?$/\=submatch(1)..'|*'..(max([str2nr(submatch(2)),1])+max([str2nr(submatch(3)),1]))/g --- test/functional/legacy/prompt_buffer_spec.lua | 86 ++++++--------------------- 1 file changed, 19 insertions(+), 67 deletions(-) (limited to 'test/functional/legacy/prompt_buffer_spec.lua') diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua index 5c3f8a6f8c..ba594801cb 100644 --- a/test/functional/legacy/prompt_buffer_spec.lua +++ b/test/functional/legacy/prompt_buffer_spec.lua @@ -57,14 +57,10 @@ describe('prompt buffer', function() ]]) screen:expect([[ cmd: ^ | - ~ | - ~ | - ~ | + ~ |*3 [Prompt] [+] | other buffer | - ~ | - ~ | - ~ | + ~ |*3 -- INSERT -- | ]]) end @@ -84,22 +80,13 @@ describe('prompt buffer', function() cmd: ^ | [Prompt] | other buffer | - ~ | - ~ | - ~ | + ~ |*3 -- INSERT -- | ]]) feed("exit\n") screen:expect([[ ^other buffer | - ~ | - ~ | - ~ | - ~ | - ~ | - ~ | - ~ | - ~ | + ~ |*8 | ]]) end) @@ -110,66 +97,43 @@ describe('prompt buffer', function() feed("hello") screen:expect([[ cmd: hel^ | - ~ | - ~ | - ~ | + ~ |*3 [Prompt] [+] | other buffer | - ~ | - ~ | - ~ | + ~ |*3 -- INSERT -- | ]]) feed("-") screen:expect([[ cmd: -^hel | - ~ | - ~ | - ~ | + ~ |*3 [Prompt] [+] | other buffer | - ~ | - ~ | - ~ | + ~ |*3 -- INSERT -- | ]]) feed("lz") screen:expect([[ cmd: -hz^el | - ~ | - ~ | - ~ | + ~ |*3 [Prompt] [+] | other buffer | - ~ | - ~ | - ~ | + ~ |*3 -- INSERT -- | ]]) feed("x") screen:expect([[ cmd: -hzelx^ | - ~ | - ~ | - ~ | + ~ |*3 [Prompt] [+] | other buffer | - ~ | - ~ | - ~ | + ~ |*3 -- INSERT -- | ]]) feed("exit\n") screen:expect([[ ^other buffer | - ~ | - ~ | - ~ | - ~ | - ~ | - ~ | - ~ | - ~ | + ~ |*8 | ]]) end) @@ -180,40 +144,28 @@ describe('prompt buffer', function() feed(":call SwitchWindows()") screen:expect{grid=[[ cmd: | - ~ | - ~ | - ~ | + ~ |*3 [Prompt] [+] | ^other buffer | - ~ | - ~ | - ~ | + ~ |*3 | ]]} feed(":call SwitchWindows()") screen:expect([[ cmd: ^ | - ~ | - ~ | - ~ | + ~ |*3 [Prompt] [+] | other buffer | - ~ | - ~ | - ~ | + ~ |*3 -- INSERT -- | ]]) feed("") screen:expect([[ cmd:^ | - ~ | - ~ | - ~ | + ~ |*3 [Prompt] [+] | other buffer | - ~ | - ~ | - ~ | + ~ |*3 | ]]) end) -- cgit From 04f2f864e270e772c6326cefdf24947f0130e492 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 3 Jan 2024 02:09:18 +0100 Subject: refactor: format test/* --- test/functional/legacy/prompt_buffer_spec.lua | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'test/functional/legacy/prompt_buffer_spec.lua') diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua index ba594801cb..76c57a23b9 100644 --- a/test/functional/legacy/prompt_buffer_spec.lua +++ b/test/functional/legacy/prompt_buffer_spec.lua @@ -72,7 +72,7 @@ describe('prompt buffer', function() -- oldtest: Test_prompt_basic() it('works', function() source_script() - feed("hello\n") + feed('hello\n') screen:expect([[ cmd: hello | Command: "hello" | @@ -83,7 +83,7 @@ describe('prompt buffer', function() ~ |*3 -- INSERT -- | ]]) - feed("exit\n") + feed('exit\n') screen:expect([[ ^other buffer | ~ |*8 @@ -94,7 +94,7 @@ describe('prompt buffer', function() -- oldtest: Test_prompt_editing() it('editing', function() source_script() - feed("hello") + feed('hello') screen:expect([[ cmd: hel^ | ~ |*3 @@ -103,7 +103,7 @@ describe('prompt buffer', function() ~ |*3 -- INSERT -- | ]]) - feed("-") + feed('-') screen:expect([[ cmd: -^hel | ~ |*3 @@ -112,7 +112,7 @@ describe('prompt buffer', function() ~ |*3 -- INSERT -- | ]]) - feed("lz") + feed('lz') screen:expect([[ cmd: -hz^el | ~ |*3 @@ -121,7 +121,7 @@ describe('prompt buffer', function() ~ |*3 -- INSERT -- | ]]) - feed("x") + feed('x') screen:expect([[ cmd: -hzelx^ | ~ |*3 @@ -130,7 +130,7 @@ describe('prompt buffer', function() ~ |*3 -- INSERT -- | ]]) - feed("exit\n") + feed('exit\n') screen:expect([[ ^other buffer | ~ |*8 @@ -141,16 +141,18 @@ describe('prompt buffer', function() -- oldtest: Test_prompt_switch_windows() it('switch windows', function() source_script() - feed(":call SwitchWindows()") - screen:expect{grid=[[ + feed(':call SwitchWindows()') + screen:expect { + grid = [[ cmd: | ~ |*3 [Prompt] [+] | ^other buffer | ~ |*3 | - ]]} - feed(":call SwitchWindows()") + ]], + } + feed(':call SwitchWindows()') screen:expect([[ cmd: ^ | ~ |*3 @@ -159,7 +161,7 @@ describe('prompt buffer', function() ~ |*3 -- INSERT -- | ]]) - feed("") + feed('') screen:expect([[ cmd:^ | ~ |*3 -- cgit From c30f2e3182e3b50e7c03932027ac55edfc8ada4a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 12 Jan 2024 12:44:54 +0000 Subject: test: typing for helpers.meths --- test/functional/legacy/prompt_buffer_spec.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'test/functional/legacy/prompt_buffer_spec.lua') diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua index 76c57a23b9..e372d713c4 100644 --- a/test/functional/legacy/prompt_buffer_spec.lua +++ b/test/functional/legacy/prompt_buffer_spec.lua @@ -180,12 +180,12 @@ describe('prompt buffer', function() call timer_start(0, {-> nvim_buf_set_lines(s:buf, -1, -1, 0, ['walrus'])}) ]] poke_eventloop() - eq({ mode = 'i', blocking = false }, meths.get_mode()) + eq({ mode = 'i', blocking = false }, meths.nvim_get_mode()) end) -- oldtest: Test_prompt_appending_while_hidden() it('accessing hidden prompt buffer does not start insert mode', function() - local prev_win = meths.get_current_win() + local prev_win = meths.nvim_get_current_win() source([[ new prompt set buftype=prompt @@ -205,16 +205,16 @@ describe('prompt buffer', function() endfunc ]]) feed('asomething') - eq('something', meths.get_var('entered')) - neq(prev_win, meths.get_current_win()) + eq('something', meths.nvim_get_var('entered')) + neq(prev_win, meths.nvim_get_current_win()) feed('exit') - eq(prev_win, meths.get_current_win()) - eq({ mode = 'n', blocking = false }, meths.get_mode()) + eq(prev_win, meths.nvim_get_current_win()) + eq({ mode = 'n', blocking = false }, meths.nvim_get_mode()) command('call DoAppend()') - eq({ mode = 'n', blocking = false }, meths.get_mode()) + eq({ mode = 'n', blocking = false }, meths.nvim_get_mode()) feed('i') - eq({ mode = 'i', blocking = false }, meths.get_mode()) + eq({ mode = 'i', blocking = false }, meths.nvim_get_mode()) command('call DoAppend()') - eq({ mode = 'i', blocking = false }, meths.get_mode()) + eq({ mode = 'i', blocking = false }, meths.nvim_get_mode()) end) end) -- cgit From 795f896a5772d5e0795f86642bdf90c82efac45c Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 12 Jan 2024 17:59:57 +0000 Subject: test: rename (meths, funcs) -> (api, fn) --- test/functional/legacy/prompt_buffer_spec.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'test/functional/legacy/prompt_buffer_spec.lua') diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua index e372d713c4..0c6898526e 100644 --- a/test/functional/legacy/prompt_buffer_spec.lua +++ b/test/functional/legacy/prompt_buffer_spec.lua @@ -5,7 +5,7 @@ local source = helpers.source local clear = helpers.clear local command = helpers.command local poke_eventloop = helpers.poke_eventloop -local meths = helpers.meths +local api = helpers.api local eq = helpers.eq local neq = helpers.neq @@ -180,12 +180,12 @@ describe('prompt buffer', function() call timer_start(0, {-> nvim_buf_set_lines(s:buf, -1, -1, 0, ['walrus'])}) ]] poke_eventloop() - eq({ mode = 'i', blocking = false }, meths.nvim_get_mode()) + eq({ mode = 'i', blocking = false }, api.nvim_get_mode()) end) -- oldtest: Test_prompt_appending_while_hidden() it('accessing hidden prompt buffer does not start insert mode', function() - local prev_win = meths.nvim_get_current_win() + local prev_win = api.nvim_get_current_win() source([[ new prompt set buftype=prompt @@ -205,16 +205,16 @@ describe('prompt buffer', function() endfunc ]]) feed('asomething') - eq('something', meths.nvim_get_var('entered')) - neq(prev_win, meths.nvim_get_current_win()) + eq('something', api.nvim_get_var('entered')) + neq(prev_win, api.nvim_get_current_win()) feed('exit') - eq(prev_win, meths.nvim_get_current_win()) - eq({ mode = 'n', blocking = false }, meths.nvim_get_mode()) + eq(prev_win, api.nvim_get_current_win()) + eq({ mode = 'n', blocking = false }, api.nvim_get_mode()) command('call DoAppend()') - eq({ mode = 'n', blocking = false }, meths.nvim_get_mode()) + eq({ mode = 'n', blocking = false }, api.nvim_get_mode()) feed('i') - eq({ mode = 'i', blocking = false }, meths.nvim_get_mode()) + eq({ mode = 'i', blocking = false }, api.nvim_get_mode()) command('call DoAppend()') - eq({ mode = 'i', blocking = false }, meths.nvim_get_mode()) + eq({ mode = 'i', blocking = false }, api.nvim_get_mode()) end) end) -- cgit From 2fce95ec439a1121271798cf00fc8ec9878813fa Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 17 Jan 2024 08:18:52 +0800 Subject: vim-patch:9.1.0033: Insert mode not stopped if closing prompt buffer modifies hidden buffer (#27051) Problem: Insert mode not stopped if an autocommand modifies a hidden buffer while closing a prompt buffer. Solution: Don't set b_prompt_insert if stop_insert_mode is already set. (zeertzjq) closes: vim/vim#13872 https://github.com/vim/vim/commit/96958366ad6159efe708b694055320ed19357e61 --- test/functional/legacy/prompt_buffer_spec.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test/functional/legacy/prompt_buffer_spec.lua') diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua index 0c6898526e..59a9283868 100644 --- a/test/functional/legacy/prompt_buffer_spec.lua +++ b/test/functional/legacy/prompt_buffer_spec.lua @@ -4,6 +4,7 @@ local feed = helpers.feed local source = helpers.source local clear = helpers.clear local command = helpers.command +local expect = helpers.expect local poke_eventloop = helpers.poke_eventloop local api = helpers.api local eq = helpers.eq @@ -217,4 +218,24 @@ describe('prompt buffer', function() command('call DoAppend()') eq({ mode = 'i', blocking = false }, api.nvim_get_mode()) end) + + -- oldtest: Test_prompt_close_modify_hidden() + it('modifying hidden buffer does not prevent prompt buffer mode change', function() + source([[ + file hidden + set bufhidden=hide + enew + new prompt + set buftype=prompt + + inoremap q bwipe! + autocmd BufWinLeave prompt call setbufline('hidden', 1, 'Test') + ]]) + feed('a') + eq({ mode = 'i', blocking = false }, api.nvim_get_mode()) + feed('q') + eq({ mode = 'n', blocking = false }, api.nvim_get_mode()) + command('bwipe!') + expect('Test') + end) end) -- cgit From 8a07ca6c4baf9a72476df4b1851aa33165b4f9c5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 18 Jan 2024 07:23:48 +0800 Subject: vim-patch:9.1.0040: issue with prompt buffer and hidden buffer (#27071) Problem: Modifying a hidden buffer still interferes with prompt buffer mode changes. Solution: Save and restore b_prompt_insert. (zeertzjq) closes: vim/vim#13875 Modifying hidden buffer still interferes with prompt buffer mode changes https://github.com/vim/vim/commit/f267847017976ab85117bdf75b45e769836f8d69 --- test/functional/legacy/prompt_buffer_spec.lua | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'test/functional/legacy/prompt_buffer_spec.lua') diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua index 59a9283868..e4810feedb 100644 --- a/test/functional/legacy/prompt_buffer_spec.lua +++ b/test/functional/legacy/prompt_buffer_spec.lua @@ -219,7 +219,7 @@ describe('prompt buffer', function() eq({ mode = 'i', blocking = false }, api.nvim_get_mode()) end) - -- oldtest: Test_prompt_close_modify_hidden() + -- oldtest: Test_prompt_leave_modify_hidden() it('modifying hidden buffer does not prevent prompt buffer mode change', function() source([[ file hidden @@ -228,14 +228,26 @@ describe('prompt buffer', function() new prompt set buftype=prompt + inoremap w wincmd w inoremap q bwipe! - autocmd BufWinLeave prompt call setbufline('hidden', 1, 'Test') + autocmd BufLeave prompt call appendbufline('hidden', '$', 'Leave') + autocmd BufEnter prompt call appendbufline('hidden', '$', 'Enter') + autocmd BufWinLeave prompt call appendbufline('hidden', '$', 'Close') ]]) feed('a') eq({ mode = 'i', blocking = false }, api.nvim_get_mode()) + feed('w') + eq({ mode = 'n', blocking = false }, api.nvim_get_mode()) + feed('w') + eq({ mode = 'i', blocking = false }, api.nvim_get_mode()) feed('q') eq({ mode = 'n', blocking = false }, api.nvim_get_mode()) command('bwipe!') - expect('Test') + expect([[ + + Leave + Enter + Leave + Close]]) end) end) -- cgit