aboutsummaryrefslogtreecommitdiff
path: root/test/functional/editor
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2023-11-29 21:52:58 +0000
committerJosh Rahm <joshuarahm@gmail.com>2023-11-29 21:52:58 +0000
commit931bffbda3668ddc609fc1da8f9eb576b170aa52 (patch)
treed8c1843a95da5ea0bb4acc09f7e37843d9995c86 /test/functional/editor
parent142d9041391780ac15b89886a54015fdc5c73995 (diff)
parent4a8bf24ac690004aedf5540fa440e788459e5e34 (diff)
downloadrneovim-userreg.tar.gz
rneovim-userreg.tar.bz2
rneovim-userreg.zip
Merge remote-tracking branch 'upstream/master' into userreguserreg
Diffstat (limited to 'test/functional/editor')
-rw-r--r--test/functional/editor/K_spec.lua2
-rw-r--r--test/functional/editor/completion_spec.lua127
-rw-r--r--test/functional/editor/fold_spec.lua140
-rw-r--r--test/functional/editor/jump_spec.lua42
-rw-r--r--test/functional/editor/mark_spec.lua87
-rw-r--r--test/functional/editor/mode_cmdline_spec.lua28
-rw-r--r--test/functional/editor/mode_insert_spec.lua85
-rw-r--r--test/functional/editor/put_spec.lua41
8 files changed, 400 insertions, 152 deletions
diff --git a/test/functional/editor/K_spec.lua b/test/functional/editor/K_spec.lua
index 3b5580540f..b964fb3467 100644
--- a/test/functional/editor/K_spec.lua
+++ b/test/functional/editor/K_spec.lua
@@ -59,7 +59,7 @@ describe('K', function()
end)
it('empty string falls back to :help #19298', function()
- meths.set_option('keywordprg', '')
+ meths.set_option_value('keywordprg', '', {})
meths.buf_set_lines(0, 0, -1, true, {'doesnotexist'})
feed('K')
eq('E149: Sorry, no help for doesnotexist', meths.get_vvar('errmsg'))
diff --git a/test/functional/editor/completion_spec.lua b/test/functional/editor/completion_spec.lua
index 22857efe5b..cbaf401f06 100644
--- a/test/functional/editor/completion_spec.lua
+++ b/test/functional/editor/completion_spec.lua
@@ -941,6 +941,15 @@ describe('completion', function()
end)
end)
+ it('cmdline completion supports various string options', function()
+ eq('auto', funcs.getcompletion('set foldcolumn=', 'cmdline')[2])
+ eq({'nosplit', 'split'}, funcs.getcompletion('set inccommand=', 'cmdline'))
+ eq({'ver:3,hor:6', 'hor:', 'ver:'}, funcs.getcompletion('set mousescroll=', 'cmdline'))
+ eq('BS', funcs.getcompletion('set termpastefilter=', 'cmdline')[2])
+ eq('SpecialKey', funcs.getcompletion('set winhighlight=', 'cmdline')[1])
+ eq('SpecialKey', funcs.getcompletion('set winhighlight=NonText:', 'cmdline')[1])
+ end)
+
describe('from the commandline window', function()
it('is cleared after CTRL-C', function ()
feed('q:')
@@ -988,7 +997,7 @@ describe('completion', function()
return ''
endfunction
]])
- meths.set_option('completeopt', 'menuone,noselect')
+ meths.set_option_value('completeopt', 'menuone,noselect', {})
meths.set_var('_complist', {{
word=0,
abbr=1,
@@ -1032,93 +1041,6 @@ describe('completion', function()
]])
end)
- -- oldtest: Test_ChangedP()
- it('TextChangedI and TextChangedP autocommands', function()
- curbufmeths.set_lines(0, 1, false, { 'foo', 'bar', 'foobar'})
- source([[
- set complete=. completeopt=menuone
- let g:foo = []
- autocmd! TextChanged * :call add(g:foo, "N")
- autocmd! TextChangedI * :call add(g:foo, "I")
- autocmd! TextChangedP * :call add(g:foo, "P")
- call cursor(3, 1)
- ]])
-
- command('let g:foo = []')
- feed('o')
- poke_eventloop()
- feed('<esc>')
- eq({'I'}, eval('g:foo'))
-
- command('let g:foo = []')
- feed('S')
- poke_eventloop()
- feed('f')
- poke_eventloop()
- eq({'I', 'I'}, eval('g:foo'))
- feed('<esc>')
-
- command('let g:foo = []')
- feed('S')
- poke_eventloop()
- feed('f')
- poke_eventloop()
- feed('<C-N>')
- poke_eventloop()
- eq({'I', 'I', 'P'}, eval('g:foo'))
- feed('<esc>')
-
- command('let g:foo = []')
- feed('S')
- poke_eventloop()
- feed('f')
- poke_eventloop()
- feed('<C-N>')
- poke_eventloop()
- feed('<C-N>')
- poke_eventloop()
- eq({'I', 'I', 'P', 'P'}, eval('g:foo'))
- feed('<esc>')
-
- command('let g:foo = []')
- feed('S')
- poke_eventloop()
- feed('f')
- poke_eventloop()
- feed('<C-N>')
- poke_eventloop()
- feed('<C-N>')
- poke_eventloop()
- feed('<C-N>')
- poke_eventloop()
- eq({'I', 'I', 'P', 'P', 'P'}, eval('g:foo'))
- feed('<esc>')
-
- command('let g:foo = []')
- feed('S')
- poke_eventloop()
- feed('f')
- poke_eventloop()
- feed('<C-N>')
- poke_eventloop()
- feed('<C-N>')
- poke_eventloop()
- feed('<C-N>')
- poke_eventloop()
- feed('<C-N>')
- eq({'I', 'I', 'P', 'P', 'P', 'P'}, eval('g:foo'))
- feed('<esc>')
-
- eq({'foo', 'bar', 'foobar', 'foo'}, eval('getline(1, "$")'))
-
- source([[
- au! TextChanged
- au! TextChangedI
- au! TextChangedP
- set complete&vim completeopt&vim
- ]])
- end)
-
it('CompleteChanged autocommand', function()
curbufmeths.set_lines(0, 1, false, { 'foo', 'bar', 'foobar', ''})
source([[
@@ -1306,4 +1228,33 @@ describe('completion', function()
expect('colorscheme NOSUCHCOLORSCHEME')
assert_alive()
end)
+
+ it('complete with f flag #25598', function()
+ screen:try_resize(20, 9)
+ command('set complete+=f | edit foo | edit bar |edit foa |edit .hidden')
+ feed('i<C-n>')
+ screen:expect{grid=[[
+ foo^ |
+ {2:foo }{0: }|
+ {1:bar }{0: }|
+ {1:foa }{0: }|
+ {1:.hidden }{0: }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {3:-- }{4:match 1 of 4} |
+ ]]}
+ feed('<Esc>ccf<C-n>')
+ screen:expect{grid=[[
+ foo^ |
+ {2:foo }{0: }|
+ {1:foa }{0: }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {3:-- }{4:match 1 of 2} |
+ ]]}
+ end)
end)
diff --git a/test/functional/editor/fold_spec.lua b/test/functional/editor/fold_spec.lua
index 00e83bedc8..424ce839a2 100644
--- a/test/functional/editor/fold_spec.lua
+++ b/test/functional/editor/fold_spec.lua
@@ -4,17 +4,18 @@ local clear = helpers.clear
local insert = helpers.insert
local feed = helpers.feed
local expect = helpers.expect
-local feed_command = helpers.feed_command
+local command = helpers.command
local funcs = helpers.funcs
-local foldlevel = funcs.foldlevel
-local foldclosedend = funcs.foldclosedend
local eq = helpers.eq
+local neq = helpers.neq
describe('Folds', function()
local tempfname = 'Xtest-fold.txt'
- clear()
- before_each(function() feed_command('enew!') end)
+
+ setup(clear)
+ before_each(function() command('bwipe! | new') end)
after_each(function() os.remove(tempfname) end)
+
it('manual folding adjusts with filter', function()
insert([[
1
@@ -37,8 +38,11 @@ describe('Folds', function()
18
19
20]])
- feed_command('4,$fold', '%foldopen', '10,$fold', '%foldopen')
- feed_command('1,8! cat')
+ command('4,$fold')
+ command('%foldopen')
+ command('10,$fold')
+ command('%foldopen')
+ command('1,8! cat')
feed('5ggzdzMGdd')
expect([[
1
@@ -51,22 +55,24 @@ describe('Folds', function()
8
9]])
end)
+
describe('adjusting folds after :move', function()
local function manually_fold_indent()
-- setting foldmethod twice is a trick to get vim to set the folds for me
- feed_command('set foldmethod=indent', 'set foldmethod=manual')
+ command('setlocal foldmethod=indent')
+ command('setlocal foldmethod=manual')
-- Ensure that all folds will get closed (makes it easier to test the
-- length of folds).
- feed_command('set foldminlines=0')
+ command('setlocal foldminlines=0')
-- Start with all folds open (so :move ranges aren't affected by closed
-- folds).
- feed_command('%foldopen!')
+ command('%foldopen!')
end
local function get_folds()
local rettab = {}
for i = 1, funcs.line('$') do
- table.insert(rettab, foldlevel(i))
+ table.insert(rettab, funcs.foldlevel(i))
end
return rettab
end
@@ -75,16 +81,16 @@ describe('Folds', function()
-- This test is easy because we just need to ensure that the resulting
-- fold is the same as calculated when creating folds from scratch.
insert(insert_string)
- feed_command(move_command)
+ command(move_command)
local after_move_folds = get_folds()
-- Doesn't change anything, but does call foldUpdateAll()
- feed_command('set foldminlines=0')
+ command('setlocal foldminlines=0')
eq(after_move_folds, get_folds())
-- Set up the buffer with insert_string for the manual fold testing.
- feed_command('enew!')
+ command('enew!')
insert(insert_string)
manually_fold_indent()
- feed_command(move_command)
+ command(move_command)
end
it('neither closes nor corrupts folds', function()
@@ -130,19 +136,20 @@ a
for i = 1,funcs.line('$') do
eq(-1, funcs.foldclosed(i))
if i == 1 or i == 7 or i == 13 then
- eq(0, foldlevel(i))
+ eq(0, funcs.foldlevel(i))
elseif i == 4 then
- eq(2, foldlevel(i))
+ eq(2, funcs.foldlevel(i))
else
- eq(1, foldlevel(i))
+ eq(1, funcs.foldlevel(i))
end
end
-- folds are not corrupted
feed('zM')
- eq(6, foldclosedend(2))
- eq(12, foldclosedend(8))
- eq(18, foldclosedend(14))
+ eq(6, funcs.foldclosedend(2))
+ eq(12, funcs.foldclosedend(8))
+ eq(18, funcs.foldclosedend(14))
end)
+
it("doesn't split a fold when the move is within it", function()
test_move_indent([[
a
@@ -157,6 +164,7 @@ a
a]], '5m6')
eq({0, 1, 1, 2, 2, 2, 2, 1, 1, 0}, get_folds())
end)
+
it('truncates folds that end in the moved range', function()
test_move_indent([[
a
@@ -168,6 +176,7 @@ a
a]], '4,5m6')
eq({0, 1, 2, 0, 0, 0, 0}, get_folds())
end)
+
it('moves folds that start between moved range and destination', function()
test_move_indent([[
a
@@ -185,6 +194,7 @@ a
a]], '3,4m$')
eq({0, 1, 1, 0, 0, 1, 2, 1, 0, 0, 1, 0, 0}, get_folds())
end)
+
it('does not affect folds outside changed lines', function()
test_move_indent([[
a
@@ -198,6 +208,7 @@ a
a]], '4m5')
eq({1, 1, 1, 0, 0, 0, 1, 1, 1}, get_folds())
end)
+
it('moves and truncates folds that start in moved range', function()
test_move_indent([[
a
@@ -212,6 +223,7 @@ a
a]], '1,3m7')
eq({0, 0, 0, 0, 0, 1, 2, 0, 0, 0}, get_folds())
end)
+
it('breaks a fold when moving text into it', function()
test_move_indent([[
a
@@ -223,6 +235,7 @@ a
a]], '$m4')
eq({0, 1, 2, 2, 0, 0, 0}, get_folds())
end)
+
it('adjusts correctly when moving a range backwards', function()
test_move_indent([[
a
@@ -232,6 +245,7 @@ a
a]], '2,3m0')
eq({1, 2, 0, 0, 0}, get_folds())
end)
+
it('handles shifting all remaining folds', function()
test_move_indent([[
a
@@ -252,6 +266,7 @@ a]], '13m7')
eq({1, 2, 2, 2, 1, 2, 2, 1, 1, 1, 2, 2, 2, 1, 0}, get_folds())
end)
end)
+
it('updates correctly on :read', function()
-- luacheck: ignore 621
helpers.write_file(tempfname, [[
@@ -265,8 +280,10 @@ a]], '13m7')
a
a
]])
- feed_command('set foldmethod=indent', '2', '%foldopen')
- feed_command('read ' .. tempfname)
+ command('setlocal foldmethod=indent')
+ command('2')
+ command('%foldopen')
+ command('read ' .. tempfname)
-- Just to check we have the correct file text.
expect([[
a
@@ -288,6 +305,7 @@ a]], '13m7')
eq(1, funcs.foldlevel(i))
end
end)
+
it('combines folds when removing separating space', function()
-- luacheck: ignore 621
insert([[
@@ -300,9 +318,11 @@ a]], '13m7')
a
a
]])
- feed_command('set foldmethod=indent', '3,5d')
+ command('setlocal foldmethod=indent')
+ command('3,5d')
eq(5, funcs.foldclosedend(1))
end)
+
it("doesn't combine folds that have a specified end", function()
insert([[
{{{
@@ -314,9 +334,12 @@ a]], '13m7')
}}}
]])
- feed_command('set foldmethod=marker', '3,5d', '%foldclose')
+ command('setlocal foldmethod=marker')
+ command('3,5d')
+ command('%foldclose')
eq(2, funcs.foldclosedend(1))
end)
+
it('splits folds according to >N and <N with foldexpr', function()
helpers.source([[
function TestFoldExpr(lnum)
@@ -350,8 +373,11 @@ a]], '13m7')
a
a
]])
- feed_command('set foldmethod=expr', 'set foldexpr=TestFoldExpr(v:lnum)', '2', 'foldopen')
- feed_command('read ' .. tempfname, '%foldclose')
+ command('setlocal foldmethod=expr foldexpr=TestFoldExpr(v:lnum)')
+ command('2')
+ command('foldopen')
+ command('read ' .. tempfname)
+ command('%foldclose')
eq(2, funcs.foldclosedend(1))
eq(0, funcs.foldlevel(3))
eq(0, funcs.foldlevel(4))
@@ -359,4 +385,64 @@ a]], '13m7')
eq(10, funcs.foldclosedend(7))
eq(14, funcs.foldclosedend(11))
end)
+
+ it('no folds remain if :delete makes buffer empty #19671', function()
+ command('setlocal foldmethod=manual')
+ funcs.setline(1, {'foo', 'bar', 'baz'})
+ command('2,3fold')
+ command('%delete')
+ eq(0, funcs.foldlevel(1))
+ end)
+
+ it('multibyte fold markers work #20438', function()
+ command('setlocal foldmethod=marker foldmarker=«,» commentstring=/*%s*/')
+ insert([[
+ bbbbb
+ bbbbb
+ bbbbb]])
+ feed('zfgg')
+ expect([[
+ bbbbb/*«*/
+ bbbbb
+ bbbbb/*»*/]])
+ eq(1, funcs.foldlevel(1))
+ end)
+
+ it('updates correctly with indent method and visual blockwise insertion #22898', function()
+ insert([[
+ a
+ b
+ ]])
+ command('setlocal foldmethod=indent shiftwidth=2')
+ feed('gg0<C-v>jI <Esc>') -- indent both lines using visual blockwise mode
+ eq(1, funcs.foldlevel(1))
+ eq(1, funcs.foldlevel(2))
+ end)
+
+ it("doesn't open folds with indent method when inserting lower foldlevel line", function()
+ insert([[
+ insert an unindented line under this line
+ keep the lines under this line folded
+ keep this line folded 1
+ keep this line folded 2
+ ]])
+ command('set foldmethod=indent shiftwidth=2 noautoindent')
+ eq(1, funcs.foldlevel(1))
+ eq(1, funcs.foldlevel(2))
+ eq(2, funcs.foldlevel(3))
+ eq(2, funcs.foldlevel(4))
+
+ feed('zo') -- open the outer fold
+ neq(-1, funcs.foldclosed(3)) -- make sure the inner fold is not open
+
+ feed('gg0oa<Esc>') -- insert unindented line
+
+ eq(1, funcs.foldlevel(1)) --| insert an unindented line under this line
+ eq(0, funcs.foldlevel(2)) --|a
+ eq(1, funcs.foldlevel(3)) --| keep the lines under this line folded
+ eq(2, funcs.foldlevel(4)) --| keep this line folded 1
+ eq(2, funcs.foldlevel(5)) --| keep this line folded 2
+
+ neq(-1, funcs.foldclosed(4)) -- make sure the inner fold is still not open
+ end)
end)
diff --git a/test/functional/editor/jump_spec.lua b/test/functional/editor/jump_spec.lua
index 63f522fe6e..dc056cb252 100644
--- a/test/functional/editor/jump_spec.lua
+++ b/test/functional/editor/jump_spec.lua
@@ -48,6 +48,48 @@ describe('jumplist', function()
feed('<C-O>')
eq(buf1, funcs.bufnr('%'))
end)
+
+ it('<C-O> scrolls cursor halfway when switching buffer #25763', function()
+ write_file(fname1, ('foobar\n'):rep(100))
+ write_file(fname2, 'baz')
+
+ local screen = Screen.new(5, 25)
+ screen:attach()
+ command('set number')
+ command('edit '..fname1)
+ feed('35gg')
+ command('edit '..fname2)
+ feed('<C-O>')
+ screen:expect{grid=[[
+ {1: 24 }foobar |
+ {1: 25 }foobar |
+ {1: 26 }foobar |
+ {1: 27 }foobar |
+ {1: 28 }foobar |
+ {1: 29 }foobar |
+ {1: 30 }foobar |
+ {1: 31 }foobar |
+ {1: 32 }foobar |
+ {1: 33 }foobar |
+ {1: 34 }foobar |
+ {1: 35 }^foobar |
+ {1: 36 }foobar |
+ {1: 37 }foobar |
+ {1: 38 }foobar |
+ {1: 39 }foobar |
+ {1: 40 }foobar |
+ {1: 41 }foobar |
+ {1: 42 }foobar |
+ {1: 43 }foobar |
+ {1: 44 }foobar |
+ {1: 45 }foobar |
+ {1: 46 }foobar |
+ {1: 47 }foobar |
+ |
+ ]], attr_ids={
+ [1] = {foreground = Screen.colors.Brown};
+ }}
+ end)
end)
describe("jumpoptions=stack behaves like 'tagstack'", function()
diff --git a/test/functional/editor/mark_spec.lua b/test/functional/editor/mark_spec.lua
index b3b190ef79..e669d7f2bb 100644
--- a/test/functional/editor/mark_spec.lua
+++ b/test/functional/editor/mark_spec.lua
@@ -24,7 +24,6 @@ describe('named marks', function()
os.remove(file2)
end)
-
it("can be set", function()
command("edit " .. file1)
command("mark a")
@@ -40,59 +39,59 @@ describe('named marks', function()
it("errors when set out of range with :mark", function()
command("edit " .. file1)
local err = pcall_err(helpers.exec_capture, "1000mark x")
- eq("nvim_exec(): Vim(mark):E16: Invalid range: 1000mark x", err)
+ eq("nvim_exec2(): Vim(mark):E16: Invalid range: 1000mark x", err)
end)
it("errors when set out of range with :k", function()
command("edit " .. file1)
local err = pcall_err(helpers.exec_capture, "1000kx")
- eq("nvim_exec(): Vim(k):E16: Invalid range: 1000kx", err)
+ eq("nvim_exec2(): Vim(k):E16: Invalid range: 1000kx", err)
end)
it("errors on unknown mark name with :mark", function()
command("edit " .. file1)
local err = pcall_err(helpers.exec_capture, "mark #")
- eq("nvim_exec(): Vim(mark):E191: Argument must be a letter or forward/backward quote", err)
+ eq("nvim_exec2(): Vim(mark):E191: Argument must be a letter or forward/backward quote", err)
end)
it("errors on unknown mark name with '", function()
command("edit " .. file1)
local err = pcall_err(helpers.exec_capture, "normal! '#")
- eq("nvim_exec(): Vim(normal):E78: Unknown mark", err)
+ eq("nvim_exec2(): Vim(normal):E78: Unknown mark", err)
end)
it("errors on unknown mark name with `", function()
command("edit " .. file1)
local err = pcall_err(helpers.exec_capture, "normal! `#")
- eq("nvim_exec(): Vim(normal):E78: Unknown mark", err)
+ eq("nvim_exec2(): Vim(normal):E78: Unknown mark", err)
end)
it("errors when moving to a mark that is not set with '", function()
command("edit " .. file1)
local err = pcall_err(helpers.exec_capture, "normal! 'z")
- eq("nvim_exec(): Vim(normal):E20: Mark not set", err)
+ eq("nvim_exec2(): Vim(normal):E20: Mark not set", err)
err = pcall_err(helpers.exec_capture, "normal! '.")
- eq("nvim_exec(): Vim(normal):E20: Mark not set", err)
+ eq("nvim_exec2(): Vim(normal):E20: Mark not set", err)
end)
it("errors when moving to a mark that is not set with `", function()
command("edit " .. file1)
local err = pcall_err(helpers.exec_capture, "normal! `z")
- eq("nvim_exec(): Vim(normal):E20: Mark not set", err)
+ eq("nvim_exec2(): Vim(normal):E20: Mark not set", err)
err = pcall_err(helpers.exec_capture, "normal! `>")
- eq("nvim_exec(): Vim(normal):E20: Mark not set", err)
+ eq("nvim_exec2(): Vim(normal):E20: Mark not set", err)
end)
it("errors when moving to a global mark that is not set with '", function()
command("edit " .. file1)
local err = pcall_err(helpers.exec_capture, "normal! 'Z")
- eq("nvim_exec(): Vim(normal):E20: Mark not set", err)
+ eq("nvim_exec2(): Vim(normal):E20: Mark not set", err)
end)
it("errors when moving to a global mark that is not set with `", function()
command("edit " .. file1)
local err = pcall_err(helpers.exec_capture, "normal! `Z")
- eq("nvim_exec(): Vim(normal):E20: Mark not set", err)
+ eq("nvim_exec2(): Vim(normal):E20: Mark not set", err)
end)
it("can move to them using '", function()
@@ -147,13 +146,27 @@ describe('named marks', function()
eq({2, 2}, cursor())
end)
+ it("can move to them using :'", function()
+ command("args " .. file1 .. " " .. file2)
+ feed("j")
+ feed("ma")
+ feed("G")
+ command("'a")
+ eq({2, 0}, cursor())
+ feed("mA")
+ command("next")
+ command("'A")
+ eq(1, meths.get_current_buf().id)
+ eq({2, 0}, cursor())
+ end)
+
it("errors when it can't find the buffer", function()
command("args " .. file1 .. " " .. file2)
feed("mA")
command("next")
command("bw! " .. file1 )
local err = pcall_err(helpers.exec_capture, "normal! 'A")
- eq("nvim_exec(): Vim(normal):E92: Buffer 1 not found", err)
+ eq("nvim_exec2(): Vim(normal):E92: Buffer 1 not found", err)
os.remove(file1)
end)
@@ -161,7 +174,7 @@ describe('named marks', function()
feed('ifoo<Esc>mA')
command('enew')
feed('ibar<Esc>')
- eq('Vim(print):E20: Mark not set', pcall_err(command, [['Aprint]]))
+ eq("Vim(print):E20: Mark not set: 'Aprint", pcall_err(command, [['Aprint]]))
end)
it("leave a context mark when moving with '", function()
@@ -413,8 +426,52 @@ describe('named marks view', function()
6 line |
^7 line |
8 line |
- {MATCH:.*} |
+ {MATCH:.*marks} |
|
]])
end)
+
+ it('fallback to standard behavior when mark is loaded from shada', function()
+ local screen = Screen.new(10, 6)
+ screen:attach()
+ command('edit ' .. file1)
+ feed('G')
+ feed('mA')
+ screen:expect([[
+ 26 line |
+ 27 line |
+ 28 line |
+ 29 line |
+ ^30 line |
+ |
+ ]])
+ command('set shadafile=Xtestfile-functional-editor-marks-shada')
+ finally(function()
+ command('set shadafile=NONE')
+ os.remove('Xtestfile-functional-editor-marks-shada')
+ end)
+ command('wshada!')
+ command('bwipe!')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]])
+ command('rshada!')
+ command('edit ' .. file1)
+ feed('`"')
+ screen:expect([[
+ 26 line |
+ 27 line |
+ 28 line |
+ 29 line |
+ ^30 line |
+ |
+ ]])
+ feed('`A')
+ screen:expect_unchanged()
+ end)
end)
diff --git a/test/functional/editor/mode_cmdline_spec.lua b/test/functional/editor/mode_cmdline_spec.lua
index 50cc5e17ee..d34b5a1a28 100644
--- a/test/functional/editor/mode_cmdline_spec.lua
+++ b/test/functional/editor/mode_cmdline_spec.lua
@@ -1,9 +1,11 @@
-- Cmdline-mode tests.
local helpers = require('test.functional.helpers')(after_each)
+local Screen = require('test.functional.ui.screen')
local clear, insert, funcs, eq, feed =
helpers.clear, helpers.insert, helpers.funcs, helpers.eq, helpers.feed
local eval = helpers.eval
+local command = helpers.command
local meths = helpers.meths
describe('cmdline', function()
@@ -43,6 +45,30 @@ describe('cmdline', function()
eq('"<C-J><C-@><C-[><C-S-M><M-C-I><C-D-J>', eval('@:'))
end)
+ it('redraws statusline when toggling overstrike', function()
+ local screen = Screen.new(60, 4)
+ screen:set_default_attr_ids({
+ [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
+ [1] = {reverse = true, bold = true}, -- StatusLine
+ })
+ screen:attach()
+ command('set laststatus=2 statusline=%!mode(1)')
+ feed(':')
+ screen:expect{grid=[[
+ |
+ {0:~ }|
+ {1:c }|
+ :^ |
+ ]]}
+ feed('<Insert>')
+ screen:expect{grid=[[
+ |
+ {0:~ }|
+ {1:cr }|
+ :^ |
+ ]]}
+ end)
+
describe('history', function()
it('correctly clears start of the history', function()
-- Regression test: check absence of the memory leak when clearing start of
@@ -55,7 +81,7 @@ describe('cmdline', function()
it('correctly clears end of the history', function()
-- Regression test: check absence of the memory leak when clearing end of
-- the history using ex_getln.c/clr_history().
- meths.set_option('history', 1)
+ meths.set_option_value('history', 1, {})
eq(1, funcs.histadd(':', 'foo'))
eq(1, funcs.histdel(':'))
eq('', funcs.histget(':', -1))
diff --git a/test/functional/editor/mode_insert_spec.lua b/test/functional/editor/mode_insert_spec.lua
index cd51a65be3..37651164f5 100644
--- a/test/functional/editor/mode_insert_spec.lua
+++ b/test/functional/editor/mode_insert_spec.lua
@@ -1,6 +1,7 @@
-- Insert-mode tests.
local helpers = require('test.functional.helpers')(after_each)
+local Screen = require('test.functional.ui.screen')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local expect = helpers.expect
local command = helpers.command
@@ -48,6 +49,56 @@ describe('insert-mode', function()
feed('i<C-r>"')
expect('påskägg')
end)
+
+ it('double quote is removed after hit-enter prompt #22609', function()
+ local screen = Screen.new(60, 6)
+ screen:set_default_attr_ids({
+ [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
+ [1] = {foreground = Screen.colors.Blue}, -- SpecialKey
+ [2] = {foreground = Screen.colors.SlateBlue},
+ [3] = {bold = true}, -- ModeMsg
+ [4] = {reverse = true, bold = true}, -- MsgSeparator
+ [5] = {background = Screen.colors.Red, foreground = Screen.colors.White}, -- ErrorMsg
+ [6] = {foreground = Screen.colors.SeaGreen, bold = true}, -- MoreMsg
+ })
+ screen:attach()
+ feed('i<C-R>')
+ screen:expect([[
+ {1:^"} |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {3:-- INSERT --} |
+ ]])
+ feed('={}')
+ screen:expect([[
+ {1:"} |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ ={2:{}}^ |
+ ]])
+ feed('<CR>')
+ screen:expect([[
+ {1:"} |
+ {0:~ }|
+ {4: }|
+ ={2:{}} |
+ {5:E731: Using a Dictionary as a String} |
+ {6:Press ENTER or type command to continue}^ |
+ ]])
+ feed('<CR>')
+ screen:expect([[
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {3:-- INSERT --} |
+ ]])
+ end)
end)
describe('Ctrl-O', function()
@@ -141,4 +192,38 @@ describe('insert-mode', function()
feed('i<C-S-V><C-J><C-S-V><C-@><C-S-V><C-[><C-S-V><C-S-M><C-S-V><M-C-I><C-S-V><C-D-J><Esc>')
expect('<C-J><C-@><C-[><C-S-M><M-C-I><C-D-J>')
end)
+
+ it('multi-char mapping updates screen properly #25626', function()
+ local screen = Screen.new(60, 6)
+ screen:set_default_attr_ids({
+ [0] = {bold = true, foreground = Screen.colors.Blue}; -- NonText
+ [1] = {bold = true, reverse = true}; -- StatusLine
+ [2] = {reverse = true}; -- StatusLineNC
+ [3] = {bold = true}; -- ModeMsg
+ })
+ screen:attach()
+ command('vnew')
+ insert('foo\nfoo\nfoo')
+ command('wincmd w')
+ command('set timeoutlen=10000')
+ command('inoremap jk <Esc>')
+ feed('i<CR>βββ<Left><Left>j')
+ screen:expect{grid=[[
+ foo │ |
+ foo │β^jβ |
+ foo │{0:~ }|
+ {0:~ }│{0:~ }|
+ {2:[No Name] [+] }{1:[No Name] [+] }|
+ {3:-- INSERT --} |
+ ]]}
+ feed('k')
+ screen:expect{grid=[[
+ foo │ |
+ foo │^βββ |
+ foo │{0:~ }|
+ {0:~ }│{0:~ }|
+ {2:[No Name] [+] }{1:[No Name] [+] }|
+ |
+ ]]}
+ end)
end)
diff --git a/test/functional/editor/put_spec.lua b/test/functional/editor/put_spec.lua
index 5050edff5c..47068470bb 100644
--- a/test/functional/editor/put_spec.lua
+++ b/test/functional/editor/put_spec.lua
@@ -9,22 +9,21 @@ local eq = helpers.eq
local map = helpers.tbl_map
local filter = helpers.tbl_filter
local feed_command = helpers.feed_command
+local command = helpers.command
local curbuf_contents = helpers.curbuf_contents
local funcs = helpers.funcs
local dedent = helpers.dedent
-local getreg = funcs.getreg
local function reset()
- feed_command('enew!')
+ command('bwipe! | new')
insert([[
Line of words 1
Line of words 2]])
- feed_command('goto 1')
+ command('goto 1')
feed('itest_string.<esc>u')
funcs.setreg('a', 'test_stringa', 'V')
funcs.setreg('b', 'test_stringb\ntest_stringb\ntest_stringb', 'b')
funcs.setreg('"', 'test_string"', 'v')
- feed_command('set virtualedit=')
end
-- We check the last inserted register ". in each of these tests because it is
@@ -508,10 +507,10 @@ describe('put command', function()
test_expect(exception_table, after_redo)
if selection_string then
if not conversion_table.put_backwards then
- eq(selection_string, getreg('"'))
+ eq(selection_string, funcs.getreg('"'))
end
else
- eq('test_string"', getreg('"'))
+ eq('test_string"', funcs.getreg('"'))
end
end
end
@@ -644,7 +643,7 @@ describe('put command', function()
-- Set curswant to '8' to be at the end of the tab character
-- This is where the cursor is put back after the 'u' command.
funcs.setpos('.', {0, 2, 1, 0, 8})
- feed_command('set autoindent')
+ command('set autoindent')
end
)
end)
@@ -655,7 +654,7 @@ describe('put command', function()
test_stringx" Line of words 2]]
run_normal_mode_tests(test_string, 'p', function()
funcs.setline('$', ' Line of words 2')
- feed_command('set virtualedit=all')
+ command('setlocal virtualedit=all')
funcs.setpos('.', {0, 2, 1, 2, 3})
end)
end)
@@ -667,7 +666,7 @@ describe('put command', function()
Line of words 2]]
run_normal_mode_tests(test_string, 'p', function()
funcs.setline('$', ' Line of words 2')
- feed_command('set virtualedit=all')
+ command('setlocal virtualedit=all')
funcs.setpos('.', {0, 1, 16, 1, 17})
end, true)
end)
@@ -717,7 +716,7 @@ describe('put command', function()
return function(exception_table, after_redo)
test_expect(exception_table, after_redo)
if not conversion_table.put_backwards then
- eq('Line of words 1\n', getreg('"'))
+ eq('Line of words 1\n', funcs.getreg('"'))
end
end
end
@@ -753,7 +752,7 @@ describe('put command', function()
return function(e,c)
test_expect(e,c)
if not conversion_table.put_backwards then
- eq('Lin\nLin', getreg('"'))
+ eq('Lin\nLin', funcs.getreg('"'))
end
end
end
@@ -836,7 +835,7 @@ describe('put command', function()
'vp',
function()
funcs.setline('$', ' Line of words 2')
- feed_command('set virtualedit=all')
+ command('setlocal virtualedit=all')
funcs.setpos('.', {0, 2, 1, 2, 3})
end,
nil,
@@ -851,7 +850,7 @@ describe('put command', function()
base_expect_string,
'vp',
function()
- feed_command('set virtualedit=all')
+ command('setlocal virtualedit=all')
funcs.setpos('.', {0, 1, 16, 2, 18})
end,
true,
@@ -903,6 +902,8 @@ describe('put command', function()
end
end
end, unchanged=(not should_ring)}
+ screen.bell = false
+ screen.visualbell = false
end
it('should not ring the bell with gp at end of line', function()
@@ -920,12 +921,12 @@ describe('put command', function()
end)
it('should ring the bell when deleting if not appropriate', function()
- feed_command('goto 2')
- feed('i<bs><esc>')
- expect([[
- ine of words 1
- Line of words 2]])
- bell_test(function() feed('".P') end, true)
+ command('goto 2')
+ feed('i<bs><esc>')
+ expect([[
+ ine of words 1
+ Line of words 2]])
+ bell_test(function() feed('".P') end, true)
end)
it('should restore cursor position after undo of ".p', function()
@@ -935,7 +936,7 @@ describe('put command', function()
end)
it("should be unaffected by 'autoindent' with V\".2p", function()
- feed_command('set autoindent')
+ command('set autoindent')
feed('i test_string.<esc>u')
feed('V".2p')
expect([[