aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/inccommand_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/ui/inccommand_spec.lua')
-rw-r--r--test/functional/ui/inccommand_spec.lua151
1 files changed, 116 insertions, 35 deletions
diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua
index 351c4b4bcf..b841574643 100644
--- a/test/functional/ui/inccommand_spec.lua
+++ b/test/functional/ui/inccommand_spec.lua
@@ -88,14 +88,14 @@ 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)
end
end
-describe(":substitute, inccommand=split", function()
+describe(":substitute, inccommand=split interactivity", function()
before_each(function()
clear()
common_setup(nil, "split", default_text)
@@ -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,19 +723,15 @@ 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")
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 |
@@ -786,6 +779,59 @@ describe(":substitute, inccommand=split", function()
{15:~ }|
:silent tabedit %s/tw/to^ |
]])
+ feed('<Esc>')
+
+ -- leading colons
+ feed(':::%s/tw/to')
+ screen:expect{any=[[{12:to}o lines]]}
+ feed('<Esc>')
+ 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('<Esc>')
+ 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('<Esc>')
+ screen:expect{any=[[two lines]]}
end)
it('shows split window when typing the pattern', function()
@@ -793,9 +839,9 @@ describe(":substitute, inccommand=split", function()
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 |
@@ -814,9 +860,9 @@ describe(":substitute, inccommand=split", function()
screen:expect([[
Inc substitution on |
o lines |
+ Inc substitution on |
+ o lines |
|
- {15:~ }|
- {15:~ }|
{11:[No Name] [+] }|
|2| o lines |
|4| o lines |
@@ -833,9 +879,9 @@ describe(":substitute, inccommand=split", function()
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 |
@@ -852,9 +898,9 @@ describe(":substitute, inccommand=split", function()
screen:expect([[
Inc substitution on |
o lines |
+ Inc substitution on |
+ o lines |
|
- {15:~ }|
- {15:~ }|
{11:[No Name] [+] }|
|2| o lines |
|4| o lines |
@@ -874,9 +920,9 @@ describe(":substitute, inccommand=split", function()
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 +984,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 |
@@ -1241,10 +1287,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 +1761,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()
@@ -2205,11 +2243,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 +2523,11 @@ describe(":substitute", function()
wait()
feed([[:%s/\(some\)\@<lt>!thing/one/]])
screen:expect([[
+ something |
every{12:one} |
someone |
{15:~ }|
{15:~ }|
- {15:~ }|
{11:[No Name] [+] }|
|2| every{12:one} |
{15:~ }|
@@ -2527,11 +2565,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:~ }|
@@ -2544,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('<CR>')
+ 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()