Merge pull request #18696 from bfredl/quickinc

fix(tests): fix some issues with ui/inccommand_spec.lua causing slowness
This commit is contained in:
bfredl 2022-05-22 17:51:31 +02:00 committed by GitHub
commit b863c150c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -123,13 +123,11 @@ describe(":substitute, inccommand=split interactivity", function()
it("no preview if invoked by feedkeys()", function() it("no preview if invoked by feedkeys()", function()
-- in a script... -- in a script...
source([[:call feedkeys(":%s/tw/MO/g\<CR>")]]) source([[:call feedkeys(":%s/tw/MO/g\<CR>")]])
poke_eventloop()
-- or interactively... -- or interactively...
feed([[:call feedkeys(":%s/tw/MO/g\<CR>")<CR>]]) feed([[:call feedkeys(":%s/bs/BUU/g\<lt>CR>")<CR>]])
poke_eventloop()
eq(1, eval("bufnr('$')")) eq(1, eval("bufnr('$')"))
-- sanity check: assert the buffer state -- sanity check: assert the buffer state
expect(default_text:gsub("tw", "MO")) expect(default_text:gsub("tw", "MO"):gsub("bs", "BUU"))
end) end)
end) end)
@ -381,7 +379,7 @@ describe(":substitute, 'inccommand' preserves undo", function()
} }
local function test_sub(substring, split, redoable) local function test_sub(substring, split, redoable)
clear() command('bwipe!')
feed_command("set inccommand=" .. split) feed_command("set inccommand=" .. split)
insert("1") insert("1")
@ -407,7 +405,7 @@ describe(":substitute, 'inccommand' preserves undo", function()
end end
local function test_notsub(substring, split, redoable) local function test_notsub(substring, split, redoable)
clear() command('bwipe!')
feed_command("set inccommand=" .. split) feed_command("set inccommand=" .. split)
insert("1") insert("1")
@ -441,7 +439,7 @@ describe(":substitute, 'inccommand' preserves undo", function()
local function test_threetree(substring, split) local function test_threetree(substring, split)
clear() command('bwipe!')
feed_command("set inccommand=" .. split) feed_command("set inccommand=" .. split)
insert("1") insert("1")
@ -493,6 +491,8 @@ describe(":substitute, 'inccommand' preserves undo", function()
2]]) 2]])
end end
before_each(clear)
it("at a non-leaf of the undo tree", function() it("at a non-leaf of the undo tree", function()
for _, case in pairs(cases) do for _, case in pairs(cases) do
for _, str in pairs(substrings) do for _, str in pairs(substrings) do
@ -1646,10 +1646,12 @@ end)
describe("'inccommand' and :cnoremap", function() describe("'inccommand' and :cnoremap", function()
local cases = { "", "split", "nosplit" } local cases = { "", "split", "nosplit" }
local screen
local function refresh(case) local function refresh(case, visual)
clear() clear()
common_setup(nil, case, default_text) screen = visual and Screen.new(50,10) or nil
common_setup(screen, case, default_text)
end end
it('work with remapped characters', function() it('work with remapped characters', function()
@ -1706,10 +1708,12 @@ describe("'inccommand' and :cnoremap", function()
it('still works with a broken mapping', function() it('still works with a broken mapping', function()
for _, case in pairs(cases) do for _, case in pairs(cases) do
refresh(case) refresh(case, true)
feed_command("cnoremap <expr> x execute('bwipeout!')[-1].'x'") feed_command("cnoremap <expr> x execute('bwipeout!')[-1].'x'")
feed(":%s/tw/tox<enter>") feed(":%s/tw/tox<enter>")
screen:expect{any=[[{14:^E523:]]}
feed('<c-c>')
-- error thrown b/c of the mapping -- error thrown b/c of the mapping
neq(nil, eval('v:errmsg'):find('^E523:')) neq(nil, eval('v:errmsg'):find('^E523:'))