From 05faa8f30ad770d4e4ead41cec601ccced8fb97f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 15 Feb 2023 07:26:55 +0800 Subject: test: make expect_unchanged() less confusing (#22255) Problem: The sleep before collecting the initial screen state is confusing and may lead to unexpected success if it comes after a blocking RPC call. Solution: Remove that sleep and add an "intermediate" argument. --- test/functional/ui/inccommand_spec.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test/functional/ui/inccommand_spec.lua') diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 6fbf9b72c8..96634be327 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -2886,7 +2886,8 @@ it(':substitute with inccommand during :terminal activity', function() feed('gg') feed(':%s/foo/ZZZ') sleep(20) -- Allow some terminal activity. - helpers.poke_eventloop() + poke_eventloop() + screen:sleep(0) screen:expect_unchanged() end) end) -- cgit From d321deb4a9b05e9d81b79ac166274f4a6e7981bf Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 27 Apr 2023 15:51:44 +0800 Subject: test: fix dependencies between test cases (#23343) Discovered using --shuffle argument of busted. --- test/functional/ui/inccommand_spec.lua | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'test/functional/ui/inccommand_spec.lua') diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 96634be327..a67db78cbe 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -745,10 +745,11 @@ describe(":substitute, 'inccommand' preserves undo", function() end) describe(":substitute, inccommand=split", function() - local screen = Screen.new(30,15) + local screen before_each(function() clear() + screen = Screen.new(30,15) common_setup(screen, "split", default_text .. default_text) end) @@ -1413,10 +1414,11 @@ describe(":substitute, inccommand=split", function() end) describe("inccommand=nosplit", function() - local screen = Screen.new(20,10) + local screen before_each(function() clear() + screen = Screen.new(20,10) common_setup(screen, "nosplit", default_text .. default_text) end) @@ -1644,11 +1646,12 @@ describe("inccommand=nosplit", function() end) describe(":substitute, 'inccommand' with a failing expression", function() - local screen = Screen.new(20,10) + local screen local cases = { "", "split", "nosplit" } local function refresh(case) clear() + screen = Screen.new(20,10) common_setup(screen, case, default_text) end @@ -2127,9 +2130,10 @@ describe("'inccommand' with 'gdefault'", function() end) describe(":substitute", function() - local screen = Screen.new(30,15) + local screen before_each(function() clear() + screen = Screen.new(30,15) end) it("inccommand=split, highlights multiline substitutions", function() @@ -2335,8 +2339,7 @@ describe(":substitute", function() ]]) end) - it("inccommand=split, substitutions of different length", - function() + it("inccommand=split, substitutions of different length", function() common_setup(screen, "split", "T T123 T2T TTT T090804\nx") feed(":%s/T\\([0-9]\\+\\)/\\1\\1/g") @@ -2872,8 +2875,8 @@ it(':substitute with inccommand during :terminal activity', function() return end retry(2, 40000, function() - local screen = Screen.new(30,15) clear() + local screen = Screen.new(30,15) command("set cmdwinheight=3") feed(([[:terminal "%s" REP 5000 xxx]]):format(testprg('shell-test'))) @@ -2893,8 +2896,8 @@ it(':substitute with inccommand during :terminal activity', function() end) it(':substitute with inccommand, timer-induced :redraw #9777', function() - local screen = Screen.new(30,12) clear() + local screen = Screen.new(30,12) command('set cmdwinheight=3') command('call timer_start(10, {-> execute("redraw")}, {"repeat":-1})') command('call timer_start(10, {-> execute("redrawstatus")}, {"repeat":-1})') @@ -2920,8 +2923,8 @@ it(':substitute with inccommand, timer-induced :redraw #9777', function() end) it(':substitute with inccommand, allows :redraw before first separator is typed #18857', function() - local screen = Screen.new(30,6) clear() + local screen = Screen.new(30,6) common_setup(screen, 'split', 'foo bar baz\nbar baz fox\nbar foo baz') command('hi! link NormalFloat CursorLine') local float_buf = meths.create_buf(false, true) @@ -2950,8 +2953,8 @@ it(':substitute with inccommand, allows :redraw before first separator is typed end) it(':substitute with inccommand, does not crash if range contains invalid marks', function() - local screen = Screen.new(30, 6) clear() + local screen = Screen.new(30, 6) common_setup(screen, 'split', 'test') feed([[:'a,'bs]]) screen:expect([[ @@ -2976,8 +2979,8 @@ it(':substitute with inccommand, does not crash if range contains invalid marks' end) it(':substitute with inccommand, no unnecessary redraw if preview is not shown', function() - local screen = Screen.new(60, 6) clear() + local screen = Screen.new(60, 6) common_setup(screen, 'split', 'test') feed(':ls') screen:expect([[ @@ -3029,8 +3032,8 @@ it(':substitute with inccommand, no unnecessary redraw if preview is not shown', end) it(":substitute doesn't crash with inccommand, if undo is empty #12932", function() - local screen = Screen.new(10,5) clear() + local screen = Screen.new(10,5) command('set undolevels=-1') common_setup(screen, 'split', 'test') feed(':%s/test') @@ -3049,8 +3052,8 @@ it(":substitute doesn't crash with inccommand, if undo is empty #12932", functio end) it(':substitute with inccommand works properly if undo is not synced #20029', function() - local screen = Screen.new(30, 6) clear() + local screen = Screen.new(30, 6) common_setup(screen, 'nosplit', 'foo\nbar\nbaz') meths.set_keymap('x', '', '``>obbbbb asdfV`lljj') @@ -3086,8 +3089,8 @@ it(':substitute with inccommand works properly if undo is not synced #20029', fu end) it('long :%s/ with inccommand does not collapse cmdline', function() - local screen = Screen.new(10,5) clear() + local screen = Screen.new(10,5) common_setup(screen) command('set inccommand=nosplit') feed(':%s/AAAAAAA', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', -- cgit From 4a098b97e53551a3383e669f4730be542c61e012 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 5 May 2023 06:32:17 +0800 Subject: fix(excmd): append original command to error message Revert the change to do_cmdline_cmd() from #5226. This function is used in many places, so making it different from Vim leads to small differences from Vim in the behavior of some functions like execute() and assert_fails(). If DOCMD_VERBOSE really needs to be removed somewhere, a do_cmdline() call without DOCMD_VERBOSE is also shorter than a do_cmdline() call with DOCMD_VERBOSE. --- test/functional/ui/inccommand_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/ui/inccommand_spec.lua') diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index a67db78cbe..28f489783b 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -1720,7 +1720,7 @@ describe("'inccommand' and :cnoremap", function() local function refresh(case, visual) clear() - screen = visual and Screen.new(50,10) or nil + screen = visual and Screen.new(80,10) or nil common_setup(screen, case, default_text) end -- cgit From 1fe1bb084d0099fc4f9bfdc11189485d0f74b75a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 19 Dec 2022 16:37:45 +0000 Subject: refactor(options): deprecate nvim[_buf|_win]_[gs]et_option Co-authored-by: zeertzjq Co-authored-by: famiu --- test/functional/ui/inccommand_spec.lua | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'test/functional/ui/inccommand_spec.lua') diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 28f489783b..23b200bd24 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -2,7 +2,6 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear = helpers.clear local command = helpers.command -local curbufmeths = helpers.curbufmeths local eq = helpers.eq local eval = helpers.eval local feed_command = helpers.feed_command @@ -178,8 +177,8 @@ describe(":substitute, 'inccommand' preserves", function() feed_command("set inccommand=" .. case) insert("as") feed(":%s/as/glork/") - eq(meths.get_option('undolevels'), 139) - eq(curbufmeths.get_option('undolevels'), 34) + eq(meths.get_option_value('undolevels', {scope='global'}), 139) + eq(meths.get_option_value('undolevels', {buf=0}), 34) end) end @@ -1192,7 +1191,7 @@ describe(":substitute, inccommand=split", function() it("deactivates if 'redrawtime' is exceeded #5602", function() -- prevent redraws from 'incsearch' - meths.set_option('incsearch', false) + meths.set_option_value('incsearch', false, {}) -- Assert that 'inccommand' is ENABLED initially. eq("split", eval("&inccommand")) -- Set 'redrawtime' to minimal value, to ensure timeout is triggered. @@ -2465,16 +2464,14 @@ describe(":substitute", function() end) it("inccommand=split, contraction of two subsequent NL chars", function() - -- luacheck: push ignore 611 local text = [[ AAA AA - + BBB BB - + CCC CC - + ]] - -- luacheck: pop -- This used to crash, but more than 20 highlight entries are required -- to reproduce it (so that the marktree has multiple nodes) @@ -2501,16 +2498,14 @@ describe(":substitute", function() end) it("inccommand=nosplit, contraction of two subsequent NL chars", function() - -- luacheck: push ignore 611 local text = [[ AAA AA - + BBB BB - + CCC CC - + ]] - -- luacheck: pop common_setup(screen, "nosplit", string.rep(text,10)) feed(":%s/\\n\\n//g") -- cgit From b60a2ab4cb7bb7d86dcda1dfe2396a9eda384e35 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 17 Jul 2023 10:15:45 +0800 Subject: fix(inccommand): block errors when parsing command line again (#24374) Revert the change to ex_getln.c from a741c7fd0465c949a0016fcbee5f4526b65f8c02 --- test/functional/ui/inccommand_spec.lua | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'test/functional/ui/inccommand_spec.lua') diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 23b200bd24..dc4aeb9c83 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -3086,8 +3086,7 @@ end) it('long :%s/ with inccommand does not collapse cmdline', function() clear() local screen = Screen.new(10,5) - common_setup(screen) - command('set inccommand=nosplit') + common_setup(screen, 'nosplit') feed(':%s/AAAAAAA', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A') screen:expect([[ @@ -3099,6 +3098,21 @@ it('long :%s/ with inccommand does not collapse cmdline', function() ]]) end) +it("with 'inccommand' typing invalid `={expr}` does not show error", function() + clear() + local screen = Screen.new(30, 6) + common_setup(screen, 'nosplit') + feed(':edit `=`') + screen:expect([[ + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :edit `=`^ | + ]]) +end) + it("with 'inccommand' typing :filter doesn't segfault or leak memory #19057", function() clear() common_setup(nil, 'nosplit') -- cgit From c1c2a1b5dd1d73e5e97b94e6626aaac25a3db9bc Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 28 Jul 2023 15:41:58 +0800 Subject: fix(inccommand): don't save information of a buffer twice (#24501) Problem: 'inccommand' doesn't restore 'undolevels' properly for a buffer shown in multiple windows. Solution: Don't save information of a buffer twice. --- test/functional/ui/inccommand_spec.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'test/functional/ui/inccommand_spec.lua') diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index dc4aeb9c83..00dfa3fd49 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -174,9 +174,12 @@ describe(":substitute, 'inccommand' preserves", function() it("'undolevels' (inccommand="..case..")", function() feed_command("set undolevels=139") feed_command("setlocal undolevels=34") + feed_command("split") -- Show the buffer in multiple windows feed_command("set inccommand=" .. case) insert("as") - feed(":%s/as/glork/") + feed(":%s/as/glork/") + poke_eventloop() + feed("") eq(meths.get_option_value('undolevels', {scope='global'}), 139) eq(meths.get_option_value('undolevels', {buf=0}), 34) end) -- cgit From bf70a33f5e7de0218704126c149db24542e39766 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 14 Oct 2023 09:58:30 +0800 Subject: vim-patch:8.1.0822: peeking and flushing output slows down execution (#25629) Problem: Peeking and flushing output slows down execution. Solution: Do not update the mode message when global_busy is set. Do not flush when only peeking for a character. (Ken Takata) https://github.com/vim/vim/commit/cb574f415486adff645ce384979bfecf27f5be8c --- test/functional/ui/inccommand_spec.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'test/functional/ui/inccommand_spec.lua') diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 00dfa3fd49..cb00c75e74 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -2929,7 +2929,16 @@ it(':substitute with inccommand, allows :redraw before first separator is typed meths.open_win(float_buf, false, { relative = 'editor', height = 1, width = 5, row = 3, col = 0, focusable = false, }) - feed(':%s') + feed(':') + screen:expect([[ + foo bar baz | + bar baz fox | + bar foo baz | + {16: }{15: }| + {15:~ }| + :^ | + ]]) + feed('%s') screen:expect([[ foo bar baz | bar baz fox | -- cgit From 366d0c7887f76f0adc40671292db46f115c9317e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 18 Oct 2023 10:34:55 +0800 Subject: fix(move): check the correct buffer (#25698) --- test/functional/ui/inccommand_spec.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test/functional/ui/inccommand_spec.lua') diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index cb00c75e74..c9e004289d 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -3095,6 +3095,36 @@ it(':substitute with inccommand works properly if undo is not synced #20029', fu baz]]) end) +it(':substitute with inccommand does not unexpectedly change viewport #25697', function() + clear() + local screen = Screen.new(45, 5) + common_setup(screen, 'nosplit', long_multiline_text) + command('vnew | tabnew | tabclose') + screen:expect([[ + ^ │£ m n | + {15:~ }│t œ ¥ | + {15:~ }│ | + {11:[No Name] }{10:[No Name] [+] }| + | + ]]) + feed(':s/') + screen:expect([[ + │£ m n | + {15:~ }│t œ ¥ | + {15:~ }│ | + {11:[No Name] }{10:[No Name] [+] }| + :s/^ | + ]]) + feed('') + screen:expect([[ + ^ │£ m n | + {15:~ }│t œ ¥ | + {15:~ }│ | + {11:[No Name] }{10:[No Name] [+] }| + | + ]]) +end) + it('long :%s/ with inccommand does not collapse cmdline', function() clear() local screen = Screen.new(10,5) -- cgit From 9af03bcd47127a416aa6a125590b75adb5f53c3c Mon Sep 17 00:00:00 2001 From: Omar El Halabi Date: Fri, 10 Nov 2023 05:20:26 +0100 Subject: fix(options): do not change inccommand during preview (#25462) --- test/functional/ui/inccommand_spec.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test/functional/ui/inccommand_spec.lua') diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index c9e004289d..3ee67a710c 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -3167,3 +3167,31 @@ it("with 'inccommand' typing :filter doesn't segfault or leak memory #19057", fu feed('i') assert_alive() end) + +it("'inccommand' cannot be changed during preview #23136", function() + clear() + local screen = Screen.new(30, 6) + common_setup(screen, 'nosplit', 'foo\nbar\nbaz') + source([[ + function! IncCommandToggle() + let prev = &inccommand + + if &inccommand ==# 'split' + set inccommand=nosplit + elseif &inccommand ==# 'nosplit' + set inccommand=split + elseif &inccommand ==# '' + set inccommand=nosplit + else + throw 'unknown inccommand' + endif + + return " \" + endfun + + cnoremap IncCommandToggle() + ]]) + + feed(':%s/foo/bar') + assert_alive() +end) -- cgit