From 708617ebb6aa9f078549646930c73f0755c2c2e6 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 14 Nov 2016 15:13:50 +0100 Subject: inccommand=nosplit: Jump to first match. Call update_topline() to adjust the current viewport. Closes #5597 --- test/functional/ui/inccommand_spec.lua | 54 ++++++++-------------------------- 1 file changed, 13 insertions(+), 41 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 7b6f82569a..811fee3a82 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -600,46 +600,18 @@ describe(":substitute, 'inccommand' preserves undo", function() feed(":%s/tw/MO/g") feed("u") - if case == "split" then - screen:expect([[ - ^LInc substitution on| - two lines | - | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - Already...st change | - ]]) - elseif case == "" then - screen:expect([[ - ^LInc substitution on| - two lines | - | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - Already...st change | - ]]) - else - screen:expect([[ - LInc substitution on| - ^two lines | - | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - Already...st change | - ]]) - end + screen:expect([[ + ^LInc substitution on| + two lines | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + Already...st change | + ]]) end screen:detach() end) @@ -905,11 +877,11 @@ describe(":substitute, inccommand=split", function() feed(":%s/tw/X") screen:expect([[ - Inc substitution on | BBo lines | Inc substitution on | Xo lines | Inc substitution on | + Xo lines | {11:[No Name] [+] }| |1001| {12:X}o lines | |1003| {12:X}o lines | -- cgit From 35231312d785e4fd1f534e573a43f5a9a4a0fe8f Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 15 Nov 2016 03:21:50 +0100 Subject: 'inccommand': Add tests. --- test/functional/ui/inccommand_spec.lua | 119 +++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 811fee3a82..2899925ed8 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -761,6 +761,7 @@ describe(":substitute, inccommand=split", function() it('does not show split window for :s/', function() feed("2gg") feed(":s/tw") + wait() screen:expect([[ Inc substitution on | two lines | @@ -935,6 +936,89 @@ describe(":substitute, inccommand=split", function() ]]) end) + it("deactivates if 'redrawtime' is exceeded #5602", function() + -- Assert that 'inccommand' is ENABLED initially. + eq("split", eval("&inccommand")) + -- Set 'redrawtime' to minimal value, to ensure timeout is triggered. + execute("set redrawtime=1 nowrap") + -- Load a big file. + execute("silent edit! test/functional/fixtures/bigfile.txt") + -- Start :substitute with a slow pattern. + feed([[:%s/B.*N/x]]) + wait() + + -- Assert that 'inccommand' is DISABLED in cmdline mode. + eq("", eval("&inccommand")) + -- Assert that preview cleared (or never manifested). + screen:expect([[ + 0000;;Cc;0;BN;;;;;N;N| + 0001;;Cc;0;BN;;;;;N;S| + 0002;;Cc;0;BN;;;;;N;S| + 0003;;Cc;0;BN;;;;;N;E| + 0004;;Cc;0;BN;;;;;N;E| + 0005;;Cc;0;BN;;;;;N;E| + 0006;;Cc;0;BN;;;;;N;A| + 0007;;Cc;0;BN;;;;;N;B| + 0008;;Cc;0;BN;;;;;N;B| + 0009;;Cc;0;S;;;;;N;CH| + 000A;;Cc;0;B;;;;;N;LI| + 000B;;Cc;0;S;;;;;N;LI| + 000C;;Cc;0;WS;;;;;N;F| + 000D;;Cc;0;B;;;;;N;CA| + :%s/B.*N/x^ | + ]]) + + -- Assert that 'inccommand' is again ENABLED after leaving cmdline mode. + feed([[]]) + eq("split", eval("&inccommand")) + end) + + it("clears preview if non-previewable command is edited #5585", function() + -- Put a non-previewable command in history. + execute("echo 'foo'") + -- Start an incomplete :substitute command. + feed(":1,2s/t/X") + + screen:expect([[ + Inc subsXitution on | + Xwo lines | + Inc substitution on | + two lines | + | + {11:[No Name] [+] }| + |1| Inc subs{12:X}itution on | + |2| {12:X}wo lines | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {10:[Preview] }| + :1,2s/t/X^ | + ]]) + + -- Select the previous command. + feed("") + -- Assert that preview was cleared. + screen:expect([[ + Inc substitution on | + two lines | + Inc substitution on | + two lines | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :echo 'foo'^ | + ]]) + end) + end) describe("inccommand=nosplit", function() @@ -1046,6 +1130,41 @@ describe("inccommand=nosplit", function() ]]) end) + it("clears preview if non-previewable command is edited", function() + -- Put a non-previewable command in history. + execute("echo 'foo'") + -- Start an incomplete :substitute command. + feed(":1,2s/t/X") + + screen:expect([[ + Inc subsXitution on | + Xwo lines | + Inc substitution on | + two lines | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :1,2s/t/X^ | + ]]) + + -- Select the previous command. + feed("") + -- Assert that preview was cleared. + screen:expect([[ + Inc substitution on | + two lines | + Inc substitution on | + two lines | + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :echo 'foo'^ | + ]]) + end) end) describe(":substitute, 'inccommand' with a failing expression", function() -- cgit