diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/legacy/arglist_spec.lua | 45 | ||||
-rw-r--r-- | test/functional/legacy/cpoptions_spec.lua | 34 | ||||
-rw-r--r-- | test/functional/legacy/ex_mode_spec.lua | 83 | ||||
-rw-r--r-- | test/functional/legacy/excmd_spec.lua | 156 | ||||
-rw-r--r-- | test/functional/legacy/filechanged_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/ui/highlight_spec.lua | 34 | ||||
-rw-r--r-- | test/functional/ui/messages_spec.lua | 47 | ||||
-rw-r--r-- | test/functional/ui/searchhl_spec.lua | 219 | ||||
-rw-r--r-- | test/functional/vimscript/input_spec.lua | 14 |
9 files changed, 511 insertions, 123 deletions
diff --git a/test/functional/legacy/arglist_spec.lua b/test/functional/legacy/arglist_spec.lua index fbb67f9c03..8379e426e0 100644 --- a/test/functional/legacy/arglist_spec.lua +++ b/test/functional/legacy/arglist_spec.lua @@ -1,8 +1,11 @@ -- Test argument list commands 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 feed = helpers.feed +local pcall_err = helpers.pcall_err describe('argument list commands', function() before_each(clear) @@ -206,7 +209,6 @@ describe('argument list commands', function() 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')") @@ -234,4 +236,45 @@ describe('argument list commands', function() 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') + eq('Vim(quit):E173: 2 more files to edit', pcall_err(command, 'quit')) + end) + + it(':confirm quit with unedited files in arglist', function() + local screen = Screen.new(60, 6) + screen:attach() + command('set nomore') + command('args a b c') + feed(':confirm quit\n') + screen:expect([[ + | + ~ | + | + :confirm quit | + 2 more files to edit. Quit anyway? | + [Y]es, (N)o: ^ | + ]]) + feed('N') + screen:expect([[ + ^ | + ~ | + ~ | + ~ | + ~ | + | + ]]) + feed(':confirm quit\n') + screen:expect([[ + | + ~ | + | + :confirm quit | + 2 more files to edit. Quit anyway? | + [Y]es, (N)o: ^ | + ]]) + feed('Y') + end) end) diff --git a/test/functional/legacy/cpoptions_spec.lua b/test/functional/legacy/cpoptions_spec.lua new file mode 100644 index 0000000000..d2f382ec12 --- /dev/null +++ b/test/functional/legacy/cpoptions_spec.lua @@ -0,0 +1,34 @@ +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 + +before_each(clear) + +describe('cpoptions', function() + it('$', function() + local screen = Screen.new(30, 6) + screen:attach() + command('set cpo+=$') + command([[call setline(1, 'one two three')]]) + feed('c2w') + screen:expect([[ + ^one tw$ three | + ~ | + ~ | + ~ | + ~ | + -- INSERT -- | + ]]) + feed('vim<Esc>') + screen:expect([[ + vi^m three | + ~ | + ~ | + ~ | + ~ | + | + ]]) + end) +end) diff --git a/test/functional/legacy/ex_mode_spec.lua b/test/functional/legacy/ex_mode_spec.lua index 244b6bf00f..98f113bbd0 100644 --- a/test/functional/legacy/ex_mode_spec.lua +++ b/test/functional/legacy/ex_mode_spec.lua @@ -1,4 +1,5 @@ local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') local clear = helpers.clear local command = helpers.command local eq = helpers.eq @@ -39,4 +40,86 @@ describe('Ex mode', function() test_ex_edit('\tm<C-T>n', '\tm<C-T>n') command('set wildchar&') end) + + it('substitute confirmation prompt', function() + command('set noincsearch nohlsearch inccommand=') + local screen = Screen.new(60, 6) + screen:set_default_attr_ids({ + [0] = {bold = true, reverse = true}, -- MsgSeparator + [1] = {foreground = Screen.colors.Brown}, -- LineNr + [2] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + }) + screen:attach() + command([[call setline(1, ['foo foo', 'foo foo', 'foo foo'])]]) + command([[set number]]) + feed('gQ') + screen:expect([[ + {1: 1 }foo foo | + {1: 2 }foo foo | + {1: 3 }foo foo | + {0: }| + Entering Ex mode. Type "visual" to go to Normal mode. | + :^ | + ]]) + + feed('%s/foo/bar/gc<CR>') + screen:expect([[ + {1: 1 }foo foo | + {0: }| + Entering Ex mode. Type "visual" to go to Normal mode. | + :%s/foo/bar/gc | + {1: 1 }foo foo | + ^^^^ | + ]]) + feed('N<CR>') + screen:expect([[ + Entering Ex mode. Type "visual" to go to Normal mode. | + :%s/foo/bar/gc | + {1: 1 }foo foo | + ^^^N | + {1: 1 }foo foo | + ^^^^ | + ]]) + feed('n<CR>') + screen:expect([[ + {1: 1 }foo foo | + ^^^N | + {1: 1 }foo foo | + ^^^n | + {1: 1 }foo foo | + ^^^^ | + ]]) + feed('y<CR>') + + feed('q<CR>') + screen:expect([[ + {1: 1 }foo foo | + ^^^y | + {1: 2 }foo foo | + ^^^q | + {1: 2 }foo foo | + :^ | + ]]) + + -- Pressing enter in ex mode should print the current line + feed('<CR>') + screen:expect([[ + ^^^y | + {1: 2 }foo foo | + ^^^q | + {1: 2 }foo foo | + {1: 3 }foo foo | + :^ | + ]]) + + feed(':vi<CR>') + screen:expect([[ + {1: 1 }foo bar | + {1: 2 }foo foo | + {1: 3 }^foo foo | + {2:~ }| + {2:~ }| + | + ]]) + end) end) diff --git a/test/functional/legacy/excmd_spec.lua b/test/functional/legacy/excmd_spec.lua index 174f7d292e..6b3b265579 100644 --- a/test/functional/legacy/excmd_spec.lua +++ b/test/functional/legacy/excmd_spec.lua @@ -1,9 +1,15 @@ local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') local clear = helpers.clear +local command = helpers.command local exec_lua = helpers.exec_lua +local feed = helpers.feed local meths = helpers.meths +local poke_eventloop = helpers.poke_eventloop +local read_file = helpers.read_file local source = helpers.source local eq = helpers.eq +local write_file = helpers.write_file local function sizeoflong() if not exec_lua('return pcall(require, "ffi")') then @@ -30,3 +36,153 @@ describe('Ex command', function() ]] end) end) + +it(':confirm command dialog', function() + local screen + + local function start_new() + clear() + screen = Screen.new(60, 20) + screen:attach() + end + + write_file('foo', 'foo1\n') + write_file('bar', 'bar1\n') + + -- Test for saving all the modified buffers + start_new() + command("set nomore") + command("new foo") + command("call setline(1, 'foo2')") + command("new bar") + command("call setline(1, 'bar2')") + command("wincmd b") + feed(':confirm qall\n') + screen:expect([[ + bar2 | + ~ | + ~ | + ~ | + ~ | + ~ | + bar [+] | + foo2 | + ~ | + ~ | + ~ | + ~ | + foo [+] | + | + ~ | + ~ | + | + :confirm qall | + Save changes to "bar"? | + [Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: ^ | + ]]) + feed('A') + poke_eventloop() + + eq('foo2\n', read_file('foo')) + eq('bar2\n', read_file('bar')) + + -- Test for discarding all the changes to modified buffers + start_new() + command("set nomore") + command("new foo") + command("call setline(1, 'foo3')") + command("new bar") + command("call setline(1, 'bar3')") + command("wincmd b") + feed(':confirm qall\n') + screen:expect([[ + bar3 | + ~ | + ~ | + ~ | + ~ | + ~ | + bar [+] | + foo3 | + ~ | + ~ | + ~ | + ~ | + foo [+] | + | + ~ | + ~ | + | + :confirm qall | + Save changes to "bar"? | + [Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: ^ | + ]]) + feed('D') + poke_eventloop() + + eq('foo2\n', read_file('foo')) + eq('bar2\n', read_file('bar')) + + -- Test for saving and discarding changes to some buffers + start_new() + command("set nomore") + command("new foo") + command("call setline(1, 'foo4')") + command("new bar") + command("call setline(1, 'bar4')") + command("wincmd b") + feed(':confirm qall\n') + screen:expect([[ + bar4 | + ~ | + ~ | + ~ | + ~ | + ~ | + bar [+] | + foo4 | + ~ | + ~ | + ~ | + ~ | + foo [+] | + | + ~ | + ~ | + | + :confirm qall | + Save changes to "bar"? | + [Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: ^ | + ]]) + feed('N') + screen:expect([[ + bar4 | + ~ | + ~ | + ~ | + ~ | + ~ | + bar [+] | + foo4 | + ~ | + ~ | + ~ | + ~ | + foo [+] | + | + | + :confirm qall | + Save changes to "bar"? | + | + Save changes to "foo"? | + [Y]es, (N)o, (C)ancel: ^ | + ]]) + feed('Y') + poke_eventloop() + + eq('foo4\n', read_file('foo')) + eq('bar2\n', read_file('bar')) + + os.remove('foo') + os.remove('bar') +end) diff --git a/test/functional/legacy/filechanged_spec.lua b/test/functional/legacy/filechanged_spec.lua index 6eb853d630..ecb861098c 100644 --- a/test/functional/legacy/filechanged_spec.lua +++ b/test/functional/legacy/filechanged_spec.lua @@ -62,7 +62,7 @@ describe('file changed dialog', function() sleep 2 silent !touch Xchanged_d let v:warningmsg = '' - checktime + checktime Xchanged_d call assert_equal('', v:warningmsg) call assert_equal(1, line('$')) call assert_equal('new line', getline(1)) diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 22589fb107..e065a727f3 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -1848,8 +1848,7 @@ describe("'winhighlight' highlight", function() ]], unchanged=true} end) - - it('works local to the buffer', function() + it('works local to the window', function() insert("aa") command("split") command("setlocal winhl=Normal:Background1") @@ -2240,4 +2239,35 @@ describe("'winhighlight' highlight", function() | ]]} end) + + it('can override StatusLine and StatusLineNC', function() + command('set winhighlight=StatusLine:Background1,StatusLineNC:Background2') + command('split') + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {1:[No Name] }| + | + {0:~ }| + {5:[No Name] }| + | + ]]) + end) + + it('can override WinBar and WinBarNC #19345', function() + command('setlocal winbar=foobar') + command('set winhighlight=WinBar:Background1,WinBarNC:Background2') + command('split') + screen:expect([[ + {1:foobar }| + ^ | + {0:~ }| + {3:[No Name] }| + {5:foobar }| + | + {4:[No Name] }| + | + ]]) + end) end) diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index e9c0e1b2a1..00f126a1f2 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1196,6 +1196,53 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim {4:Press ENTER or type command to continue}^ | ]]} end) + + it('prints lines in Ex mode correctly with a burst of carriage returns #19341', function() + command('set number') + meths.buf_set_lines(0, 0, 0, true, {'aaa', 'bbb', 'ccc'}) + command('set display-=msgsep') + feed('gggQ<CR><CR>1<CR><CR>vi') + screen:expect([[ + Entering Ex mode. Type "visual" to go to Normal mode. | + {11: 2 }bbb | + {11: 3 }ccc | + :1 | + {11: 1 }aaa | + {11: 2 }bbb | + :vi^ | + ]]) + feed('<CR>') + screen:expect([[ + {11: 1 }aaa | + {11: 2 }^bbb | + {11: 3 }ccc | + {11: 4 } | + {1:~ }| + {1:~ }| + | + ]]) + command('set display+=msgsep') + feed('gggQ<CR><CR>1<CR><CR>vi') + screen:expect([[ + Entering Ex mode. Type "visual" to go to Normal mode. | + {11: 2 }bbb | + {11: 3 }ccc | + :1 | + {11: 1 }aaa | + {11: 2 }bbb | + :vi^ | + ]]) + feed('<CR>') + screen:expect([[ + {11: 1 }aaa | + {11: 2 }^bbb | + {11: 3 }ccc | + {11: 4 } | + {1:~ }| + {1:~ }| + | + ]]) + end) end) describe('ui/ext_messages', function() diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua index c3b9af5e72..c5c88323a2 100644 --- a/test/functional/ui/searchhl_spec.lua +++ b/test/functional/ui/searchhl_spec.lua @@ -5,6 +5,7 @@ local command = helpers.command local feed_command = helpers.feed_command local eq = helpers.eq local eval = helpers.eval +local funcs = helpers.funcs local testprg = helpers.testprg describe('search highlighting', function() @@ -321,100 +322,101 @@ describe('search highlighting', function() end) it('works with incsearch', function() - feed_command('set hlsearch') - feed_command('set incsearch') + command('set hlsearch') + command('set incsearch') + command('set laststatus=0') insert([[ the first line - in a little file - ]]) + in a little file]]) + command('vsplit') feed("gg/li") screen:expect([[ - the first {3:li}ne | - in a {2:li}ttle file | - | - {1:~ }| - {1:~ }| - {1:~ }| + the first {3:li}ne │the first {2:li}ne | + in a {2:li}ttle file │in a {2:li}ttle file | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| /li^ | ]]) -- check that consecutive matches are caught by C-g/C-t feed("<C-g>") screen:expect([[ - the first {2:li}ne | - in a {3:li}ttle file | - | - {1:~ }| - {1:~ }| - {1:~ }| + the first {2:li}ne │the first {2:li}ne | + in a {3:li}ttle file │in a {2:li}ttle file | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| /li^ | ]]) feed("<C-t>") screen:expect([[ - the first {3:li}ne | - in a {2:li}ttle file | - | - {1:~ }| - {1:~ }| - {1:~ }| + the first {3:li}ne │the first {2:li}ne | + in a {2:li}ttle file │in a {2:li}ttle file | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| /li^ | ]]) feed("t") screen:expect([[ - the first line | - in a {3:lit}tle file | - | - {1:~ }| - {1:~ }| - {1:~ }| + the first line │the first line | + in a {3:lit}tle file │in a {2:lit}tle file | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| /lit^ | ]]) feed("<cr>") screen:expect([[ - the first line | - in a {2:^lit}tle file | - | - {1:~ }| - {1:~ }| - {1:~ }| + the first line │the first line | + in a {2:^lit}tle file │in a {2:lit}tle file | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| /lit | ]]) feed("/fir") screen:expect([[ - the {3:fir}st line | - in a little file | - | - {1:~ }| - {1:~ }| - {1:~ }| + the {3:fir}st line │the {2:fir}st line | + in a little file │in a little file | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| /fir^ | ]]) -- incsearch have priority over hlsearch feed("<esc>/ttle") screen:expect([[ - the first line | - in a li{3:ttle} file | - | - {1:~ }| - {1:~ }| - {1:~ }| + the first line │the first line | + in a li{3:ttle} file │in a li{2:ttle} file | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| /ttle^ | ]]) -- cancelling search resets to the old search term feed('<esc>') screen:expect([[ - the first line | - in a {2:^lit}tle file | - | - {1:~ }| - {1:~ }| - {1:~ }| + the first line │the first line | + in a {2:^lit}tle file │in a {2:lit}tle file | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| | ]]) eq('lit', eval('@/')) @@ -422,91 +424,78 @@ describe('search highlighting', function() -- cancelling inc search restores the hl state feed(':noh<cr>') screen:expect([[ - the first line | - in a ^little file | - | - {1:~ }| - {1:~ }| - {1:~ }| + the first line │the first line | + in a ^little file │in a little file | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| :noh | ]]) feed('/first') screen:expect([[ - the {3:first} line | - in a little file | - | - {1:~ }| - {1:~ }| - {1:~ }| + the {3:first} line │the {2:first} line | + in a little file │in a little file | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| /first^ | ]]) feed('<esc>') screen:expect([[ - the first line | - in a ^little file | - | - {1:~ }| - {1:~ }| - {1:~ }| + the first line │the first line | + in a ^little file │in a little file | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| | ]]) -- test that pressing C-g in an empty command line does not move the cursor - feed('/<C-g>') - screen:expect([[ - the first line | - in a little file | - | - {1:~ }| - {1:~ }| - {1:~ }| - /^ | - ]]) - - -- same, for C-t - feed('<ESC>') - screen:expect([[ - the first line | - in a ^little file | - | - {1:~ }| - {1:~ }| - {1:~ }| - | - ]]) - feed('/<C-t>') - screen:expect([[ - the first line | - in a little file | - | - {1:~ }| - {1:~ }| - {1:~ }| - /^ | - ]]) + feed('gg0') + command([[let @/ = 'i']]) + -- moves to next match of previous search pattern, just like /<cr> + feed('/<c-g><cr>') + eq({0, 1, 6, 0}, funcs.getpos('.')) + -- moves to next match of previous search pattern, just like /<cr> + feed('/<cr>') + eq({0, 1, 12, 0}, funcs.getpos('.')) + -- moves to next match of previous search pattern, just like /<cr> + feed('/<c-t><cr>') + eq({0, 2, 1, 0}, funcs.getpos('.')) -- 8.0.1304, test that C-g and C-t works with incsearch and empty pattern feed('<esc>/fi<CR>') + screen:expect([[ + the {2:fi}rst line │the {2:fi}rst line | + in a little {2:^fi}le │in a little {2:fi}le | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + /fi | + ]]) feed('//') screen:expect([[ - the {3:fi}rst line | - in a little {2:fi}le | - | - {1:~ }| - {1:~ }| - {1:~ }| + the {3:fi}rst line │the {2:fi}rst line | + in a little {2:fi}le │in a little {2:fi}le | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| //^ | ]]) - feed('<C-g>') screen:expect([[ - the {2:fi}rst line | - in a little {3:fi}le | - | - {1:~ }| - {1:~ }| - {1:~ }| + the {2:fi}rst line │the {2:fi}rst line | + in a little {3:fi}le │in a little {2:fi}le | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| //^ | ]]) end) diff --git a/test/functional/vimscript/input_spec.lua b/test/functional/vimscript/input_spec.lua index 14c02f9eb2..554d15e550 100644 --- a/test/functional/vimscript/input_spec.lua +++ b/test/functional/vimscript/input_spec.lua @@ -9,6 +9,7 @@ local source = helpers.source local command = helpers.command local exc_exec = helpers.exc_exec local nvim_async = helpers.nvim_async +local NIL = helpers.NIL local screen @@ -200,6 +201,15 @@ describe('input()', function() feed(':let var = input({"cancelreturn": "BAR"})<CR>') feed('<Esc>') eq('BAR', meths.get_var('var')) + feed(':let var = input({"cancelreturn": []})<CR>') + feed('<Esc>') + eq({}, meths.get_var('var')) + feed(':let var = input({"cancelreturn": v:false})<CR>') + feed('<Esc>') + eq(false, meths.get_var('var')) + feed(':let var = input({"cancelreturn": v:null})<CR>') + feed('<Esc>') + eq(NIL, meths.get_var('var')) end) it('supports default string', function() feed(':let var = input("", "DEF1")<CR>') @@ -220,8 +230,6 @@ describe('input()', function() eq('Vim(call):E730: using List as a String', exc_exec('call input({"prompt": []})')) eq('Vim(call):E730: using List as a String', - exc_exec('call input({"cancelreturn": []})')) - eq('Vim(call):E730: using List as a String', exc_exec('call input({"default": []})')) eq('Vim(call):E730: using List as a String', exc_exec('call input({"completion": []})')) @@ -418,8 +426,6 @@ describe('inputdialog()', function() eq('Vim(call):E730: using List as a String', exc_exec('call inputdialog({"prompt": []})')) eq('Vim(call):E730: using List as a String', - exc_exec('call inputdialog({"cancelreturn": []})')) - eq('Vim(call):E730: using List as a String', exc_exec('call inputdialog({"default": []})')) eq('Vim(call):E730: using List as a String', exc_exec('call inputdialog({"completion": []})')) |