From 1f4c9da9c60f3cf5573c2f35e74c48a0f56056b4 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 25 Sep 2019 01:56:29 -0400 Subject: test: fix screen assertions --- test/functional/ui/inccommand_spec.lua | 36 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 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 351c4b4bcf..e9a7c8c2df 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -734,11 +734,11 @@ describe(":substitute, inccommand=split", function() feed_command("set nomodified") feed(":%s/tw") screen:expect([[ + Inc substitution on | + {12:tw}o lines | Inc substitution on | {12:tw}o lines | | - {15:~ }| - {15:~ }| {11:[No Name] }| |2| {12:tw}o lines | |4| {12:tw}o lines | @@ -791,11 +791,11 @@ describe(":substitute, inccommand=split", function() it('shows split window when typing the pattern', function() feed(":%s/tw") screen:expect([[ + Inc substitution on | + {12:tw}o lines | Inc substitution on | {12:tw}o lines | | - {15:~ }| - {15:~ }| {11:[No Name] [+] }| |2| {12:tw}o lines | |4| {12:tw}o lines | @@ -812,11 +812,11 @@ describe(":substitute, inccommand=split", function() it('shows preview with empty replacement', function() feed(":%s/tw/") screen:expect([[ + Inc substitution on | + o lines | Inc substitution on | o lines | | - {15:~ }| - {15:~ }| {11:[No Name] [+] }| |2| o lines | |4| o lines | @@ -831,11 +831,11 @@ describe(":substitute, inccommand=split", function() feed("x") screen:expect([[ + Inc substitution on | + {12:x}o lines | Inc substitution on | {12:x}o lines | | - {15:~ }| - {15:~ }| {11:[No Name] [+] }| |2| {12:x}o lines | |4| {12:x}o lines | @@ -850,11 +850,11 @@ describe(":substitute, inccommand=split", function() feed("") screen:expect([[ + Inc substitution on | + o lines | Inc substitution on | o lines | | - {15:~ }| - {15:~ }| {11:[No Name] [+] }| |2| o lines | |4| o lines | @@ -872,11 +872,11 @@ describe(":substitute, inccommand=split", function() it('shows split window when typing replacement', function() feed(":%s/tw/XX") screen:expect([[ + Inc substitution on | + {12:XX}o lines | Inc substitution on | {12:XX}o lines | | - {15:~ }| - {15:~ }| {11:[No Name] [+] }| |2| {12:XX}o lines | |4| {12:XX}o lines | @@ -938,11 +938,11 @@ describe(":substitute, inccommand=split", function() feed(":%s/tw") -- 'cursorline' is NOT active during preview. screen:expect([[ + Inc substitution on | {12:tw}o lines | Inc substitution on | {12:tw}o lines | | - {15:~ }| {11:[No Name] [+] }| |2| {12:tw}o lines | |4| {12:tw}o lines | @@ -2205,11 +2205,11 @@ describe(":substitute", function() feed("/KKK") screen:expect([[ + T T123 T T123 T2T TT T23423424| + x | afa {12:KKK}adf la;lkd {12:KKK}alx | | {15:~ }| - {15:~ }| - {15:~ }| {11:[No Name] [+] }| |3| afa {12:KKK}adf la;lkd {12:KKK}alx | {15:~ }| @@ -2485,11 +2485,11 @@ describe(":substitute", function() wait() feed([[:%s/\(some\)\@!thing/one/]]) screen:expect([[ + something | every{12:one} | someone | {15:~ }| {15:~ }| - {15:~ }| {11:[No Name] [+] }| |2| every{12:one} | {15:~ }| @@ -2527,11 +2527,11 @@ describe(":substitute", function() wait() feed([[:%s/some\(thing\)\@!/every/]]) screen:expect([[ + something | + everything | {12:every}one | {15:~ }| {15:~ }| - {15:~ }| - {15:~ }| {11:[No Name] [+] }| |3| {12:every}one | {15:~ }| -- cgit From 4987311fb5b8f4a11d26995f71f5f402a9e2ace4 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sun, 13 Oct 2019 20:18:22 +0200 Subject: tests/ui: remove unnecessary screen:detach() It is perfectly fine and expected to detach from the screen just by the UI disconnecting from nvim or exiting nvim. Just keep detach() in screen_basic_spec, to get some coverage of the detach method itself. This avoids hang on failure in many situations (though one could argue that detach() should be "fast", or at least "as fast as resize", which works in press-return already). Never use detach() just to change the size of the screen, try_resize() method exists for that specifically. --- test/functional/ui/inccommand_spec.lua | 15 --------------- 1 file changed, 15 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 e9a7c8c2df..d60cd08fb0 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -556,7 +556,6 @@ describe(":substitute, 'inccommand' preserves undo", function() ]]) end end - screen:detach() end) it('with undolevels=2', function() @@ -647,7 +646,6 @@ describe(":substitute, 'inccommand' preserves undo", function() Already ...t change | ]]) end - screen:detach() end end) @@ -713,7 +711,6 @@ describe(":substitute, 'inccommand' preserves undo", function() Already ...t change | ]]) end - screen:detach() end) end) @@ -726,10 +723,6 @@ describe(":substitute, inccommand=split", function() common_setup(screen, "split", default_text .. default_text) end) - after_each(function() - screen:detach() - end) - it("preserves 'modified' buffer flag", function() feed_command("set nomodified") feed(":%s/tw") @@ -1241,10 +1234,6 @@ describe("inccommand=nosplit", function() common_setup(screen, "nosplit", default_text .. default_text) end) - after_each(function() - if screen then screen:detach() end - end) - it("works with :smagic, :snomagic", function() feed_command("set hlsearch") insert("Line *.3.* here") @@ -1719,10 +1708,6 @@ describe("'inccommand' split windows", function() common_setup(screen, "split", default_text) end - after_each(function() - screen:detach() - end) - it('work after more splits', function() refresh() -- cgit From d4384cbbf37786f0185f6bbb2e5bf82f5573e532 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Wed, 30 Oct 2019 20:38:41 +0000 Subject: Remove unnecessary expr in 'icm' test --- 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 d60cd08fb0..82251a4b88 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -88,7 +88,7 @@ local function common_setup(screen, inccommand, text) }) end - command("set inccommand=" .. (inccommand and inccommand or "")) + command("set inccommand=" .. (inccommand or "")) if text then insert(text) -- cgit From 1c7aa1131297b4b3686d66aae06090e1398da56c Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Fri, 8 Mar 2019 22:49:48 +0000 Subject: Allow multiple leading colons before and after modifiers for 'inccommand' --- test/functional/ui/inccommand_spec.lua | 7 +++++++ 1 file changed, 7 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 82251a4b88..c5ad093eca 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -779,6 +779,13 @@ describe(":substitute, inccommand=split", function() {15:~ }| :silent tabedit %s/tw/to^ | ]]) + feed('') + + -- leading colons + feed(':::%s/tw/to') + screen:expect{any=[[{12:to}o lines]]} + feed('') + screen:expect{any=[[two lines]]} end) it('shows split window when typing the pattern', function() -- cgit From d52d7823898c7fee0121c4d6da730a0530bf8c50 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Tue, 29 Oct 2019 22:31:40 +0000 Subject: Prevent :topleft, etc modifying the inccommand preview window --- test/functional/ui/inccommand_spec.lua | 48 +++++++++++++++++++++++++++++++++- 1 file changed, 47 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 c5ad093eca..0d6aa7f128 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -95,7 +95,7 @@ local function common_setup(screen, inccommand, text) end end -describe(":substitute, inccommand=split", function() +describe(":substitute, inccommand=split interactivity", function() before_each(function() clear() common_setup(nil, "split", default_text) @@ -788,6 +788,52 @@ describe(":substitute, inccommand=split", function() screen:expect{any=[[two lines]]} end) + it("ignores new-window modifiers when splitting the preview window", function() + -- one modifier + feed(':topleft %s/tw/to') + screen:expect([[ + Inc substitution on | + {12:to}o lines | + Inc substitution on | + {12:to}o lines | + | + {11:[No Name] [+] }| + |2| {12:to}o lines | + |4| {12:to}o lines | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :topleft %s/tw/to^ | + ]]) + feed('') + screen:expect{any=[[two lines]]} + + -- multiple modifiers + feed(':topleft vert %s/tw/to') + screen:expect([[ + Inc substitution on | + {12:to}o lines | + Inc substitution on | + {12:to}o lines | + | + {11:[No Name] [+] }| + |2| {12:to}o lines | + |4| {12:to}o lines | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :topleft vert %s/tw/to^ | + ]]) + feed('') + screen:expect{any=[[two lines]]} + end) + it('shows split window when typing the pattern', function() feed(":%s/tw") screen:expect([[ -- cgit From d04ab11f24521e60278a0daed9a7d5abeeaf6f4f Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Tue, 29 Oct 2019 22:32:25 +0000 Subject: Prevent prompts during inccommand previews For example, "Backwards range given, OK to swap (y/n)?" on each keypress. --- test/functional/ui/inccommand_spec.lua | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 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 0d6aa7f128..b841574643 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -2582,6 +2582,49 @@ describe(":substitute", function() :%s/some\(thing\)\@!/every/^ | ]]) end) + + it("doesn't prompt to swap cmd range", function() + screen = Screen.new(50, 8) -- wide to avoid hit-enter prompt + common_setup(screen, "split", default_text) + feed(':2,1s/tw/MO/g') + + -- substitution preview should have been made, without prompting + screen:expect([[ + {12:MO}o lines | + {11:[No Name] [+] }| + |2| {12:MO}o lines | + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :2,1s/tw/MO/g^ | + ]]) + + -- but should be prompted on hitting enter + feed('') + screen:expect([[ + {12:MO}o lines | + {11:[No Name] [+] }| + |2| {12:MO}o lines | + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + {13:Backwards range given, OK to swap (y/n)?}^ | + ]]) + + feed('y') + screen:expect([[ + Inc substitution on | + ^MOo lines | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {13:Backwards range given, OK to swap (y/n)?}y | + ]]) + end) end) it(':substitute with inccommand during :terminal activity', function() -- cgit From 459a362cc140644d104de326258f9dfe75dbdcdf Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sat, 1 Feb 2020 16:16:36 +0100 Subject: extmarks: fix crash due to invalid column values in inccommand preview This used to use -1 and MAXCOL values. Make sure in range values are used. --- test/functional/ui/inccommand_spec.lua | 72 ++++++++++++++++++++++++++++++++++ 1 file changed, 72 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 b841574643..afb0c9cfa6 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -18,6 +18,7 @@ local wait = helpers.wait local nvim = helpers.nvim local sleep = helpers.sleep local nvim_dir = helpers.nvim_dir +local assert_alive = helpers.assert_alive local default_text = [[ Inc substitution on @@ -84,6 +85,7 @@ local function common_setup(screen, inccommand, text) [14] = {foreground = Screen.colors.White, background = Screen.colors.Red}, [15] = {bold=true, foreground=Screen.colors.Blue}, [16] = {background=Screen.colors.Grey90}, -- cursorline + [17] = {foreground = Screen.colors.Blue1}, vis = {background=Screen.colors.LightGrey} }) end @@ -2291,6 +2293,76 @@ 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) + common_setup(screen, "split", string.rep(text,10)) + feed(":%s/\\n\\n//g") + screen:expect{grid=[[ + CCC CC | + AAA AA | + BBB BB | + CCC CC | + | + {11:[No Name] [+] }| + | 1| AAA AA | + | 2|{12: }BBB BB | + | 3|{12: }CCC CC | + | 4|{12: }AAA AA | + | 5|{12: }BBB BB | + | 6|{12: }CCC CC | + | 7|{12: }AAA AA | + {10:[Preview] }| + :%s/\n\n/{17:^M}/g^ | + ]]} + assert_alive() + 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") + screen:expect{grid=[[ + CCC CC | + AAA AA | + BBB BB | + CCC CC | + AAA AA | + BBB BB | + CCC CC | + AAA AA | + BBB BB | + CCC CC | + AAA AA | + BBB BB | + CCC CC | + | + :%s/\n\n/{17:^M}/g^ | + ]]} + assert_alive() + end) + it("inccommand=split, multibyte text", function() common_setup(screen, "split", multibyte_text) feed(":%s/£.*ѫ/X¥¥") -- cgit