diff options
Diffstat (limited to 'test/functional/legacy')
17 files changed, 887 insertions, 465 deletions
diff --git a/test/functional/legacy/006_argument_list_spec.lua b/test/functional/legacy/006_argument_list_spec.lua deleted file mode 100644 index d269bf8ec9..0000000000 --- a/test/functional/legacy/006_argument_list_spec.lua +++ /dev/null @@ -1,85 +0,0 @@ --- Test for autocommand that redefines the argument list, when doing ":all". - -local helpers = require('test.functional.helpers')(after_each) -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local command, dedent, eq = helpers.command, helpers.dedent, helpers.eq -local curbuf_contents = helpers.curbuf_contents -local poke_eventloop = helpers.poke_eventloop - -describe('argument list', function() - setup(clear) - - it('is working', function() - insert([[ - start of test file Xxx - this is a test - this is a test - this is a test - this is a test - end of test file Xxx]]) - poke_eventloop() - - command('au BufReadPost Xxx2 next Xxx2 Xxx1') - command('/^start of') - - -- Write test file Xxx1 - feed('A1<Esc>:.,/end of/w! Xxx1<cr>') - - -- Write test file Xxx2 - feed('$r2:.,/end of/w! Xxx2<cr>') - - -- Write test file Xxx3 - feed('$r3:.,/end of/w! Xxx3<cr>') - poke_eventloop() - - -- Redefine arglist; go to Xxx1 - command('next! Xxx1 Xxx2 Xxx3') - - -- Open window for all args - command('all') - - -- Write contents of Xxx1 - command('%yank A') - - -- Append contents of last window (Xxx1) - feed('') - poke_eventloop() - command('%yank A') - - -- should now be in Xxx2 - command('rew') - - -- Append contents of Xxx2 - command('%yank A') - - command('%d') - command('0put=@a') - command('$d') - - eq(dedent([[ - start of test file Xxx1 - this is a test - this is a test - this is a test - this is a test - end of test file Xxx - start of test file Xxx1 - this is a test - this is a test - this is a test - this is a test - end of test file Xxx - start of test file Xxx2 - this is a test - this is a test - this is a test - this is a test - end of test file Xxx]]), curbuf_contents()) - end) - - teardown(function() - os.remove('Xxx1') - os.remove('Xxx2') - os.remove('Xxx3') - end) -end) diff --git a/test/functional/legacy/030_fileformats_spec.lua b/test/functional/legacy/030_fileformats_spec.lua index 15dbd05cf5..e88afd9c47 100644 --- a/test/functional/legacy/030_fileformats_spec.lua +++ b/test/functional/legacy/030_fileformats_spec.lua @@ -255,7 +255,7 @@ describe('fileformats option', function() -- Assert buffer contents. This has to be done manually as -- helpers.expect() calls helpers.dedent() which messes up the white space - -- and carrige returns. + -- and carriage returns. eq( 'unix\n'.. 'unix\n'.. diff --git a/test/functional/legacy/055_list_and_dict_types_spec.lua b/test/functional/legacy/055_list_and_dict_types_spec.lua index 4d71a526c1..c0ff3ed17a 100644 --- a/test/functional/legacy/055_list_and_dict_types_spec.lua +++ b/test/functional/legacy/055_list_and_dict_types_spec.lua @@ -907,7 +907,7 @@ describe('list and dictionary types', function() feed('o<C-R>=a<CR><esc>') feed_command('lang C') feed_command('redir => a') - -- The test failes if this is not in one line. + -- The test fails if this is not in one line. feed_command("try|foobar|catch|let a = matchstr(v:exception,'^[^ ]*')|endtry") feed_command('redir END') feed('o<C-R>=a<CR><esc>') diff --git a/test/functional/legacy/063_match_and_matchadd_spec.lua b/test/functional/legacy/063_match_and_matchadd_spec.lua index d164d9c02f..235a826640 100644 --- a/test/functional/legacy/063_match_and_matchadd_spec.lua +++ b/test/functional/legacy/063_match_and_matchadd_spec.lua @@ -3,10 +3,8 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local eval, clear, command = helpers.eval, helpers.clear, helpers.command -local eq, neq = helpers.eq, helpers.neq +local clear, command = helpers.clear, helpers.command local insert = helpers.insert -local pcall_err = helpers.pcall_err describe('063: Test for ":match", "matchadd()" and related functions', function() setup(clear) @@ -19,105 +17,9 @@ describe('063: Test for ":match", "matchadd()" and related functions', function( [1] = {background = Screen.colors.Red}, }) - -- Check that "matcharg()" returns the correct group and pattern if a match - -- is defined. command("highlight MyGroup1 term=bold ctermbg=red guibg=red") command("highlight MyGroup2 term=italic ctermbg=green guibg=green") command("highlight MyGroup3 term=underline ctermbg=blue guibg=blue") - command("match MyGroup1 /TODO/") - command("2match MyGroup2 /FIXME/") - command("3match MyGroup3 /XXX/") - eq({'MyGroup1', 'TODO'}, eval('matcharg(1)')) - eq({'MyGroup2', 'FIXME'}, eval('matcharg(2)')) - eq({'MyGroup3', 'XXX'}, eval('matcharg(3)')) - - -- Check that "matcharg()" returns an empty list if the argument is not 1, - -- 2 or 3 (only 0 and 4 are tested). - eq({}, eval('matcharg(0)')) - eq({}, eval('matcharg(4)')) - - -- Check that "matcharg()" returns ['', ''] if a match is not defined. - command("match") - command("2match") - command("3match") - eq({'', ''}, eval('matcharg(1)')) - eq({'', ''}, eval('matcharg(2)')) - eq({'', ''}, eval('matcharg(3)')) - - -- Check that "matchadd()" and "getmatches()" agree on added matches and - -- that default values apply. - command("let m1 = matchadd('MyGroup1', 'TODO')") - command("let m2 = matchadd('MyGroup2', 'FIXME', 42)") - command("let m3 = matchadd('MyGroup3', 'XXX', 60, 17)") - eq({{group = 'MyGroup1', pattern = 'TODO', priority = 10, id = 4}, - {group = 'MyGroup2', pattern = 'FIXME', priority = 42, id = 5}, - {group = 'MyGroup3', pattern = 'XXX', priority = 60, id = 17}}, - eval('getmatches()')) - - -- Check that "matchdelete()" deletes the matches defined in the previous - -- test correctly. - command("call matchdelete(m1)") - command("call matchdelete(m2)") - command("call matchdelete(m3)") - eq({}, eval('getmatches()')) - - --- Check that "matchdelete()" returns 0 if successful and otherwise -1. - command("let m = matchadd('MyGroup1', 'TODO')") - eq(0, eval('matchdelete(m)')) - - -- matchdelete throws error and returns -1 on failure - neq(true, pcall(function() eval('matchdelete(42)') end)) - eq('Vim(let):E803: ID not found: 42', pcall_err(command, 'let r2 = matchdelete(42)')) - - -- Check that "clearmatches()" clears all matches defined by ":match" and - -- "matchadd()". - command("let m1 = matchadd('MyGroup1', 'TODO')") - command("let m2 = matchadd('MyGroup2', 'FIXME', 42)") - command("let m3 = matchadd('MyGroup3', 'XXX', 60, 17)") - command("match MyGroup1 /COFFEE/") - command("2match MyGroup2 /HUMPPA/") - command("3match MyGroup3 /VIM/") - command("call clearmatches()") - eq({}, eval('getmatches()')) - - -- Check that "setmatches()" restores a list of matches saved by - -- "getmatches()" without changes. (Matches with equal priority must also - -- remain in the same order.) - command("let m1 = matchadd('MyGroup1', 'TODO')") - command("let m2 = matchadd('MyGroup2', 'FIXME', 42)") - command("let m3 = matchadd('MyGroup3', 'XXX', 60, 17)") - command("match MyGroup1 /COFFEE/") - command("2match MyGroup2 /HUMPPA/") - command("3match MyGroup3 /VIM/") - command("let ml = getmatches()") - local ml = eval("ml") - command("call clearmatches()") - command("call setmatches(ml)") - eq(ml, eval('getmatches()')) - - -- Check that "setmatches()" can correctly restore the matches from matchaddpos() - command("call clearmatches()") - command("call setmatches(ml)") - eq(ml, eval('getmatches()')) - - -- Check that "setmatches()" will not add two matches with the same ID. The - -- expected behaviour (for now) is to add the first match but not the - -- second and to return -1. - eq('Vim(let):E801: ID already taken: 1', - pcall_err(command, "let r1 = setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}, {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 10, 'id': 1}])")) - eq({{group = 'MyGroup1', pattern = 'TODO', priority = 10, id = 1}}, eval('getmatches()')) - - -- Check that "setmatches()" returns 0 if successful and otherwise -1. - -- (A range of valid and invalid input values are tried out to generate the - -- return values.) - eq(0,eval("setmatches([])")) - eq(0,eval("setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}])")) - command("call clearmatches()") - eq('Vim(let):E714: List required', pcall_err(command, 'let rf1 = setmatches(0)')) - eq('Vim(let):E474: List item 0 is either not a dictionary or an empty one', - pcall_err(command, 'let rf2 = setmatches([0])')) - eq('Vim(let):E474: List item 0 is missing one of the required keys', - pcall_err(command, "let rf3 = setmatches([{'wrong key': 'wrong value'}])")) -- Check that "matchaddpos()" positions matches correctly insert('abcdefghijklmnopq') diff --git a/test/functional/legacy/072_undo_file_spec.lua b/test/functional/legacy/072_undo_file_spec.lua index b4927e779e..80665027c3 100644 --- a/test/functional/legacy/072_undo_file_spec.lua +++ b/test/functional/legacy/072_undo_file_spec.lua @@ -69,7 +69,7 @@ describe('72', function() feed_command('set undofile ul=100') feed('uuuuuu:w >>test.out<cr>') - ---- Open the output to see if it meets the expections + ---- Open the output to see if it meets the expectations feed_command('e! test.out') -- Assert buffer contents. diff --git a/test/functional/legacy/083_tag_search_with_file_encoding_spec.lua b/test/functional/legacy/083_tag_search_with_file_encoding_spec.lua index e94b46ca66..54620c7104 100644 --- a/test/functional/legacy/083_tag_search_with_file_encoding_spec.lua +++ b/test/functional/legacy/083_tag_search_with_file_encoding_spec.lua @@ -26,7 +26,7 @@ describe('tag search with !_TAG_FILE_ENCODING', function() '!_TAG_FILE_ENCODING cp932 //\n' .. '\130`\130a\130b Xtags2.txt /\130`\130a\130b\n' ) - -- The last file is very long but repetetive and can be generated on the + -- The last file is very long but repetitive and can be generated on the -- fly. local text = helpers.dedent([[ !_TAG_FILE_SORTED 1 // diff --git a/test/functional/legacy/arglist_spec.lua b/test/functional/legacy/arglist_spec.lua index 4d9e88c446..a15809907b 100644 --- a/test/functional/legacy/arglist_spec.lua +++ b/test/functional/legacy/arglist_spec.lua @@ -3,7 +3,6 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear, command, eq = helpers.clear, helpers.command, helpers.eq -local eval, exc_exec, neq = helpers.eval, helpers.exc_exec, helpers.neq local expect_exit = helpers.expect_exit local feed = helpers.feed local pcall_err = helpers.pcall_err @@ -11,233 +10,6 @@ local pcall_err = helpers.pcall_err describe('argument list commands', function() before_each(clear) - local function init_abc() - command('args a b c') - command('next') - end - - local function reset_arglist() - command('arga a | %argd') - end - - local function assert_fails(cmd, err) - neq(nil, exc_exec(cmd):find(err)) - end - - it('test that argidx() works', function() - command('args a b c') - command('last') - eq(2, eval('argidx()')) - command('%argdelete') - eq(0, eval('argidx()')) - - command('args a b c') - eq(0, eval('argidx()')) - command('next') - eq(1, eval('argidx()')) - command('next') - eq(2, eval('argidx()')) - command('1argdelete') - eq(1, eval('argidx()')) - command('1argdelete') - eq(0, eval('argidx()')) - command('1argdelete') - eq(0, eval('argidx()')) - end) - - it('test that argadd() works', function() - command('%argdelete') - command('argadd a b c') - eq(0, eval('argidx()')) - - command('%argdelete') - command('argadd a') - eq(0, eval('argidx()')) - command('argadd b c d') - eq(0, eval('argidx()')) - - init_abc() - command('argadd x') - eq({'a', 'b', 'x', 'c'}, eval('argv()')) - eq(1, eval('argidx()')) - - init_abc() - command('0argadd x') - eq({'x', 'a', 'b', 'c'}, eval('argv()')) - eq(2, eval('argidx()')) - - init_abc() - command('1argadd x') - eq({'a', 'x', 'b', 'c'}, eval('argv()')) - eq(2, eval('argidx()')) - - init_abc() - command('$argadd x') - eq({'a', 'b', 'c', 'x'}, eval('argv()')) - eq(1, eval('argidx()')) - - init_abc() - command('$argadd x') - command('+2argadd y') - eq({'a', 'b', 'c', 'x', 'y'}, eval('argv()')) - eq(1, eval('argidx()')) - - command('%argd') - command('edit d') - command('arga') - eq(1, eval('len(argv())')) - eq('d', eval('get(argv(), 0, "")')) - - command('%argd') - command('new') - command('arga') - eq(0, eval('len(argv())')) - end) - - it('test for 0argadd and 0argedit', function() - reset_arglist() - - command('arga a b c d') - command('2argu') - command('0arga added') - eq({'added', 'a', 'b', 'c', 'd'}, eval('argv()')) - - command('%argd') - command('arga a b c d') - command('2argu') - command('0arge edited') - eq({'edited', 'a', 'b', 'c', 'd'}, eval('argv()')) - - command('2argu') - command('arga third') - eq({'edited', 'a', 'third', 'b', 'c', 'd'}, eval('argv()')) - end) - - it('test for argc()', function() - reset_arglist() - eq(0, eval('argc()')) - command('argadd a b') - eq(2, eval('argc()')) - end) - - it('test for arglistid()', function() - reset_arglist() - command('arga a b') - eq(0, eval('arglistid()')) - command('split') - command('arglocal') - eq(1, eval('arglistid()')) - command('tabnew | tabfirst') - eq(0, eval('arglistid(2)')) - eq(1, eval('arglistid(1, 1)')) - eq(0, eval('arglistid(2, 1)')) - eq(1, eval('arglistid(1, 2)')) - command('tabonly | only | enew!') - command('argglobal') - eq(0, eval('arglistid()')) - end) - - it('test for argv()', function() - reset_arglist() - eq({}, eval('argv()')) - eq('', eval('argv(2)')) - command('argadd a b c d') - eq('c', eval('argv(2)')) - end) - - it('test for :argedit command', function() - reset_arglist() - command('argedit a') - eq({'a'}, eval('argv()')) - eq('a', eval('expand("%:t")')) - command('argedit b') - eq({'a', 'b'}, eval('argv()')) - eq('b', eval('expand("%:t")')) - command('argedit a') - eq({'a', 'b', 'a'}, eval('argv()')) - eq('a', eval('expand("%:t")')) - command('argedit c') - eq({'a', 'b', 'a', 'c'}, eval('argv()')) - command('0argedit x') - eq({'x', 'a', 'b', 'a', 'c'}, eval('argv()')) - command('set nohidden') - command('enew! | set modified') - assert_fails('argedit y', 'E37:') - command('argedit! y') - eq({'x', 'y', 'y', 'a', 'b', 'a', 'c'}, eval('argv()')) - command('set hidden') - command('%argd') - command('argedit a b') - eq({'a', 'b'}, eval('argv()')) - end) - - it('test for :argdelete command', function() - reset_arglist() - command('args aa a aaa b bb') - command('argdelete a*') - eq({'b', 'bb'}, eval('argv()')) - eq('aa', eval('expand("%:t")')) - command('last') - command('argdelete %') - eq({'b'}, eval('argv()')) - assert_fails('argdelete', 'E610:') - assert_fails('1,100argdelete', 'E16:') - reset_arglist() - command('args a b c d') - command('next') - command('argdel') - eq({'a', 'c', 'd'}, eval('argv()')) - command('%argdel') - end) - - it('test for the :next, :prev, :first, :last, :rewind commands', function() - reset_arglist() - command('args a b c d') - command('last') - eq(3, eval('argidx()')) - assert_fails('next', 'E165:') - command('prev') - eq(2, eval('argidx()')) - command('Next') - eq(1, eval('argidx()')) - command('first') - eq(0, eval('argidx()')) - assert_fails('prev', 'E164:') - command('3next') - eq(3, eval('argidx()')) - command('rewind') - eq(0, eval('argidx()')) - command('%argd') - end) - - it('test for autocommand that redefines the argument list, when doing ":all"', function() - command('autocmd BufReadPost Xxx2 next Xxx2 Xxx1') - command("call writefile(['test file Xxx1'], 'Xxx1')") - command("call writefile(['test file Xxx2'], 'Xxx2')") - command("call writefile(['test file Xxx3'], 'Xxx3')") - - command('new') - -- redefine arglist; go to Xxx1 - command('next! Xxx1 Xxx2 Xxx3') - -- open window for all args - command('all') - eq('test file Xxx1', eval('getline(1)')) - command('wincmd w') - command('wincmd w') - eq('test file Xxx1', eval('getline(1)')) - -- should now be in Xxx2 - command('rewind') - eq('test file Xxx2', eval('getline(1)')) - - command('autocmd! BufReadPost Xxx2') - command('enew! | only') - command("call delete('Xxx1')") - command("call delete('Xxx2')") - command("call delete('Xxx3')") - command('argdelete Xxx*') - command('bwipe! Xxx1 Xxx2 Xxx3') - end) - it('quitting Vim with unedited files in the argument list throws E173', function() command('set nomore') command('args a b c') diff --git a/test/functional/legacy/autocmd_option_spec.lua b/test/functional/legacy/autocmd_option_spec.lua index 5e586d3a6a..e00b468c16 100644 --- a/test/functional/legacy/autocmd_option_spec.lua +++ b/test/functional/legacy/autocmd_option_spec.lua @@ -211,7 +211,7 @@ describe('au OptionSet', function() expected_combination({'backup', 0, 0, '', 1, 'local', 'setlocal'}) end) - it('should trigger if the current buffer is different from the targetted buffer', function() + it('should trigger if the current buffer is different from the targeted buffer', function() local new_buffer = make_buffer() local new_bufnr = buf.get_number(new_buffer) @@ -590,7 +590,7 @@ describe('au OptionSet', function() expected_combination({'backup', 0, 0, '', 1, 'local', 'setlocal'}) end) - it('should trigger if the current buffer is different from the targetted buffer', function() + it('should trigger if the current buffer is different from the targeted buffer', function() set_hook('buftype') local new_buffer = make_buffer() @@ -616,7 +616,7 @@ describe('au OptionSet', function() expected_combination({'backup', 0, 0, '', 1, 'local', 'setlocal'}) end) - it('should not trigger if the current window is different from the targetted window', function() + it('should not trigger if the current window is different from the targeted window', function() set_hook('cursorcolumn') local new_winnr = get_new_window_number() diff --git a/test/functional/legacy/buffer_spec.lua b/test/functional/legacy/buffer_spec.lua new file mode 100644 index 0000000000..acaa9a51f1 --- /dev/null +++ b/test/functional/legacy/buffer_spec.lua @@ -0,0 +1,59 @@ +local helpers = require('test.functional.helpers')(after_each) +local clear, source = helpers.clear, helpers.source +local call, eq, meths = helpers.call, helpers.eq, helpers.meths + +local function expected_empty() + eq({}, meths.get_vvar('errors')) +end + +describe('buffer', function() + before_each(function() + clear() + meths.ui_attach(80, 24, {}) + meths.set_option('hidden', false) + end) + + it('deleting a modified buffer with :confirm', function() + source([[ + func Test_bdel_with_confirm() + new + call setline(1, 'test') + call assert_fails('bdel', 'E89:') + call nvim_input('c') + confirm bdel + call assert_equal(2, winnr('$')) + call assert_equal(1, &modified) + call nvim_input('n') + confirm bdel + call assert_equal(1, winnr('$')) + endfunc + ]]) + call('Test_bdel_with_confirm') + expected_empty() + end) + + it('editing another buffer from a modified buffer with :confirm', function() + source([[ + func Test_goto_buf_with_confirm() + new Xfile + enew + call setline(1, 'test') + call assert_fails('b Xfile', 'E37:') + call nvim_input('c') + call assert_fails('confirm b Xfile', 'E37:') + call assert_equal(1, &modified) + call assert_equal('', @%) + call nvim_input('y') + call assert_fails('confirm b Xfile', 'E37:') + call assert_equal(1, &modified) + call assert_equal('', @%) + call nvim_input('n') + confirm b Xfile + call assert_equal('Xfile', @%) + close! + endfunc + ]]) + call('Test_goto_buf_with_confirm') + expected_empty() + end) +end) diff --git a/test/functional/legacy/cmdline_spec.lua b/test/functional/legacy/cmdline_spec.lua index cf02636890..2fceb6a132 100644 --- a/test/functional/legacy/cmdline_spec.lua +++ b/test/functional/legacy/cmdline_spec.lua @@ -1,9 +1,12 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear = helpers.clear +local command = helpers.command local feed = helpers.feed local feed_command = helpers.feed_command local exec = helpers.exec +local meths = helpers.meths +local pesc = helpers.pesc describe('cmdline', function() before_each(clear) @@ -18,8 +21,6 @@ describe('cmdline', function() [3] = {reverse = true}; [4] = {bold = true, foreground = Screen.colors.Blue1}; } - -- TODO(bfredl): redraw with tabs is severly broken. fix it - feed_command [[ set display-=msgsep ]] feed_command([[call setline(1, range(30))]]) screen:expect([[ @@ -60,7 +61,7 @@ describe('cmdline', function() {4:~ }| | | - :tabnew | + | ]]} feed [[gt]] @@ -140,4 +141,180 @@ describe('cmdline', function() :^ | ]]) end) + + -- oldtest: Test_redraw_in_autocmd() + it('cmdline cursor position is correct after :redraw with cmdheight=2', function() + local screen = Screen.new(30, 6) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + }) + screen:attach() + exec([[ + set cmdheight=2 + autocmd CmdlineChanged * redraw + ]]) + feed(':for i in range(3)<CR>') + screen:expect([[ + | + {0:~ }| + {0:~ }| + {0:~ }| + :for i in range(3) | + : ^ | + ]]) + feed(':let i =') + -- Note: this may still be considered broken, ref #18140 + screen:expect([[ + | + {0:~ }| + {0:~ }| + {0:~ }| + : :let i =^ | + | + ]]) + end) + + it("setting 'cmdheight' works after outputting two messages vim-patch:9.0.0665", function() + local screen = Screen.new(60, 8) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {bold = true, reverse = true}, -- StatusLine + }) + screen:attach() + exec([[ + set cmdheight=1 laststatus=2 + func EchoTwo() + set laststatus=2 + set cmdheight=5 + echo 'foo' + echo 'bar' + set cmdheight=1 + endfunc + ]]) + feed(':call EchoTwo()') + screen:expect([[ + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {1:[No Name] }| + :call EchoTwo()^ | + ]]) + feed('<CR>') + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {1:[No Name] }| + | + ]]) + end) + + -- oldtest: Test_cmdheight_tabline() + it("changing 'cmdheight' when there is a tabline", function() + local screen = Screen.new(60, 8) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {bold = true, reverse = true}, -- StatusLine + [2] = {bold = true}, -- TabLineSel + [3] = {reverse = true}, -- TabLineFill + }) + screen:attach() + meths.set_option('laststatus', 2) + meths.set_option('showtabline', 2) + meths.set_option('cmdheight', 1) + screen:expect([[ + {2: [No Name] }{3: }| + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {1:[No Name] }| + | + ]]) + end) +end) + +describe('cmdwin', function() + before_each(clear) + + -- oldtest: Test_cmdwin_interrupted() + it('still uses a new buffer when interrupting more prompt on open', function() + local screen = Screen.new(30, 16) + 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, foreground = Screen.colors.SeaGreen}, -- MoreMsg + [4] = {bold = true}, -- ModeMsg + }) + screen:attach() + command('set more') + command('autocmd WinNew * highlight') + feed('q:') + screen:expect({any = pesc('{3:-- More --}^')}) + feed('q') + screen:expect([[ + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {2:[No Name] }| + {0::}^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {1:[Command Line] }| + | + ]]) + feed([[aecho 'done']]) + screen:expect([[ + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {2:[No Name] }| + {0::}echo 'done'^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {1:[Command Line] }| + {4:-- INSERT --} | + ]]) + feed('<CR>') + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + done | + ]]) + end) end) diff --git a/test/functional/legacy/display_spec.lua b/test/functional/legacy/display_spec.lua index f0ffaf2c48..9160129a02 100644 --- a/test/functional/legacy/display_spec.lua +++ b/test/functional/legacy/display_spec.lua @@ -9,6 +9,7 @@ local command = helpers.command describe('display', function() before_each(clear) + -- oldtest: Test_display_scroll_at_topline() it('scroll when modified at topline vim-patch:8.2.1488', function() local screen = Screen.new(20, 4) screen:attach() @@ -26,6 +27,7 @@ describe('display', function() ]]) end) + -- oldtest: Test_display_scroll_update_visual() it('scrolling when modified at topline in Visual mode vim-patch:8.2.4626', function() local screen = Screen.new(60, 8) screen:attach() @@ -56,8 +58,8 @@ describe('display', function() ]]) end) - it('@@@ in the last line shows correctly in a narrow window vim-patch:8.2.4718', function() - local screen = Screen.new(60, 10) + local function run_test_display_lastline(euro) + local screen = Screen.new(75, 10) screen:set_default_attr_ids({ [1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText [2] = {bold = true, reverse = true}, -- StatusLine @@ -65,39 +67,86 @@ describe('display', function() }) screen:attach() exec([[ - call setline(1, ['aaa', 'b'->repeat(100)]) + call setline(1, ['aaa', 'b'->repeat(200)]) set display=truncate + vsplit 100wincmd < ]]) - screen:expect([[ - ^a│aaa | - a│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| - a│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | - b│{1:~ }| - b│{1:~ }| - b│{1:~ }| - b│{1:~ }| - {1:@}│{1:~ }| - {2:< }{3:[No Name] [+] }| - | - ]]) + local fillchar = '@' + if euro then + command('set fillchars=lastline:€') + fillchar = '€' + end + screen:expect((([[ + ^a│aaa | + a│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| + a│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| + b│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | + b│{1:~ }| + b│{1:~ }| + b│{1:~ }| + {1:@}│{1:~ }| + {2:< }{3:[No Name] [+] }| + | + ]]):gsub('@', fillchar))) + command('set display=lastline') screen:expect_unchanged() + command('100wincmd >') - screen:expect([[ - ^aaa │a| - bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│a| - bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb │a| - {1:~ }│b| - {1:~ }│b| - {1:~ }│b| - {1:~ }│b| - {1:~ }│{1:@}| - {2:[No Name] [+] }{3:<}| - | - ]]) + screen:expect((([[ + ^aaa │a| + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│a| + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│a| + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb │b| + {1:~ }│b| + {1:~ }│b| + {1:~ }│b| + {1:~ }│{1:@}| + {2:[No Name] [+] }{3:<}| + | + ]]):gsub('@', fillchar))) + command('set display=truncate') screen:expect_unchanged() + + command('close') + command('3split') + screen:expect((([[ + ^aaa | + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| + {1:@@@ }| + {2:[No Name] [+] }| + aaa | + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | + {3:[No Name] [+] }| + | + ]]):gsub('@', fillchar))) + + command('close') + command('2vsplit') + screen:expect((([[ + ^aa│aaa | + a │bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| + bb│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| + bb│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | + bb│{1:~ }| + bb│{1:~ }| + bb│{1:~ }| + {1:@@}│{1:~ }| + {2:< }{3:[No Name] [+] }| + | + ]]):gsub('@', fillchar))) + end + + -- oldtest: Test_display_lastline() + it('display "lastline" works correctly', function() + run_test_display_lastline() + end) + it('display "lastline" works correctly with multibyte fillchar', function() + run_test_display_lastline(true) end) end) diff --git a/test/functional/legacy/listlbr_spec.lua b/test/functional/legacy/listlbr_spec.lua index f70d55f4a3..d4f11a61c2 100644 --- a/test/functional/legacy/listlbr_spec.lua +++ b/test/functional/legacy/listlbr_spec.lua @@ -1,11 +1,12 @@ -- Test for linebreak and list option (non-utf8) local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') local feed, insert, source = helpers.feed, helpers.insert, helpers.source local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect describe('listlbr', function() - setup(clear) + before_each(clear) -- luacheck: ignore 621 (Indentation) -- luacheck: ignore 611 (Line contains only whitespaces) @@ -195,4 +196,97 @@ describe('listlbr', function() aa>-----a-$ ~ ]]) end) + + -- oldtest: Test_linebreak_reset_restore() + it('cursor position is drawn correctly after operator', function() + local screen = Screen.new(60, 6) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {background = Screen.colors.LightGrey}, -- Visual + [2] = {background = Screen.colors.Red, foreground = Screen.colors.White}, -- ErrorMsg + }) + screen:attach() + + -- f_wincol() calls validate_cursor() + source([[ + set linebreak showcmd noshowmode formatexpr=wincol()-wincol() + call setline(1, repeat('a', &columns - 10) .. ' bbbbbbbbbb c') + ]]) + + feed('$v$') + screen:expect([[ + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | + bbbbbbbbbb {1:c}^ | + {0:~ }| + {0:~ }| + {0:~ }| + 2 | + ]]) + feed('zo') + screen:expect([[ + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | + bbbbbbbbbb ^c | + {0:~ }| + {0:~ }| + {0:~ }| + {2:E490: No fold found} | + ]]) + + feed('$v$') + screen:expect([[ + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | + bbbbbbbbbb {1:c}^ | + {0:~ }| + {0:~ }| + {0:~ }| + {2:E490: No fold found} 2 | + ]]) + feed('gq') + screen:expect([[ + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | + bbbbbbbbbb ^c | + {0:~ }| + {0:~ }| + {0:~ }| + {2:E490: No fold found} | + ]]) + + feed('$<C-V>$') + screen:expect([[ + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | + bbbbbbbbbb {1:c}^ | + {0:~ }| + {0:~ }| + {0:~ }| + {2:E490: No fold found} 1x2 | + ]]) + feed('I') + screen:expect([[ + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | + bbbbbbbbbb ^c | + {0:~ }| + {0:~ }| + {0:~ }| + {2:E490: No fold found} | + ]]) + + feed('<Esc>$v$') + screen:expect([[ + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | + bbbbbbbbbb {1:c}^ | + {0:~ }| + {0:~ }| + {0:~ }| + {2:E490: No fold found} 2 | + ]]) + feed('s') + screen:expect([[ + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | + bbbbbbbbbb ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {2:E490: No fold found} | + ]]) + end) end) diff --git a/test/functional/legacy/match_spec.lua b/test/functional/legacy/match_spec.lua new file mode 100644 index 0000000000..271f844f9d --- /dev/null +++ b/test/functional/legacy/match_spec.lua @@ -0,0 +1,38 @@ +local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') +local clear = helpers.clear +local exec = helpers.exec + +before_each(clear) + +describe('matchaddpos()', function() + -- oldtest: Test_matchaddpos_dump() + it('can add more than 8 match positions vim-patch:9.0.0620', function() + local screen = Screen.new(60, 14) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {background = Screen.colors.Yellow}, -- Search + }) + screen:attach() + exec([[ + call setline(1, ['1234567890123']->repeat(14)) + call matchaddpos('Search', range(1, 12)->map({i, v -> [v, v]})) + ]]) + screen:expect([[ + {1:^1}234567890123 | + 1{1:2}34567890123 | + 12{1:3}4567890123 | + 123{1:4}567890123 | + 1234{1:5}67890123 | + 12345{1:6}7890123 | + 123456{1:7}890123 | + 1234567{1:8}90123 | + 12345678{1:9}0123 | + 123456789{1:0}123 | + 1234567890{1:1}23 | + 12345678901{1:2}3 | + 1234567890123 | + | + ]]) + end) +end) diff --git a/test/functional/legacy/messages_spec.lua b/test/functional/legacy/messages_spec.lua index 159cf7a551..71a53c8381 100644 --- a/test/functional/legacy/messages_spec.lua +++ b/test/functional/legacy/messages_spec.lua @@ -4,27 +4,65 @@ local clear = helpers.clear local command = helpers.command local exec = helpers.exec local feed = helpers.feed +local meths = helpers.meths +local nvim_dir = helpers.nvim_dir before_each(clear) describe('messages', function() local screen + -- oldtest: Test_warning_scroll() + it('a warning causes scrolling if and only if it has a stacktrace', function() + screen = Screen.new(75, 6) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {bold = true, foreground = Screen.colors.SeaGreen}, -- MoreMsg + [2] = {bold = true, reverse = true}, -- MsgSeparator + [3] = {foreground = Screen.colors.Red}, -- WarningMsg + }) + screen:attach() + + -- When the warning comes from a script, messages are scrolled so that the + -- stacktrace is visible. + -- It is a bit hard to assert the screen when sourcing a script, so skip this part. + + -- When the warning does not come from a script, messages are not scrolled. + command('enew') + command('set readonly') + feed('u') + screen:expect({grid = [[ + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {3:W10: Warning: Changing a readonly file}^ | + ]], timeout = 500}) + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + Already at oldest change | + ]]) + end) + describe('more prompt', function() before_each(function() + command('set more') + end) + + -- oldtest: Test_message_more() + it('works', function() screen = Screen.new(75, 6) screen:set_default_attr_ids({ - [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText [1] = {bold = true, foreground = Screen.colors.SeaGreen}, -- MoreMsg [2] = {foreground = Screen.colors.Brown}, -- LineNr - [3] = {foreground = Screen.colors.Blue}, -- SpecialKey }) screen:attach() - command('set more') - end) - -- oldtest: Test_message_more() - it('works', function() command('call setline(1, range(1, 100))') feed(':%pfoo<C-H><C-H><C-H>#') @@ -313,16 +351,139 @@ describe('messages', function() ]]) end) + -- oldtest: Test_echo_verbose_system() + it('verbose message before echo command', function() + screen = Screen.new(60, 10) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {bold = true, foreground = Screen.colors.SeaGreen}, -- MoreMsg + }) + screen:attach() + + command('cd '..nvim_dir) + meths.set_option('shell', './shell-test') + meths.set_option('shellcmdflag', 'REP 20') + meths.set_option('shellxquote', '') -- win: avoid extra quotes + + -- display a page and go back, results in exactly the same view + feed([[:4 verbose echo system('foo')<CR>]]) + screen:expect([[ + Executing command: "'./shell-test' 'REP' '20' 'foo'" | + | + 0: foo | + 1: foo | + 2: foo | + 3: foo | + 4: foo | + 5: foo | + 6: foo | + {1:-- More --}^ | + ]]) + feed('<Space>') + screen:expect([[ + 7: foo | + 8: foo | + 9: foo | + 10: foo | + 11: foo | + 12: foo | + 13: foo | + 14: foo | + 15: foo | + {1:-- More --}^ | + ]]) + feed('b') + screen:expect([[ + Executing command: "'./shell-test' 'REP' '20' 'foo'" | + | + 0: foo | + 1: foo | + 2: foo | + 3: foo | + 4: foo | + 5: foo | + 6: foo | + {1:-- More --}^ | + ]]) + + -- do the same with 'cmdheight' set to 2 + feed('q') + command('set ch=2') + command('mode') -- FIXME: bottom is invalid after scrolling + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + | + ]]) + feed([[:4 verbose echo system('foo')<CR>]]) + screen:expect([[ + Executing command: "'./shell-test' 'REP' '20' 'foo'" | + | + 0: foo | + 1: foo | + 2: foo | + 3: foo | + 4: foo | + 5: foo | + 6: foo | + {1:-- More --}^ | + ]]) + feed('<Space>') + screen:expect([[ + 7: foo | + 8: foo | + 9: foo | + 10: foo | + 11: foo | + 12: foo | + 13: foo | + 14: foo | + 15: foo | + {1:-- More --}^ | + ]]) + feed('b') + screen:expect([[ + Executing command: "'./shell-test' 'REP' '20' 'foo'" | + | + 0: foo | + 1: foo | + 2: foo | + 3: foo | + 4: foo | + 5: foo | + 6: foo | + {1:-- More --}^ | + ]]) + end) + -- oldtest: Test_quit_long_message() it('with control characters can be quit vim-patch:8.2.1844', function() - screen:try_resize(40, 6) + screen = Screen.new(40, 10) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {bold = true, foreground = Screen.colors.SeaGreen}, -- MoreMsg + [2] = {foreground = Screen.colors.Blue}, -- SpecialKey + }) + screen:attach() + feed([[:echom range(9999)->join("\x01")<CR>]]) screen:expect([[ - 0{3:^A}1{3:^A}2{3:^A}3{3:^A}4{3:^A}5{3:^A}6{3:^A}7{3:^A}8{3:^A}9{3:^A}10{3:^A}11{3:^A}12| - {3:^A}13{3:^A}14{3:^A}15{3:^A}16{3:^A}17{3:^A}18{3:^A}19{3:^A}20{3:^A}21{3:^A}22| - {3:^A}23{3:^A}24{3:^A}25{3:^A}26{3:^A}27{3:^A}28{3:^A}29{3:^A}30{3:^A}31{3:^A}32| - {3:^A}33{3:^A}34{3:^A}35{3:^A}36{3:^A}37{3:^A}38{3:^A}39{3:^A}40{3:^A}41{3:^A}42| - {3:^A}43{3:^A}44{3:^A}45{3:^A}46{3:^A}47{3:^A}48{3:^A}49{3:^A}50{3:^A}51{3:^A}52| + 0{2:^A}1{2:^A}2{2:^A}3{2:^A}4{2:^A}5{2:^A}6{2:^A}7{2:^A}8{2:^A}9{2:^A}10{2:^A}11{2:^A}12| + {2:^A}13{2:^A}14{2:^A}15{2:^A}16{2:^A}17{2:^A}18{2:^A}19{2:^A}20{2:^A}21{2:^A}22| + {2:^A}23{2:^A}24{2:^A}25{2:^A}26{2:^A}27{2:^A}28{2:^A}29{2:^A}30{2:^A}31{2:^A}32| + {2:^A}33{2:^A}34{2:^A}35{2:^A}36{2:^A}37{2:^A}38{2:^A}39{2:^A}40{2:^A}41{2:^A}42| + {2:^A}43{2:^A}44{2:^A}45{2:^A}46{2:^A}47{2:^A}48{2:^A}49{2:^A}50{2:^A}51{2:^A}52| + {2:^A}53{2:^A}54{2:^A}55{2:^A}56{2:^A}57{2:^A}58{2:^A}59{2:^A}60{2:^A}61{2:^A}62| + {2:^A}63{2:^A}64{2:^A}65{2:^A}66{2:^A}67{2:^A}68{2:^A}69{2:^A}70{2:^A}71{2:^A}72| + {2:^A}73{2:^A}74{2:^A}75{2:^A}76{2:^A}77{2:^A}78{2:^A}79{2:^A}80{2:^A}81{2:^A}82| + {2:^A}83{2:^A}84{2:^A}85{2:^A}86{2:^A}87{2:^A}88{2:^A}89{2:^A}90{2:^A}91{2:^A}92| {1:-- More --}^ | ]]) feed('q') @@ -332,6 +493,10 @@ describe('messages', function() {0:~ }| {0:~ }| {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| | ]]) end) diff --git a/test/functional/legacy/search_spec.lua b/test/functional/legacy/search_spec.lua index 67991f5d48..5a94fca794 100644 --- a/test/functional/legacy/search_spec.lua +++ b/test/functional/legacy/search_spec.lua @@ -644,7 +644,35 @@ end) describe('Search highlight', function() before_each(clear) - it('Search highlight is combined with Visual highlight vim-patch:8.2.2797', function() + + -- oldtest: Test_hlsearch_dump() + it('beyond line end vim-patch:8.2.2542', function() + local screen = Screen.new(50, 6) + screen:set_default_attr_ids({ + [1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [2] = {background = Screen.colors.Yellow}, -- Search + [3] = {background = Screen.colors.Grey90}, -- CursorLine + }) + screen:attach() + exec([[ + set hlsearch noincsearch cursorline + call setline(1, ["xxx", "xxx", "xxx"]) + /.* + 2 + ]]) + feed([[/\_.*<CR>]]) + screen:expect([[ + {2:xxx } | + {2:xxx } | + {2:^xxx }{3: }| + {1:~ }| + {1:~ }| + /\_.* | + ]]) + end) + + -- oldtest: Test_hlsearch_and_visual() + it('is combined with Visual highlight vim-patch:8.2.2797', function() local screen = Screen.new(40, 6) screen:set_default_attr_ids({ [1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText diff --git a/test/functional/legacy/080_substitute_spec.lua b/test/functional/legacy/substitute_spec.lua index faeb61e3af..f3ce343680 100644 --- a/test/functional/legacy/080_substitute_spec.lua +++ b/test/functional/legacy/substitute_spec.lua @@ -3,11 +3,13 @@ -- Test for *:s%* on :substitute. local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') local feed, insert = helpers.feed, helpers.insert +local exec = helpers.exec local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect local eq, eval = helpers.eq, helpers.eval -describe('substitue()', function() +describe('substitute()', function() before_each(clear) -- The original test contained several TEST_X lines to delimit different @@ -132,7 +134,7 @@ describe('substitue()', function() end) end) -describe(':substitue', function() +describe(':substitute', function() before_each(clear) it('with \\ze and \\zs and confirmation dialog (TEST_8)', function() @@ -159,4 +161,29 @@ describe(':substitue', function() feed('yyq') -- For the dialog of the previous :s command. expect('XXx') end) + + it('first char is highlighted with confirmation dialog and empty match', function() + local screen = Screen.new(60, 8) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {reverse = true}, -- IncSearch + [2] = {bold = true, foreground = Screen.colors.SeaGreen}, -- MoreMsg + }) + screen:attach() + exec([[ + set nohlsearch noincsearch + call setline(1, ['one', 'two', 'three']) + ]]) + feed(':%s/^/ /c<CR>') + screen:expect([[ + {1:o}ne | + two | + three | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {2:replace with (y/n/a/q/l/^E/^Y)?}^ | + ]]) + end) end) diff --git a/test/functional/legacy/window_cmd_spec.lua b/test/functional/legacy/window_cmd_spec.lua new file mode 100644 index 0000000000..8b89c55f5b --- /dev/null +++ b/test/functional/legacy/window_cmd_spec.lua @@ -0,0 +1,196 @@ +local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') +local clear = helpers.clear +local exec = helpers.exec +local exec_lua = helpers.exec_lua +local feed = helpers.feed + +describe('splitkeep', function() + local screen = Screen.new() + before_each(function() + clear('--cmd', 'set splitkeep=screen') + screen:attach() + end) + + -- oldtest: Test_splitkeep_callback() + it('does not scroll when split in callback', function() + exec([[ + call setline(1, range(&lines)) + function C1(a, b, c) + split | wincmd p + endfunction + function C2(a, b, c) + close | split + endfunction + ]]) + exec_lua([[ + vim.api.nvim_set_keymap("n", "j", "", { callback = function() + vim.cmd("call jobstart([&sh, &shcf, 'true'], { 'on_exit': 'C1' })") + end + })]]) + exec_lua([[ + vim.api.nvim_set_keymap("n", "t", "", { callback = function() + vim.api.nvim_set_current_win( + vim.api.nvim_open_win(vim.api.nvim_create_buf(false, {}), false, { + width = 10, + relative = "cursor", + height = 4, + row = 0, + col = 0, + })) + vim.cmd("call termopen([&sh, &shcf, 'true'], { 'on_exit': 'C2' })") + end + })]]) + feed('j') + screen:expect([[ + 0 | + 1 | + 2 | + 3 | + 4 | + 5 | + [No Name] [+] | + ^7 | + 8 | + 9 | + 10 | + 11 | + [No Name] [+] | + | + ]]) + feed(':quit<CR>Ht') + screen:expect([[ + ^0 | + 1 | + 2 | + 3 | + 4 | + 5 | + [No Name] [+] | + 7 | + 8 | + 9 | + 10 | + 11 | + [No Name] [+] | + :quit | + ]]) + feed(':set sb<CR>:quit<CR>Gj') + screen:expect([[ + 1 | + 2 | + 3 | + 4 | + ^5 | + [No Name] [+] | + 7 | + 8 | + 9 | + 10 | + 11 | + 12 | + [No Name] [+] | + :quit | + ]]) + feed(':quit<CR>Gt') + screen:expect([[ + 1 | + 2 | + 3 | + 4 | + 5 | + [No Name] [+] | + 7 | + 8 | + 9 | + 10 | + 11 | + ^12 | + [No Name] [+] | + :quit | + ]]) + end) + + -- oldtest: Test_splitkeep_fold() + it('does not scroll when window has closed folds', function() + exec([[ + set splitkeep=screen + set foldmethod=marker + set number + let line = 1 + for n in range(1, &lines) + call setline(line, ['int FuncName() {/*{{{*/', 1, 2, 3, 4, 5, '}/*}}}*/', + \ 'after fold']) + let line += 8 + endfor + ]]) + feed('L:wincmd s<CR>') + screen:expect([[ + 1 +-- 7 lines: int FuncName() {···················| + 8 after fold | + 9 +-- 7 lines: int FuncName() {···················| + 16 after fold | + 17 +-- 7 lines: int FuncName() {···················| + 24 ^after fold | + [No Name] [+] | + 32 after fold | + 33 +-- 7 lines: int FuncName() {···················| + 40 after fold | + 41 +-- 7 lines: int FuncName() {···················| + 48 after fold | + [No Name] [+] | + :wincmd s | + ]]) + feed(':quit<CR>') + screen:expect([[ + 1 +-- 7 lines: int FuncName() {···················| + 8 after fold | + 9 +-- 7 lines: int FuncName() {···················| + 16 after fold | + 17 +-- 7 lines: int FuncName() {···················| + 24 after fold | + 25 +-- 7 lines: int FuncName() {···················| + 32 after fold | + 33 +-- 7 lines: int FuncName() {···················| + 40 after fold | + 41 +-- 7 lines: int FuncName() {···················| + 48 after fold | + 49 ^+-- 7 lines: int FuncName() {···················| + :quit | + ]]) + feed('H:below split<CR>') + screen:expect([[ + 1 +-- 7 lines: int FuncName() {···················| + 8 after fold | + 9 +-- 7 lines: int FuncName() {···················| + 16 after fold | + 17 +-- 7 lines: int FuncName() {···················| + [No Name] [+] | + 25 ^+-- 7 lines: int FuncName() {···················| + 32 after fold | + 33 +-- 7 lines: int FuncName() {···················| + 40 after fold | + 41 +-- 7 lines: int FuncName() {···················| + 48 after fold | + [No Name] [+] | + :below split | + ]]) + feed(':wincmd k<CR>:quit<CR>') + screen:expect([[ + 1 +-- 7 lines: int FuncName() {···················| + 8 after fold | + 9 +-- 7 lines: int FuncName() {···················| + 16 after fold | + 17 +-- 7 lines: int FuncName() {···················| + 24 after fold | + 25 ^+-- 7 lines: int FuncName() {···················| + 32 after fold | + 33 +-- 7 lines: int FuncName() {···················| + 40 after fold | + 41 +-- 7 lines: int FuncName() {···················| + 48 after fold | + 49 +-- 7 lines: int FuncName() {···················| + :quit | + ]]) + end) +end) |