diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/api/autocmd_spec.lua | 48 | ||||
-rw-r--r-- | test/functional/autocmd/show_spec.lua | 150 | ||||
-rw-r--r-- | test/functional/editor/completion_spec.lua | 41 | ||||
-rw-r--r-- | test/functional/editor/macro_spec.lua | 47 | ||||
-rw-r--r-- | test/functional/editor/mode_insert_spec.lua | 24 | ||||
-rw-r--r-- | test/functional/ex_cmds/normal_spec.lua | 27 | ||||
-rw-r--r-- | test/functional/legacy/cmdline_spec.lua | 68 | ||||
-rw-r--r-- | test/functional/legacy/delete_spec.lua | 55 | ||||
-rw-r--r-- | test/functional/legacy/mapping_spec.lua | 26 | ||||
-rw-r--r-- | test/functional/ui/cmdline_spec.lua | 3 | ||||
-rw-r--r-- | test/functional/ui/diff_spec.lua | 127 | ||||
-rw-r--r-- | test/functional/ui/highlight_spec.lua | 22 | ||||
-rw-r--r-- | test/functional/ui/popupmenu_spec.lua | 41 | ||||
-rw-r--r-- | test/unit/buffer_spec.lua | 42 |
14 files changed, 612 insertions, 109 deletions
diff --git a/test/functional/api/autocmd_spec.lua b/test/functional/api/autocmd_spec.lua index b4a9a4f01f..377b4fecf0 100644 --- a/test/functional/api/autocmd_spec.lua +++ b/test/functional/api/autocmd_spec.lua @@ -182,6 +182,54 @@ describe('autocmd api', function() meths.exec_autocmds("User", {pattern = "Test"}) eq({}, meths.get_autocmds({event = "User", pattern = "Test"})) end) + + it('receives an args table', function() + local res = exec_lua [[ + local group_id = vim.api.nvim_create_augroup("TestGroup", {}) + local autocmd_id = vim.api.nvim_create_autocmd("User", { + group = "TestGroup", + pattern = "Te*", + callback = function(args) + vim.g.autocmd_args = args + end, + }) + + return {group_id, autocmd_id} + ]] + + meths.exec_autocmds("User", {pattern = "Test pattern"}) + eq({ + id = res[2], + group = res[1], + event = "User", + match = "Test pattern", + file = "Test pattern", + buf = 1, + }, meths.get_var("autocmd_args")) + + -- Test without a group + res = exec_lua [[ + local autocmd_id = vim.api.nvim_create_autocmd("User", { + pattern = "*", + callback = function(args) + vim.g.autocmd_args = args + end, + }) + + return {autocmd_id} + ]] + + meths.exec_autocmds("User", {pattern = "some_pat"}) + eq({ + id = res[1], + group = nil, + event = "User", + match = "some_pat", + file = "some_pat", + buf = 1, + }, meths.get_var("autocmd_args")) + + end) end) describe('nvim_get_autocmds', function() diff --git a/test/functional/autocmd/show_spec.lua b/test/functional/autocmd/show_spec.lua index 59757a7d61..505bed834b 100644 --- a/test/functional/autocmd/show_spec.lua +++ b/test/functional/autocmd/show_spec.lua @@ -1,13 +1,19 @@ local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') local clear = helpers.clear local command = helpers.command local dedent = helpers.dedent local eq = helpers.eq local funcs = helpers.funcs +local eval = helpers.eval +local exec = helpers.exec +local feed = helpers.feed describe(":autocmd", function() - before_each(clear) + before_each(function() + clear({'-u', 'NONE'}) + end) it("should not segfault when you just do autocmd", function() command ":autocmd" @@ -30,6 +36,148 @@ describe(":autocmd", function() * :echo "Line 1" :echo "Line 2"]]), funcs.execute('autocmd BufEnter')) + end) + + it('should not show group information if interrupted', function() + local screen = Screen.new(50, 6) + screen:set_default_attr_ids({ + [1] = {bold = true, foreground = Screen.colors.Blue1}, -- NonText + [2] = {bold = true, foreground = Screen.colors.SeaGreen}, -- MoreMsg + [3] = {bold = true, foreground = Screen.colors.Magenta}, -- Title + }) + screen:attach() + exec([[ + set more + autocmd! BufEnter + augroup test_1 + autocmd BufEnter A echo 'A' + autocmd BufEnter B echo 'B' + autocmd BufEnter C echo 'C' + autocmd BufEnter D echo 'D' + autocmd BufEnter E echo 'E' + autocmd BufEnter F echo 'F' + augroup END + autocmd! BufLeave + augroup test_1 + autocmd BufLeave A echo 'A' + autocmd BufLeave B echo 'B' + autocmd BufLeave C echo 'C' + autocmd BufLeave D echo 'D' + autocmd BufLeave E echo 'E' + autocmd BufLeave F echo 'F' + augroup END + ]]) + feed(':autocmd<CR>') + screen:expect([[ + :autocmd | + {3:--- Autocommands ---} | + {3:test_1} {3:BufEnter} | + A echo 'A' | + B echo 'B' | + {2:-- More --}^ | + ]]) + feed('q') + screen:expect([[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + end) + + it('should not show group information for deleted pattern', function() + exec([[ + autocmd! BufEnter + augroup test_1 + autocmd BufEnter A echo 'A' + autocmd BufEnter B echo 'B' + autocmd BufEnter C echo 'C' + augroup END + augroup test_2 + autocmd BufEnter foo echo 'foo' + augroup END + augroup test_3 + autocmd BufEnter D echo 'D' + autocmd BufEnter E echo 'E' + autocmd BufEnter F echo 'F' + augroup END + + func Func() + autocmd! test_2 BufEnter + let g:output = execute('autocmd BufEnter') + endfunc + + autocmd User foo call Func() + doautocmd User foo + ]]) + eq(dedent([[ + + --- Autocommands --- + test_1 BufEnter + A echo 'A' + B echo 'B' + C echo 'C' + test_3 BufEnter + D echo 'D' + E echo 'E' + F echo 'F']]), eval('g:output')) + end) + + it('can filter by pattern #17973', function() + exec([[ + autocmd! BufEnter + autocmd! User + augroup test_1 + autocmd BufEnter A echo "A1" + autocmd BufEnter B echo "B1" + autocmd User A echo "A1" + autocmd User B echo "B1" + augroup END + augroup test_2 + autocmd BufEnter A echo "A2" + autocmd BufEnter B echo "B2" + autocmd User A echo "A2" + autocmd User B echo "B2" + augroup END + augroup test_3 + autocmd BufEnter A echo "A3" + autocmd BufEnter B echo "B3" + autocmd User A echo "A3" + autocmd User B echo "B3" + augroup END + ]]) + eq(dedent([[ + + --- Autocommands --- + test_1 User + A echo "A1" + test_2 User + A echo "A2" + test_3 User + A echo "A3"]]), funcs.execute('autocmd User A')) + eq(dedent([[ + + --- Autocommands --- + test_1 BufEnter + B echo "B1" + test_2 BufEnter + B echo "B2" + test_3 BufEnter + B echo "B3" + test_1 User + B echo "B1" + test_2 User + B echo "B2" + test_3 User + B echo "B3"]]), funcs.execute('autocmd * B')) + eq(dedent([[ + --- Autocommands --- + test_3 BufEnter + B echo "B3" + test_3 User + B echo "B3"]]), funcs.execute('autocmd test_3 * B')) end) end) diff --git a/test/functional/editor/completion_spec.lua b/test/functional/editor/completion_spec.lua index 1a0ee54505..e27da0947f 100644 --- a/test/functional/editor/completion_spec.lua +++ b/test/functional/editor/completion_spec.lua @@ -1194,6 +1194,47 @@ describe('completion', function() feed('<esc>') end) + it('is stopped by :stopinsert from timer #12976', function() + screen:try_resize(32,14) + command([[call setline(1, ['hello', 'hullo', 'heeee', ''])]]) + feed('Gah<c-x><c-n>') + screen:expect([[ + hello | + hullo | + heeee | + hello^ | + {2:hello }{0: }| + {1:hullo }{0: }| + {1:heeee }{0: }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {3:-- }{4:match 1 of 3} | + ]]) + command([[call timer_start(100, { -> execute('stopinsert') })]]) + helpers.sleep(200) + feed('k') -- cursor should move up in Normal mode + screen:expect([[ + hello | + hullo | + heee^e | + hello | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end) + it('does not crash if text is changed by first call to complete function #17489', function() source([[ func Complete(findstart, base) abort diff --git a/test/functional/editor/macro_spec.lua b/test/functional/editor/macro_spec.lua index c0c9256af2..d4cf6b28fd 100644 --- a/test/functional/editor/macro_spec.lua +++ b/test/functional/editor/macro_spec.lua @@ -6,11 +6,14 @@ local feed = helpers.feed local clear = helpers.clear local expect = helpers.expect local command = helpers.command +local funcs = helpers.funcs +local meths = helpers.meths local insert = helpers.insert local curbufmeths = helpers.curbufmeths +before_each(clear) + describe('macros', function() - before_each(clear) it('can be recorded and replayed', function() feed('qiahello<esc>q') expect('hello') @@ -47,9 +50,47 @@ hello]] end) end) -describe('reg_recorded()', function() - before_each(clear) +describe('immediately after a macro has finished executing,', function() + before_each(function() + command([[let @a = 'gg0']]) + end) + + describe('reg_executing() from RPC returns an empty string', function() + it('if the macro does not end with a <Nop> mapping', function() + feed('@a') + eq('', funcs.reg_executing()) + end) + + it('if the macro ends with a <Nop> mapping', function() + command('nnoremap 0 <Nop>') + feed('@a') + eq('', funcs.reg_executing()) + end) + end) + describe('characters from a mapping are not treated as a part of the macro #18015', function() + before_each(function() + command('nnoremap s qa') + end) + + it('if the macro does not end with a <Nop> mapping', function() + feed('@asq') -- "q" from "s" mapping should start recording a macro instead of being no-op + eq({mode = 'n', blocking = false}, meths.get_mode()) + expect('') + eq('', eval('@a')) + end) + + it('if the macro ends with a <Nop> mapping', function() + command('nnoremap 0 <Nop>') + feed('@asq') -- "q" from "s" mapping should start recording a macro instead of being no-op + eq({mode = 'n', blocking = false}, meths.get_mode()) + expect('') + eq('', eval('@a')) + end) + end) +end) + +describe('reg_recorded()', function() it('returns the correct value', function() feed [[qqyyq]] eq('q', eval('reg_recorded()')) diff --git a/test/functional/editor/mode_insert_spec.lua b/test/functional/editor/mode_insert_spec.lua index 528e228121..c38acbe96a 100644 --- a/test/functional/editor/mode_insert_spec.lua +++ b/test/functional/editor/mode_insert_spec.lua @@ -6,6 +6,8 @@ local expect = helpers.expect local command = helpers.command local eq = helpers.eq local eval = helpers.eval +local meths = helpers.meths +local poke_eventloop = helpers.poke_eventloop describe('insert-mode', function() before_each(function() @@ -128,4 +130,26 @@ describe('insert-mode', function() expect('<M-1><D-2><M-7><D-8>') end) end) + + describe([[With 'insertmode', Insert mode is not re-entered immediately after <C-L>]], function() + before_each(function() + command('set insertmode') + poke_eventloop() + eq({mode = 'i', blocking = false}, meths.get_mode()) + end) + + it('after calling :edit from <Cmd> mapping', function() + command('inoremap <C-B> <Cmd>edit Xfoo<CR>') + feed('<C-B><C-L>') + poke_eventloop() + eq({mode = 'n', blocking = false}, meths.get_mode()) + end) + + it('after calling :edit from RPC #16823', function() + command('edit Xfoo') + feed('<C-L>') + poke_eventloop() + eq({mode = 'n', blocking = false}, meths.get_mode()) + end) + end) end) diff --git a/test/functional/ex_cmds/normal_spec.lua b/test/functional/ex_cmds/normal_spec.lua new file mode 100644 index 0000000000..f6e7dd2b3a --- /dev/null +++ b/test/functional/ex_cmds/normal_spec.lua @@ -0,0 +1,27 @@ +local helpers = require('test.functional.helpers')(after_each) +local clear = helpers.clear +local command = helpers.command +local feed = helpers.feed +local expect = helpers.expect +local eq = helpers.eq +local eval = helpers.eval + +before_each(clear) + +describe(':normal', function() + it('can get out of Insert mode if called from Ex mode #17924', function() + feed('gQnormal! Ifoo<CR>') + expect('foo') + end) + + it('normal! does not execute command in Ex mode when running out of characters', function() + command('let g:var = 0') + command('normal! gQlet g:var = 1') + eq(0, eval('g:var')) + end) + + it('normal! gQinsert does not hang #17980', function() + command('normal! gQinsert') + expect('') + end) +end) diff --git a/test/functional/legacy/cmdline_spec.lua b/test/functional/legacy/cmdline_spec.lua index 9ebe9aeb91..d8d849271b 100644 --- a/test/functional/legacy/cmdline_spec.lua +++ b/test/functional/legacy/cmdline_spec.lua @@ -11,6 +11,15 @@ describe('cmdline', function() it('is cleared when switching tabs', function() local screen = Screen.new(30, 10) screen:attach() + screen:set_default_attr_ids { + [1] = {underline = true, background = Screen.colors.LightGrey}; + [2] = {bold = true}; + [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([[ ^0 | @@ -24,18 +33,61 @@ describe('cmdline', function() 8 | :call setline(1, range(30)) | ]]) - feed([[:tabnew<cr><C-w>-<C-w>-gtgt]]) - screen:expect([[ - + [No Name] [No Name] X| + + feed [[:tabnew<cr>]] + screen:expect{grid=[[ + {1: + [No Name] }{2: [No Name] }{3: }{1:X}| + ^ | + {4:~ }| + {4:~ }| + {4:~ }| + {4:~ }| + {4:~ }| + {4:~ }| + {4:~ }| + :tabnew | + ]]} + + feed [[<C-w>-<C-w>-]] + screen:expect{grid=[[ + {1: + [No Name] }{2: [No Name] }{3: }{1:X}| ^ | - ~ | - ~ | - ~ | - ~ | - ~ | + {4:~ }| + {4:~ }| + {4:~ }| + {4:~ }| + {4:~ }| + | + | + :tabnew | + ]]} + + feed [[gt]] + screen:expect{grid=[[ + {2: + [No Name] }{1: [No Name] }{3: }{1:X}| + ^0 | + 1 | + 2 | + 3 | + 4 | + 5 | 6 | 7 | | + ]]} + + feed [[gt]] + screen:expect([[ + {1: + [No Name] }{2: [No Name] }{3: }{1:X}| + ^ | + {4:~ }| + {4:~ }| + {4:~ }| + {4:~ }| + {4:~ }| + | + | + | ]]) end) diff --git a/test/functional/legacy/delete_spec.lua b/test/functional/legacy/delete_spec.lua index 623b6b14a5..4ba4c8d356 100644 --- a/test/functional/legacy/delete_spec.lua +++ b/test/functional/legacy/delete_spec.lua @@ -1,6 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear, source = helpers.clear, helpers.source local eq, eval, command = helpers.eq, helpers.eval, helpers.command +local exc_exec = helpers.exc_exec describe('Test for delete()', function() before_each(clear) @@ -8,6 +9,23 @@ describe('Test for delete()', function() os.remove('Xfile') end) + it('file delete', function() + command('split Xfile') + command("call setline(1, ['a', 'b'])") + command('wq') + eq(eval("['a', 'b']"), eval("readfile('Xfile')")) + eq(0, eval("delete('Xfile')")) + eq(-1, eval("delete('Xfile')")) + end) + + it('directory delete', function() + command("call mkdir('Xdir1')") + eq(1, eval("isdirectory('Xdir1')")) + eq(0, eval("delete('Xdir1', 'd')")) + eq(0, eval("isdirectory('Xdir1')")) + eq(-1, eval("delete('Xdir1', 'd')")) + end) + it('symlink delete', function() source([[ split Xfile @@ -43,39 +61,8 @@ describe('Test for delete()', function() eq(0, eval("delete('Xdir1', 'd')")) end) - it('symlink recursive delete', function() - source([[ - call mkdir('Xdir3') - call mkdir('Xdir3/subdir') - call mkdir('Xdir4') - split Xdir3/Xfile - call setline(1, ['a', 'b']) - w - w Xdir3/subdir/Xfile - w Xdir4/Xfile - close - if has('win32') - silent !mklink /j Xdir3\Xlink Xdir4 - else - silent !ln -s ../Xdir4 Xdir3/Xlink - endif - ]]) - - eq(1, eval("isdirectory('Xdir3')")) - eq(eval("['a', 'b']"), eval("readfile('Xdir3/Xfile')")) - eq(1, eval("isdirectory('Xdir3/subdir')")) - eq(eval("['a', 'b']"), eval("readfile('Xdir3/subdir/Xfile')")) - eq(1, eval("isdirectory('Xdir4')")) - eq(1, eval("isdirectory('Xdir3/Xlink')")) - eq(eval("['a', 'b']"), eval("readfile('Xdir4/Xfile')")) - - eq(0, eval("delete('Xdir3', 'rf')")) - eq(0, eval("isdirectory('Xdir3')")) - eq(-1, eval("delete('Xdir3', 'd')")) - -- symlink is deleted, not the directory it points to - eq(1, eval("isdirectory('Xdir4')")) - eq(eval("['a', 'b']"), eval("readfile('Xdir4/Xfile')")) - eq(0, eval("delete('Xdir4/Xfile')")) - eq(0, eval("delete('Xdir4', 'd')")) + it('gives correct emsgs', function() + eq('Vim(call):E474: Invalid argument', exc_exec("call delete('')")) + eq('Vim(call):E15: Invalid expression: 0', exc_exec("call delete('foo', 0)")) end) end) diff --git a/test/functional/legacy/mapping_spec.lua b/test/functional/legacy/mapping_spec.lua index 92a757ca85..aa29698589 100644 --- a/test/functional/legacy/mapping_spec.lua +++ b/test/functional/legacy/mapping_spec.lua @@ -3,6 +3,8 @@ local helpers = require('test.functional.helpers')(after_each) local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert local feed_command, expect, poke_eventloop = helpers.feed_command, helpers.expect, helpers.poke_eventloop +local command, eq, eval, meths = helpers.command, helpers.eq, helpers.eval, helpers.meths +local sleep = helpers.sleep describe('mapping', function() before_each(clear) @@ -126,4 +128,28 @@ describe('mapping', function() new line here ]]) end) + + it('<LeftDrag> mapping in Insert mode works correctly vim-patch:8.2.4692', function() + command('set mouse=a') + + command([[inoremap <LeftDrag> <LeftDrag><Cmd>let g:dragged = 1<CR>]]) + feed('i') + sleep(10) + meths.input_mouse('left', 'press', '', 0, 0, 0) + sleep(10) + meths.input_mouse('left', 'drag', '', 0, 0, 1) + sleep(10) + eq(1, eval('g:dragged')) + eq('v', eval('mode()')) + feed([[<C-\><C-N>]]) + + command([[inoremap <LeftDrag> <LeftDrag><C-\><C-N>]]) + feed('i') + sleep(10) + meths.input_mouse('left', 'press', '', 0, 0, 0) + sleep(10) + meths.input_mouse('left', 'drag', '', 0, 0, 1) + sleep(10) + eq('n', eval('mode()')) + end) end) diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index ad23402ff9..3b273fd229 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -4,6 +4,7 @@ local clear, feed = helpers.clear, helpers.feed local source = helpers.source local command = helpers.command local assert_alive = helpers.assert_alive +local uname = helpers.uname local function new_screen(opt) local screen = Screen.new(25, 5) @@ -824,7 +825,7 @@ describe('cmdline redraw', function() end) it('with <Cmd>', function() - if 'openbsd' == helpers.uname() then + if string.find(uname(), 'bsd') then pending('FIXME #10804') end command('cmap a <Cmd>call sin(0)<CR>') -- no-op diff --git a/test/functional/ui/diff_spec.lua b/test/functional/ui/diff_spec.lua index 3a25d7e813..6f67dea2be 100644 --- a/test/functional/ui/diff_spec.lua +++ b/test/functional/ui/diff_spec.lua @@ -1226,3 +1226,130 @@ it('Align the filler lines when changing text in diff mode', function() | ]]} end) + +it('diff mode works properly if file contains NUL bytes vim-patch:8.2.3925', function() + clear() + local screen = Screen.new(40, 20) + screen:set_default_attr_ids({ + [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Gray}; + [2] = {reverse = true}; + [3] = {background = Screen.colors.LightBlue}; + [4] = {background = Screen.colors.LightMagenta}; + [5] = {background = Screen.colors.Red, bold = true}; + [6] = {foreground = Screen.colors.Blue, bold = true}; + [7] = {background = Screen.colors.Red, foreground = Screen.colors.Blue, bold = true}; + [8] = {reverse = true, bold = true}; + }) + screen:attach() + exec([[ + call setline(1, ['a', 'b', "c\n", 'd', 'e', 'f', 'g']) + vnew + call setline(1, ['A', 'b', 'c', 'd', 'E', 'f', 'g']) + windo diffthis + wincmd p + norm! gg0 + redraw! + ]]) + + -- Test using internal diff + screen:expect([[ + {1: }{5:^A}{4: }{2:│}{1: }{5:a}{4: }| + {1: }b {2:│}{1: }b | + {1: }{4:c }{2:│}{1: }{4:c}{7:^@}{4: }| + {1: }d {2:│}{1: }d | + {1: }{5:E}{4: }{2:│}{1: }{5:e}{4: }| + {1: }f {2:│}{1: }f | + {1: }g {2:│}{1: }g | + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {8:[No Name] [+] }{2:[No Name] [+] }| + | + ]]) + + -- Test using internal diff and case folding + command('set diffopt+=icase') + feed('<C-L>') + screen:expect([[ + {1: }^A {2:│}{1: }a | + {1: }b {2:│}{1: }b | + {1: }{4:c }{2:│}{1: }{4:c}{7:^@}{4: }| + {1: }d {2:│}{1: }d | + {1: }E {2:│}{1: }e | + {1: }f {2:│}{1: }f | + {1: }g {2:│}{1: }g | + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {8:[No Name] [+] }{2:[No Name] [+] }| + | + ]]) + + -- Test using external diff + command('set diffopt=filler') + feed('<C-L>') + screen:expect([[ + {1: }{5:^A}{4: }{2:│}{1: }{5:a}{4: }| + {1: }b {2:│}{1: }b | + {1: }{4:c }{2:│}{1: }{4:c}{7:^@}{4: }| + {1: }d {2:│}{1: }d | + {1: }{5:E}{4: }{2:│}{1: }{5:e}{4: }| + {1: }f {2:│}{1: }f | + {1: }g {2:│}{1: }g | + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {8:[No Name] [+] }{2:[No Name] [+] }| + | + ]]) + + -- Test using external diff and case folding + command('set diffopt+=filler,icase') + feed('<C-L>') + screen:expect([[ + {1: }^A {2:│}{1: }a | + {1: }b {2:│}{1: }b | + {1: }{4:c }{2:│}{1: }{4:c}{7:^@}{4: }| + {1: }d {2:│}{1: }d | + {1: }E {2:│}{1: }e | + {1: }f {2:│}{1: }f | + {1: }g {2:│}{1: }g | + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {6:~ }{2:│}{6:~ }| + {8:[No Name] [+] }{2:[No Name] [+] }| + | + ]]) +end) diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 4b63b09a5b..8afc69a649 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -1345,6 +1345,28 @@ describe('CursorColumn highlight', function() {2:~ }| {3:-- INSERT --} | ]]) + feed('<C-O>') + screen:expect([[ + 1234567{1:8}9 | + a ^ b | + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {3:-- (insert) --} | + ]]) + feed('i') + screen:expect([[ + 1{1:2}3456789 | + a^ b | + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {3:-- INSERT --} | + ]]) end) it('is updated if cursor is moved from timer', function() diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index d521e3cd25..07c6c5b046 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -2321,47 +2321,6 @@ describe('builtin popupmenu', function() assert_alive() end) - it('is closed by :stopinsert from timer #12976', function() - screen:try_resize(32,14) - command([[call setline(1, ['hello', 'hullo', 'heeee', ''])]]) - feed('Gah<c-x><c-n>') - screen:expect([[ - hello | - hullo | - heeee | - hello^ | - {s:hello }{1: }| - {n:hullo }{1: }| - {n:heeee }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {2:-- }{5:match 1 of 3} | - ]]) - command([[call timer_start(100, { -> execute('stopinsert') })]]) - helpers.sleep(200) - feed('k') -- cursor should move up in Normal mode - screen:expect([[ - hello | - hullo | - heee^e | - hello | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - | - ]]) - end) - it('truncates double-width character correctly when there is no scrollbar', function() screen:try_resize(32,8) command('set completeopt+=menuone,noselect') diff --git a/test/unit/buffer_spec.lua b/test/unit/buffer_spec.lua index 34c88248e6..833b21b00b 100644 --- a/test/unit/buffer_spec.lua +++ b/test/unit/buffer_spec.lua @@ -17,8 +17,8 @@ describe('buffer functions', function() return buffer.buflist_new(c_file, c_file, 1, flags) end - local close_buffer = function(win, buf, action, abort_if_last) - return buffer.close_buffer(win, buf, action, abort_if_last) + local close_buffer = function(win, buf, action, abort_if_last, ignore_abort) + return buffer.close_buffer(win, buf, action, abort_if_last, ignore_abort) end local path1 = 'test_file_path' @@ -53,7 +53,7 @@ describe('buffer functions', function() itp('should view a closed and hidden buffer as valid', function() local buf = buflist_new(path1, buffer.BLN_LISTED) - close_buffer(NULL, buf, 0, 0) + close_buffer(NULL, buf, 0, 0, 0) eq(true, buffer.buf_valid(buf)) end) @@ -61,7 +61,7 @@ describe('buffer functions', function() itp('should view a closed and unloaded buffer as valid', function() local buf = buflist_new(path1, buffer.BLN_LISTED) - close_buffer(NULL, buf, buffer.DOBUF_UNLOAD, 0) + close_buffer(NULL, buf, buffer.DOBUF_UNLOAD, 0, 0) eq(true, buffer.buf_valid(buf)) end) @@ -69,7 +69,7 @@ describe('buffer functions', function() itp('should view a closed and wiped buffer as invalid', function() local buf = buflist_new(path1, buffer.BLN_LISTED) - close_buffer(NULL, buf, buffer.DOBUF_WIPE, 0) + close_buffer(NULL, buf, buffer.DOBUF_WIPE, 0, 0) eq(false, buffer.buf_valid(buf)) end) @@ -90,7 +90,7 @@ describe('buffer functions', function() eq(buf.handle, buflist_findpat(path1, ONLY_LISTED)) - close_buffer(NULL, buf, buffer.DOBUF_WIPE, 0) + close_buffer(NULL, buf, buffer.DOBUF_WIPE, 0, 0) end) itp('should prefer to match the start of a file path', function() @@ -102,9 +102,9 @@ describe('buffer functions', function() eq(buf2.handle, buflist_findpat("file", ONLY_LISTED)) eq(buf3.handle, buflist_findpat("path", ONLY_LISTED)) - close_buffer(NULL, buf1, buffer.DOBUF_WIPE, 0) - close_buffer(NULL, buf2, buffer.DOBUF_WIPE, 0) - close_buffer(NULL, buf3, buffer.DOBUF_WIPE, 0) + close_buffer(NULL, buf1, buffer.DOBUF_WIPE, 0, 0) + close_buffer(NULL, buf2, buffer.DOBUF_WIPE, 0, 0) + close_buffer(NULL, buf3, buffer.DOBUF_WIPE, 0, 0) end) itp('should prefer to match the end of a file over the middle', function() @@ -118,7 +118,7 @@ describe('buffer functions', function() --} --{ When: We close buf2 - close_buffer(NULL, buf2, buffer.DOBUF_WIPE, 0) + close_buffer(NULL, buf2, buffer.DOBUF_WIPE, 0, 0) -- And: Open buf1, which has 'file' in the middle of its name local buf1 = buflist_new(path1, buffer.BLN_LISTED) @@ -127,8 +127,8 @@ describe('buffer functions', function() eq(buf3.handle, buflist_findpat("file", ONLY_LISTED)) --} - close_buffer(NULL, buf1, buffer.DOBUF_WIPE, 0) - close_buffer(NULL, buf3, buffer.DOBUF_WIPE, 0) + close_buffer(NULL, buf1, buffer.DOBUF_WIPE, 0, 0) + close_buffer(NULL, buf3, buffer.DOBUF_WIPE, 0, 0) end) itp('should match a unique fragment of a file path', function() @@ -138,9 +138,9 @@ describe('buffer functions', function() eq(buf3.handle, buflist_findpat("_test_", ONLY_LISTED)) - close_buffer(NULL, buf1, buffer.DOBUF_WIPE, 0) - close_buffer(NULL, buf2, buffer.DOBUF_WIPE, 0) - close_buffer(NULL, buf3, buffer.DOBUF_WIPE, 0) + close_buffer(NULL, buf1, buffer.DOBUF_WIPE, 0, 0) + close_buffer(NULL, buf2, buffer.DOBUF_WIPE, 0, 0) + close_buffer(NULL, buf3, buffer.DOBUF_WIPE, 0, 0) end) itp('should include / ignore unlisted buffers based on the flag.', function() @@ -152,7 +152,7 @@ describe('buffer functions', function() --} --{ When: We unlist the buffer - close_buffer(NULL, buf3, buffer.DOBUF_DEL, 0) + close_buffer(NULL, buf3, buffer.DOBUF_DEL, 0, 0) -- Then: It should not find the buffer when searching only listed buffers eq(-1, buflist_findpat("_test_", ONLY_LISTED)) @@ -162,7 +162,7 @@ describe('buffer functions', function() --} --{ When: We wipe the buffer - close_buffer(NULL, buf3, buffer.DOBUF_WIPE, 0) + close_buffer(NULL, buf3, buffer.DOBUF_WIPE, 0, 0) -- Then: It should not find the buffer at all eq(-1, buflist_findpat("_test_", ONLY_LISTED)) @@ -180,7 +180,7 @@ describe('buffer functions', function() --} --{ When: The first buffer is unlisted - close_buffer(NULL, buf1, buffer.DOBUF_DEL, 0) + close_buffer(NULL, buf1, buffer.DOBUF_DEL, 0, 0) -- Then: The second buffer is preferred because -- unlisted buffers are not allowed @@ -194,7 +194,7 @@ describe('buffer functions', function() --} --{ When: We unlist the second buffer - close_buffer(NULL, buf2, buffer.DOBUF_DEL, 0) + close_buffer(NULL, buf2, buffer.DOBUF_DEL, 0, 0) -- Then: The first buffer is preferred again -- because buf1 matches better which takes precedence @@ -205,8 +205,8 @@ describe('buffer functions', function() eq(-1, buflist_findpat("test", ONLY_LISTED)) --} - close_buffer(NULL, buf1, buffer.DOBUF_WIPE, 0) - close_buffer(NULL, buf2, buffer.DOBUF_WIPE, 0) + close_buffer(NULL, buf1, buffer.DOBUF_WIPE, 0, 0) + close_buffer(NULL, buf2, buffer.DOBUF_WIPE, 0, 0) end) end) |