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.lua117
1 files changed, 87 insertions, 30 deletions
diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua
index f2282e3fb8..7b6f82569a 100644
--- a/test/functional/ui/inccommand_spec.lua
+++ b/test/functional/ui/inccommand_spec.lua
@@ -413,7 +413,7 @@ describe(":substitute, 'inccommand' preserves undo", function()
insert("X")
feed("IY<esc>")
feed(":%s/tw/MO/<esc>")
- -- using execute("undo") here will result in a "Press ENTER" prompt
+ -- execute("undo") here would cause "Press ENTER".
feed("u")
expect(default_text:gsub("Inc", "XInc"))
feed("u")
@@ -430,6 +430,7 @@ describe(":substitute, 'inccommand' preserves undo", function()
if case == "split" then
screen:expect([[
+ Inc substitution on |
^MOo lines |
|
{15:~ }|
@@ -438,7 +439,6 @@ describe(":substitute, 'inccommand' preserves undo", function()
{15:~ }|
{15:~ }|
{15:~ }|
- {15:~ }|
Already...st change |
]])
else
@@ -482,6 +482,7 @@ describe(":substitute, 'inccommand' preserves undo", function()
if case == "split" then
screen:expect([[
+ Inc substitution on |
two line^s |
|
{15:~ }|
@@ -490,7 +491,6 @@ describe(":substitute, 'inccommand' preserves undo", function()
{15:~ }|
{15:~ }|
{15:~ }|
- {15:~ }|
Already...st change |
]])
else
@@ -522,6 +522,7 @@ describe(":substitute, 'inccommand' preserves undo", function()
if case == "split" then
screen:expect([[
+ Inc substitution on |
^MOo lines |
|
{15:~ }|
@@ -530,7 +531,6 @@ describe(":substitute, 'inccommand' preserves undo", function()
{15:~ }|
{15:~ }|
{15:~ }|
- {15:~ }|
Already...st change |
]])
else
@@ -564,6 +564,7 @@ describe(":substitute, 'inccommand' preserves undo", function()
feed("u")
if case == "split" then
screen:expect([[
+ Inc substitution on |
^MOo lines |
|
{15:~ }|
@@ -572,7 +573,6 @@ describe(":substitute, 'inccommand' preserves undo", function()
{15:~ }|
{15:~ }|
{15:~ }|
- {15:~ }|
Already...st change |
]])
else
@@ -602,7 +602,8 @@ describe(":substitute, 'inccommand' preserves undo", function()
if case == "split" then
screen:expect([[
- ^two lines |
+ ^LInc substitution on|
+ two lines |
|
{15:~ }|
{15:~ }|
@@ -610,7 +611,6 @@ describe(":substitute, 'inccommand' preserves undo", function()
{15:~ }|
{15:~ }|
{15:~ }|
- {15:~ }|
Already...st change |
]])
elseif case == "" then
@@ -705,7 +705,7 @@ describe(":substitute, inccommand=split", function()
]])
end)
- it('shows split window with empty replacement', function()
+ it('shows preview with empty replacement', function()
feed(":%s/tw/")
screen:expect([[
Inc substitution on |
@@ -727,11 +727,11 @@ describe(":substitute, inccommand=split", function()
feed("x")
screen:expect([[
- xo lines |
Inc substitution on |
xo lines |
|
{15:~ }|
+ {15:~ }|
{11:[No Name] [+] }|
|2| {12:x}o lines |
|4| {12:x}o lines |
@@ -746,11 +746,11 @@ describe(":substitute, inccommand=split", function()
feed("<bs>")
screen:expect([[
- o lines |
Inc substitution on |
o lines |
|
{15:~ }|
+ {15:~ }|
{11:[No Name] [+] }|
|2| o lines |
|4| o lines |
@@ -768,11 +768,11 @@ describe(":substitute, inccommand=split", function()
it('shows split window when typing replacement', function()
feed(":%s/tw/XX")
screen:expect([[
- XXo lines |
Inc substitution on |
XXo lines |
|
{15:~ }|
+ {15:~ }|
{11:[No Name] [+] }|
|2| {12:XX}o lines |
|4| {12:XX}o lines |
@@ -808,16 +808,37 @@ describe(":substitute, inccommand=split", function()
]])
end)
- it("'hlsearch' highlights the substitution, 'cursorline' does not", function()
- execute("set hlsearch")
- execute("set cursorline") -- Should NOT appear in the preview window.
- feed(":%s/tw")
+ it("'hlsearch' is active, 'cursorline' is not", function()
+ execute("set hlsearch cursorline")
+ feed("gg")
+
+ -- Assert that 'cursorline' is active.
screen:expect([[
+ {16:^Inc substitution on }|
+ two lines |
Inc substitution on |
- {9:tw}{16:o lines }|
+ two lines |
|
{15:~ }|
{15:~ }|
+ {15:~ }|
+ {15:~ }|
+ {15:~ }|
+ {15:~ }|
+ {15:~ }|
+ {15:~ }|
+ {15:~ }|
+ :set hlsearch cursorline |
+ ]])
+
+ feed(":%s/tw")
+ -- 'cursorline' is NOT active during preview.
+ screen:expect([[
+ Inc substitution on |
+ {9:tw}o lines |
+ Inc substitution on |
+ {9:tw}o lines |
+ |
{11:[No Name] [+] }|
|2| {9:tw}o lines |
|4| {9:tw}o lines |
@@ -831,7 +852,7 @@ describe(":substitute, inccommand=split", function()
]])
end)
- it('highlights the replacement text correctly', function()
+ it('highlights the replacement text', function()
feed('ggO')
feed('M M M<esc>')
feed(':%s/M/123/g')
@@ -855,9 +876,10 @@ describe(":substitute, inccommand=split", function()
end)
it('actually replaces text', function()
- feed(":%s/tw/XX/g<enter>")
+ feed(":%s/tw/XX/g<Enter>")
screen:expect([[
+ Inc substitution on |
XXo lines |
Inc substitution on |
^XXo lines |
@@ -871,7 +893,6 @@ describe(":substitute, inccommand=split", function()
{15:~ }|
{15:~ }|
{15:~ }|
- {15:~ }|
:%s/tw/XX/g |
]])
end)
@@ -884,11 +905,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 |
@@ -922,13 +943,13 @@ describe(":substitute, inccommand=split", function()
end)
it('works with the n flag', function()
- feed(":%s/tw/Mix/n<enter>")
+ feed(":%s/tw/Mix/n<Enter>")
screen:expect([[
- ^two lines |
Inc substitution on |
two lines |
- |
- {15:~ }|
+ Inc substitution on |
+ two lines |
+ ^ |
{15:~ }|
{15:~ }|
{15:~ }|
@@ -944,7 +965,7 @@ describe(":substitute, inccommand=split", function()
end)
-describe(":substitute, inccommand=nosplit", function()
+describe("inccommand=nosplit", function()
if helpers.pending_win32(pending) then return end
local screen = Screen.new(20,10)
@@ -958,7 +979,42 @@ describe(":substitute, inccommand=nosplit", function()
if screen then screen:detach() end
end)
- it('does not show a split window anytime', function()
+ it("works with :smagic, :snomagic", function()
+ execute("set hlsearch")
+ insert("Line *.3.* here")
+
+ feed(":%smagic/3.*/X") -- start :smagic command
+ screen:expect([[
+ Inc substitution on |
+ two lines |
+ Inc substitution on |
+ two lines |
+ Line *.X |
+ {15:~ }|
+ {15:~ }|
+ {15:~ }|
+ {15:~ }|
+ :%smagic/3.*/X^ |
+ ]])
+
+
+ feed([[<C-\><C-N>]]) -- cancel
+ feed(":%snomagic/3.*/X") -- start :snomagic command
+ screen:expect([[
+ Inc substitution on |
+ two lines |
+ Inc substitution on |
+ two lines |
+ Line *.X here |
+ {15:~ }|
+ {15:~ }|
+ {15:~ }|
+ {15:~ }|
+ :%snomagic/3.*/X^ |
+ ]])
+ end)
+
+ it('never shows preview buffer', function()
execute("set hlsearch")
feed(":%s/tw")
@@ -1163,7 +1219,7 @@ describe("'inccommand' and :cnoremap", function()
end)
-describe("'inccommand': autocommands", function()
+describe("'inccommand' autocommands", function()
before_each(clear)
-- keys are events to be tested
@@ -1251,7 +1307,7 @@ describe("'inccommand': autocommands", function()
end)
-describe("'inccommand': split windows", function()
+describe("'inccommand' split windows", function()
if helpers.pending_win32(pending) then return end
local screen
@@ -1268,10 +1324,12 @@ describe("'inccommand': split windows", function()
it('work after more splits', function()
refresh()
+ feed("gg")
execute("vsplit")
execute("split")
feed(":%s/tw")
screen:expect([[
+ Inc substitution on {10:|}Inc substitution on|
two lines {10:|}two lines |
{10:|} |
{15:~ }{10:|}{15:~ }|
@@ -1285,13 +1343,12 @@ describe("'inccommand': split windows", function()
{15:~ }{10:|}{15:~ }|
{15:~ }{10:|}{15:~ }|
{15:~ }{10:|}{15:~ }|
- {15:~ }{10:|}{15:~ }|
{11:[No Name] [+] }{10:|}{15:~ }|
+ Inc substitution on {10:|}{15:~ }|
two lines {10:|}{15:~ }|
{10:|}{15:~ }|
{15:~ }{10:|}{15:~ }|
{15:~ }{10:|}{15:~ }|
- {15:~ }{10:|}{15:~ }|
{10:[No Name] [+] [No Name] [+] }|
|2| two lines |
|