diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/api/buffer_spec.lua | 35 | ||||
-rw-r--r-- | test/functional/api/vim_spec.lua | 22 | ||||
-rw-r--r-- | test/functional/autocmd/autocmd_spec.lua | 91 | ||||
-rw-r--r-- | test/functional/autocmd/textyankpost_spec.lua | 16 | ||||
-rw-r--r-- | test/functional/ex_cmds/dict_notifications_spec.lua | 21 | ||||
-rw-r--r-- | test/functional/terminal/tui_spec.lua | 30 | ||||
-rw-r--r-- | test/functional/terminal/window_split_tab_spec.lua | 9 | ||||
-rw-r--r-- | test/functional/ui/cursor_spec.lua | 4 | ||||
-rw-r--r-- | test/functional/ui/float_spec.lua | 428 | ||||
-rw-r--r-- | test/functional/ui/highlight_spec.lua | 9 | ||||
-rw-r--r-- | test/functional/ui/inccommand_spec.lua | 18 | ||||
-rw-r--r-- | test/functional/ui/mouse_spec.lua | 17 | ||||
-rw-r--r-- | test/functional/ui/output_spec.lua | 3 | ||||
-rw-r--r-- | test/functional/ui/popupmenu_spec.lua | 6 | ||||
-rw-r--r-- | test/functional/ui/syntax_conceal_spec.lua | 7 |
15 files changed, 584 insertions, 132 deletions
diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua index d9412f0f13..93599c04f1 100644 --- a/test/functional/api/buffer_spec.lua +++ b/test/functional/api/buffer_spec.lua @@ -1,7 +1,9 @@ local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') local clear, nvim, buffer = helpers.clear, helpers.nvim, helpers.buffer local curbuf, curwin, eq = helpers.curbuf, helpers.curwin, helpers.eq local curbufmeths, ok = helpers.curbufmeths, helpers.ok +local meths = helpers.meths local funcs = helpers.funcs local request = helpers.request local exc_exec = helpers.exc_exec @@ -11,6 +13,7 @@ local NIL = helpers.NIL local meth_pcall = helpers.meth_pcall local command = helpers.command local bufmeths = helpers.bufmeths +local feed = helpers.feed describe('api/buf', function() before_each(clear) @@ -299,6 +302,38 @@ describe('api/buf', function() local retval = exc_exec("call nvim_buf_set_lines(1, 0, 1, v:false, ['test'])") eq(0, retval) end) + + it("set_lines of invisible buffer doesn't move cursor in current window", function() + local screen = Screen.new(20, 5) + screen:set_default_attr_ids({ + [1] = {bold = true, foreground = Screen.colors.Blue1}, + [2] = {bold = true}, + }) + screen:attach() + + insert([[ + Who would win? + A real window + with proper text]]) + local buf = meths.create_buf(false,true) + screen:expect([[ + Who would win? | + A real window | + with proper tex^t | + {1:~ }| + | + ]]) + + meths.buf_set_lines(buf, 0, -1, true, {'or some', 'scratchy text'}) + feed('i') -- provoke redraw + screen:expect([[ + Who would win? | + A real window | + with proper tex^t | + {1:~ }| + {2:-- INSERT --} | + ]]) + end) end) describe('get_offset', function() diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index b10076c6da..75b9fb71c9 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -1359,6 +1359,9 @@ describe('API', function() eq({id=1}, meths.get_current_buf()) local screen = Screen.new(20, 4) + screen:set_default_attr_ids({ + [1] = {bold = true, foreground = Screen.colors.Blue1}, + }) screen:attach() -- @@ -1373,7 +1376,7 @@ describe('API', function() end -- - -- Visiting a scratch-buffer DOES change its properties. + -- Visiting a scratch-buffer DOES NOT change its properties. -- meths.set_current_buf(edited_buf) screen:expect([[ @@ -1381,12 +1384,19 @@ describe('API', function() {1:~ }| {1:~ }| | - ]], { - [1] = {bold = true, foreground = Screen.colors.Blue1}, - }) - eq('', meths.buf_get_option(edited_buf, 'buftype')) - eq('', meths.buf_get_option(edited_buf, 'bufhidden')) + ]]) + eq('nofile', meths.buf_get_option(edited_buf, 'buftype')) + eq('hide', meths.buf_get_option(edited_buf, 'bufhidden')) eq(false, meths.buf_get_option(edited_buf, 'swapfile')) + + -- scratch buffer can be wiped without error + command('bwipe') + screen:expect([[ + ^ | + {1:~ }| + {1:~ }| + | + ]]) end) end) end) diff --git a/test/functional/autocmd/autocmd_spec.lua b/test/functional/autocmd/autocmd_spec.lua index 8ee9462a8d..814624d8e2 100644 --- a/test/functional/autocmd/autocmd_spec.lua +++ b/test/functional/autocmd/autocmd_spec.lua @@ -1,15 +1,18 @@ local helpers = require('test.functional.helpers')(after_each) +local dedent = helpers.dedent local eq = helpers.eq local eval = helpers.eval +local feed = helpers.feed local clear = helpers.clear local meths = helpers.meths +local funcs = helpers.funcs local expect = helpers.expect local command = helpers.command local exc_exec = helpers.exc_exec local curbufmeths = helpers.curbufmeths -describe('autocmds:', function() +describe('autocmd', function() before_each(clear) it(':tabnew triggers events in the correct order', function() @@ -55,4 +58,90 @@ describe('autocmds:', function() end of test file xx]]) end) end) + + it('++once', function() -- :help autocmd-once + -- + -- ":autocmd ... ++once" executes its handler once, then removes the handler. + -- + local expected = { + 'Many1', + 'Once1', + 'Once2', + 'Many2', + 'Once3', + 'Many1', + 'Many2', + 'Many1', + 'Many2', + } + command('let g:foo = []') + command('autocmd TabNew * :call add(g:foo, "Many1")') + command('autocmd TabNew * ++once :call add(g:foo, "Once1")') + command('autocmd TabNew * ++once :call add(g:foo, "Once2")') + command('autocmd TabNew * :call add(g:foo, "Many2")') + command('autocmd TabNew * ++once :call add(g:foo, "Once3")') + eq(dedent([[ + + --- Autocommands --- + TabNew + * :call add(g:foo, "Many1") + :call add(g:foo, "Once1") + :call add(g:foo, "Once2") + :call add(g:foo, "Many2") + :call add(g:foo, "Once3")]]), + funcs.execute('autocmd Tabnew')) + command('tabnew') + command('tabnew') + command('tabnew') + eq(expected, eval('g:foo')) + eq(dedent([[ + + --- Autocommands --- + TabNew + * :call add(g:foo, "Many1") + :call add(g:foo, "Many2")]]), + funcs.execute('autocmd Tabnew')) + + -- + -- ":autocmd ... ++once" handlers can be deleted. + -- + expected = {} + command('let g:foo = []') + command('autocmd TabNew * ++once :call add(g:foo, "Once1")') + command('autocmd! TabNew') + command('tabnew') + eq(expected, eval('g:foo')) + + -- + -- ":autocmd ... <buffer> ++once ++nested" + -- + expected = { + 'OptionSet-Once', + 'CursorMoved-Once', + } + command('let g:foo = []') + command('autocmd OptionSet binary ++nested ++once :call add(g:foo, "OptionSet-Once")') + command('autocmd CursorMoved <buffer> ++once ++nested setlocal binary|:call add(g:foo, "CursorMoved-Once")') + command("put ='foo bar baz'") + feed('0llhlh') + eq(expected, eval('g:foo')) + + -- + -- :autocmd should not show empty section after ++once handlers expire. + -- + expected = { + 'Once1', + 'Once2', + } + command('let g:foo = []') + command('autocmd! TabNew') -- Clear all TabNew handlers. + command('autocmd TabNew * ++once :call add(g:foo, "Once1")') + command('autocmd TabNew * ++once :call add(g:foo, "Once2")') + command('tabnew') + eq(expected, eval('g:foo')) + eq(dedent([[ + + --- Autocommands ---]]), + funcs.execute('autocmd Tabnew')) + end) end) diff --git a/test/functional/autocmd/textyankpost_spec.lua b/test/functional/autocmd/textyankpost_spec.lua index 486a3346b1..5849679dd2 100644 --- a/test/functional/autocmd/textyankpost_spec.lua +++ b/test/functional/autocmd/textyankpost_spec.lua @@ -23,6 +23,7 @@ describe('TextYankPost', function() it('is executed after yank and handles register types', function() feed('yy') eq({ + inclusive = false, operator = 'y', regcontents = { 'foo\nbar' }, regname = '', @@ -35,6 +36,7 @@ describe('TextYankPost', function() feed('+yw') eq({ + inclusive = false, operator = 'y', regcontents = { 'baz ' }, regname = '', @@ -44,6 +46,7 @@ describe('TextYankPost', function() feed('<c-v>eky') eq({ + inclusive = true, operator = 'y', regcontents = { 'foo', 'baz' }, regname = '', @@ -55,6 +58,7 @@ describe('TextYankPost', function() it('makes v:event immutable', function() feed('yy') eq({ + inclusive = false, operator = 'y', regcontents = { 'foo\nbar' }, regname = '', @@ -84,6 +88,7 @@ describe('TextYankPost', function() command('autocmd TextYankPost * normal "+yy') feed('yy') eq({ + inclusive = false, operator = 'y', regcontents = { 'foo\nbar' }, regname = '', @@ -96,6 +101,7 @@ describe('TextYankPost', function() it('is executed after delete and change', function() feed('dw') eq({ + inclusive = false, operator = 'd', regcontents = { 'foo' }, regname = '', @@ -105,6 +111,7 @@ describe('TextYankPost', function() feed('dd') eq({ + inclusive = false, operator = 'd', regcontents = { '\nbar' }, regname = '', @@ -114,6 +121,7 @@ describe('TextYankPost', function() feed('cwspam<esc>') eq({ + inclusive = true, operator = 'c', regcontents = { 'baz' }, regname = '', @@ -141,6 +149,7 @@ describe('TextYankPost', function() it('gives the correct register name', function() feed('$"byiw') eq({ + inclusive = true, operator = 'y', regcontents = { 'bar' }, regname = 'b', @@ -149,6 +158,7 @@ describe('TextYankPost', function() feed('"*yy') eq({ + inclusive = true, operator = 'y', regcontents = { 'foo\nbar' }, regname = '*', @@ -160,6 +170,7 @@ describe('TextYankPost', function() -- regname still shows the name the user requested feed('yy') eq({ + inclusive = true, operator = 'y', regcontents = { 'foo\nbar' }, regname = '', @@ -168,6 +179,7 @@ describe('TextYankPost', function() feed('"*yy') eq({ + inclusive = true, operator = 'y', regcontents = { 'foo\nbar' }, regname = '*', @@ -178,6 +190,7 @@ describe('TextYankPost', function() it('works with Ex commands', function() command('1delete +') eq({ + inclusive = false, operator = 'd', regcontents = { 'foo\nbar' }, regname = '+', @@ -187,6 +200,7 @@ describe('TextYankPost', function() command('yank') eq({ + inclusive = false, operator = 'y', regcontents = { 'baz text' }, regname = '', @@ -196,6 +210,7 @@ describe('TextYankPost', function() command('normal yw') eq({ + inclusive = false, operator = 'y', regcontents = { 'baz ' }, regname = '', @@ -205,6 +220,7 @@ describe('TextYankPost', function() command('normal! dd') eq({ + inclusive = false, operator = 'd', regcontents = { 'baz text' }, regname = '', diff --git a/test/functional/ex_cmds/dict_notifications_spec.lua b/test/functional/ex_cmds/dict_notifications_spec.lua index 3d550588e7..48e7e05e4c 100644 --- a/test/functional/ex_cmds/dict_notifications_spec.lua +++ b/test/functional/ex_cmds/dict_notifications_spec.lua @@ -1,12 +1,13 @@ local helpers = require('test.functional.helpers')(after_each) local clear, nvim, source = helpers.clear, helpers.nvim, helpers.source +local insert = helpers.insert local eq, next_msg = helpers.eq, helpers.next_msg local exc_exec = helpers.exc_exec local command = helpers.command local eval = helpers.eval -describe('dictionary change notifications', function() +describe('VimL dictionary notifications', function() local channel before_each(function() @@ -338,4 +339,22 @@ describe('dictionary change notifications', function() eq({'notification', '2', {'foo', {old = 'baz', new = 'bar'}}}, next_msg()) end) end) + + it('for b:changedtick', function() + source([[ + function! OnTickChanged(dict, key, value) + call rpcnotify(g:channel, 'SendChangeTick', a:key, a:value) + endfunction + call dictwatcheradd(b:, 'changedtick', 'OnTickChanged') + ]]) + + insert('t'); + eq({'notification', 'SendChangeTick', {'changedtick', {old = 2, new = 3}}}, + next_msg()) + + command([[call dictwatcherdel(b:, 'changedtick', 'OnTickChanged')]]) + insert('t'); + eq(2, eval('1+1')) -- Still alive? + end) + end) diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index a0adb45630..9d0eb5e40e 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -839,8 +839,7 @@ describe('TUI background color', function() it("triggers OptionSet event on terminal-response", function() feed_data('\027:autocmd OptionSet background echo "did OptionSet, yay!"\n') - -- The child Nvim is running asynchronously; wait for it to register the - -- OptionSet handler. + -- Wait for the child Nvim to register the OptionSet handler. feed_data('\027:autocmd OptionSet\n') screen:expect({any='--- Autocommands ---'}) @@ -860,16 +859,23 @@ describe('TUI background color', function() local function assert_bg(color, bg) it('handles '..color..' as '..bg, function() - feed_data('\027]11;rgb:'..color..'\007:echo &background\n') - screen:expect(string.format([[ - {1: } | - {4:~ }| - {4:~ }| - {4:~ }| - {5:[No Name] 0,0-1 All}| - %-5s | - {3:-- TERMINAL --} | - ]], bg)) + feed_data('\027]11;rgb:'..color..'\007') + -- Retry until the terminal response is handled. + retry(100, nil, function() + feed_data(':echo &background\n') + screen:expect({ + timeout=40, + grid=string.format([[ + {1: } | + {4:~ }| + {4:~ }| + {4:~ }| + {5:[No Name] 0,0-1 All}| + %-5s | + {3:-- TERMINAL --} | + ]], bg) + }) + end) end) end diff --git a/test/functional/terminal/window_split_tab_spec.lua b/test/functional/terminal/window_split_tab_spec.lua index f3d0b45d09..c0ce656bb1 100644 --- a/test/functional/terminal/window_split_tab_spec.lua +++ b/test/functional/terminal/window_split_tab_spec.lua @@ -39,10 +39,11 @@ describe(':terminal', function() it('does not change size on WinEnter', function() if helpers.pending_win32(pending) then return end feed('<c-\\><c-n>') + feed('k') feed_command('2split') screen:expect([[ - tty ready | - ^rows: 5, cols: 50 | + ^tty ready | + rows: 5, cols: 50 | ========== | tty ready | rows: 5, cols: 50 | @@ -57,8 +58,8 @@ describe(':terminal', function() tty ready | rows: 5, cols: 50 | ========== | - tty ready | - ^rows: 5, cols: 50 | + ^tty ready | + rows: 5, cols: 50 | {2: } | | | diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index 3e0370db14..4dc86f1e1f 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -216,10 +216,10 @@ describe('ui/cursor', function() if m.blinkwait then m.blinkwait = 700 end end if m.hl_id then - m.hl_id = 49 + m.hl_id = 50 m.attr = {background = Screen.colors.DarkGray} end - if m.id_lm then m.id_lm = 50 end + if m.id_lm then m.id_lm = 51 end end -- Assert the new expectation. diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 784c2d98f5..bb3255840e 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -29,7 +29,10 @@ describe('floating windows', function() [10] = {background = Screen.colors.LightGrey, underline = true, bold = true, foreground = Screen.colors.Magenta}, [11] = {bold = true, foreground = Screen.colors.Magenta}, [12] = {background = Screen.colors.Red, bold = true, foreground = Screen.colors.Blue1}, - [13] = {background = Screen.colors.WebGray} + [13] = {background = Screen.colors.WebGray}, + [14] = {foreground = Screen.colors.Brown}, + [15] = {background = Screen.colors.Grey20}, + [16] = {background = Screen.colors.Grey20, bold = true, foreground = Screen.colors.Blue1}, } local function with_ext_multigrid(multigrid) @@ -43,12 +46,10 @@ describe('floating windows', function() it('can be created and reconfigured', function() local buf = meths.create_buf(false,false) local win = meths.open_win(buf, false, 20, 2, {relative='editor', row=2, col=5}) - meths.win_set_option(win , 'winhl', 'Normal:PMenu') local expected_pos = { [3]={{id=1001}, 'NW', 1, 2, 5, true}, } - if multigrid then screen:expect{grid=[[ ## grid 1 @@ -151,6 +152,83 @@ describe('floating windows', function() end end) + it('defaults to nonumber and NormalFloat highlight', function() + command('set number') + command('hi NormalFloat guibg=#333333') + feed('ix<cr>y<cr><esc>gg') + local win = meths.open_win(0, false, 20, 4, {relative='editor', row=4, col=10}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + | + ## grid 2 + {14: 1 }^x | + {14: 2 }y | + {14: 3 } | + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {15:x }| + {15:y }| + {15: }| + {16:~ }| + ]], float_pos={[3] = {{id = 1001}, "NW", 1, 4, 10, true}}} + else + screen:expect([[ + {14: 1 }^x | + {14: 2 }y | + {14: 3 } {15:x } | + {0:~ }{15:y }{0: }| + {0:~ }{15: }{0: }| + {0:~ }{16:~ }{0: }| + | + ]]) + end + + local buf = meths.create_buf(false, true) + meths.win_set_buf(win, buf) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + {4:[No Name] [+] }| + | + ## grid 2 + {14: 1 }^x | + {14: 2 }y | + {14: 3 } | + {0:~ }| + {0:~ }| + ## grid 3 + {15: }| + {16:~ }| + {16:~ }| + {16:~ }| + ]], float_pos={[3] = {{id = 1001}, "NW", 1, 4, 10, true}}} + else + screen:expect([[ + {14: 1 }^x | + {14: 2 }y | + {14: 3 } {15: } | + {0:~ }{16:~ }{0: }| + {0:~ }{16:~ }{0: }| + {4:[No Name] }{16:~ }{4: }| + | + ]]) + end + end) + it('API has proper error messages', function() local buf = meths.create_buf(false,false) eq({false, "Invalid options key 'bork'"}, @@ -211,7 +289,6 @@ describe('floating windows', function() local buf = meths.create_buf(false,false) -- no 'win' arg, relative default window local win = meths.open_win(buf, false, 20, 2, {relative='win', row=0, col=10}) - meths.win_set_option(win, 'winhl', 'Normal:PMenu') if multigrid then screen:expect{grid=[[ ## grid 1 @@ -467,8 +544,7 @@ describe('floating windows', function() screen2:attach(nil, session2) screen2:set_default_attr_ids(attrs) local buf = meths.create_buf(false,false) - local win = meths.open_win(buf, true, 20, 2, {relative='editor', row=2, col=5}) - meths.win_set_option(win, 'winhl', 'Normal:PMenu') + meths.open_win(buf, true, 20, 2, {relative='editor', row=2, col=5}) local expected_pos = { [2]={{id=1001}, 'NW', 1, 2, 5} } @@ -502,9 +578,8 @@ describe('floating windows', function() local buf = meths.create_buf(false,false) meths.buf_set_lines(buf, 0, -1, true, {'such', 'very', 'float'}) local win = meths.open_win(buf, false, 15, 4, {relative='editor', row=2, col=10}) - meths.win_set_option(win , 'winhl', 'Normal:PMenu') local expected_pos = { - [3]={{id=1001}, 'NW', 1, 2, 10, true}, + [4]={{id=1002}, 'NW', 1, 2, 10, true}, } if multigrid then screen:expect{grid=[[ @@ -523,7 +598,7 @@ describe('floating windows', function() {0:~ }| {0:~ }| {0:~ }| - ## grid 3 + ## grid 4 {1:such }| {1:very }| {1:float }| @@ -555,7 +630,7 @@ describe('floating windows', function() {0:~ }| {0:~ }| {0:~ }| - ## grid 3 + ## grid 4 {1:such }| {1:very }| {1:float }| @@ -583,7 +658,7 @@ describe('floating windows', function() ^ | {0:~ }| {0:~ }| - ## grid 3 + ## grid 4 {1:such }| {1:very }| {1:float }| @@ -608,7 +683,7 @@ describe('floating windows', function() ## grid 2 ^ | {0:~ }| - ## grid 3 + ## grid 4 {1:such }| {1:very }| {1:float }| @@ -631,7 +706,7 @@ describe('floating windows', function() ## grid 2 | {0:~ }| - ## grid 3 + ## grid 4 {1:such }| {1:very }| {1:^float }| @@ -663,7 +738,7 @@ describe('floating windows', function() {0:~ }| {0:~ }| {0:~ }| - ## grid 3 + ## grid 4 {1:such }| {1:very }| {1:^float }| @@ -700,7 +775,7 @@ describe('floating windows', function() {0:~ }| {0:~ }| {0:~ }| - ## grid 3 + ## grid 4 {1:^such }| {1:very }| {1:float }| @@ -735,7 +810,7 @@ describe('floating windows', function() {0:~ }| {0:~ }| {0:~ }| - ## grid 3 + ## grid 4 {1:^such }| {1:very }| {1:float }| @@ -770,7 +845,7 @@ describe('floating windows', function() {0:~ }| {0:~ }| {0:~ }| - ## grid 3 + ## grid 4 {1:^such }| {1:very }| {1:float }| @@ -805,7 +880,7 @@ describe('floating windows', function() {0:~ }| {0:~ }| {0:~ }| - ## grid 3 + ## grid 4 {1:^such }| {1:very }| {1:float }| @@ -840,7 +915,7 @@ describe('floating windows', function() {0:~ }| {0:~ }| {0:~ }| - ## grid 3 + ## grid 4 {1:^such }| {1:very }| {1:float }| @@ -875,7 +950,7 @@ describe('floating windows', function() {0:~ }| {0:~ }| {0:~ }| - ## grid 3 + ## grid 4 {1:^such }| {1:very }| {1:float }| @@ -910,7 +985,7 @@ describe('floating windows', function() {0:~ }| {0:~ }| {0:~ }| - ## grid 3 + ## grid 4 {1:^such }| {1:very }| {1:float }| @@ -945,7 +1020,7 @@ describe('floating windows', function() {0:~ }| {0:~ }| {0:~ }| - ## grid 3 + ## grid 4 {1:^such }| {1:very }| {1:float }| @@ -971,7 +1046,7 @@ describe('floating windows', function() | ## grid 2 | - ## grid 3 + ## grid 4 {1:^such }| {1:very }| {1:float }| @@ -1001,7 +1076,7 @@ describe('floating windows', function() {0:~ }| {0:~ }| {0:~ }| - ## grid 3 + ## grid 4 {1:^such }| {1:very }| {1:float }| @@ -1019,6 +1094,13 @@ describe('floating windows', function() end end) + it('does not crash when set cmdheight #9680', function() + local buf = meths.create_buf(false,false) + meths.open_win(buf, false, 20, 2, {relative='editor', row=2, col=5}) + command("set cmdheight=2") + eq(1, meths.eval('1')) + end) + describe('and completion', function() before_each(function() local buf = meths.create_buf(false,false) @@ -1395,9 +1477,233 @@ describe('floating windows', function() ]]) end end) - end) + describe('float shown after pum', function() + local win + before_each(function() + command('hi NormalFloat guibg=#333333') + feed('i') + funcs.complete(1, {'aa', 'word', 'longtext'}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + {3:-- INSERT --} | + ## grid 2 + aa^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {13:aa }| + {1:word }| + {1:longtext }| + ]], float_pos={ + [3] = {{id = -1}, "NW", 2, 1, 0, false}} + } + else + screen:expect([[ + aa^ | + {13:aa }{0: }| + {1:word }{0: }| + {1:longtext }{0: }| + {0:~ }| + {0:~ }| + {3:-- INSERT --} | + ]]) + end + + local buf = meths.create_buf(false,true) + meths.buf_set_lines(buf,0,-1,true,{"some info", "about item"}) + win = meths.open_win(buf, false, 12, 2, {relative='cursor', row=1, col=10}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + {3:-- INSERT --} | + ## grid 2 + aa^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {13:aa }| + {1:word }| + {1:longtext }| + ## grid 5 + {15:some info }| + {15:about item }| + ]], float_pos={ + [3] = {{id = -1}, "NW", 2, 1, 0, false}, + [5] = {{id = 1002}, "NW", 2, 1, 12, true}, + }} + else + screen:expect([[ + aa^ | + {13:aa }{15:e info }{0: }| + {1:word }{15:ut item }{0: }| + {1:longtext }{0: }| + {0:~ }| + {0:~ }| + {3:-- INSERT --} | + ]]) + end + end) + + it('and close pum first', function() + feed('<c-y>') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + {3:-- INSERT --} | + ## grid 2 + aa^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 5 + {15:some info }| + {15:about item }| + ]], float_pos={ + [5] = {{id = 1002}, "NW", 2, 1, 12, true}, + }} + else + screen:expect([[ + aa^ | + {0:~ }{15:some info }{0: }| + {0:~ }{15:about item }{0: }| + {0:~ }| + {0:~ }| + {0:~ }| + {3:-- INSERT --} | + ]]) + end + + meths.win_close(win, false) + if multigrid then + screen:expect([[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + {3:-- INSERT --} | + ## grid 2 + aa^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ]]) + else + screen:expect([[ + aa^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {3:-- INSERT --} | + ]]) + end + end) + + it('and close float first', function() + meths.win_close(win, false) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + {3:-- INSERT --} | + ## grid 2 + aa^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {13:aa }| + {1:word }| + {1:longtext }| + ]], float_pos={ + [3] = {{id = -1}, "NW", 2, 1, 0, false}, + }} + else + screen:expect([[ + aa^ | + {13:aa }{0: }| + {1:word }{0: }| + {1:longtext }{0: }| + {0:~ }| + {0:~ }| + {3:-- INSERT --} | + ]]) + end + + feed('<c-y>') + if multigrid then + screen:expect([[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + {3:-- INSERT --} | + ## grid 2 + aa^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ]]) + else + screen:expect([[ + aa^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {3:-- INSERT --} | + ]]) + end + end) + end) describe("handles :wincmd", function() local win @@ -1410,7 +1716,6 @@ describe('floating windows', function() local buf = meths.create_buf(false,false) win = meths.open_win(buf, false, 20, 2, {relative='editor', row=2, col=5}) meths.buf_set_lines(buf,0,-1,true,{"y"}) - meths.win_set_option(win , 'winhl', 'Normal:PMenu') expected_pos = { [3]={{id=1001}, 'NW', 1, 2, 5, true} } @@ -2067,39 +2372,6 @@ describe('floating windows', function() {1:y }| {2:~ }| ## grid 4 - {1:^y }| - {2:~ }| - ]], float_pos=expected_pos} - else - screen:expect([[ - {1:^y }| - {2:~ }| - {4:[No N}{1:y }{4: }| - x {2:~ } | - {0:~ }| - {5:[No Name] [+] }| - | - ]]) - end - - feed(":set winhighlight=<cr><c-l>") - if multigrid then - screen:expect{grid=[[ - ## grid 1 - [4:----------------------------------------]| - [4:----------------------------------------]| - {4:[No Name] [+] }| - [2:----------------------------------------]| - [2:----------------------------------------]| - {5:[No Name] [+] }| - | - ## grid 2 - x | - {0:~ }| - ## grid 3 - {1:y }| - {2:~ }| - ## grid 4 ^y | {0:~ }| ]], float_pos=expected_pos} @@ -2115,7 +2387,6 @@ describe('floating windows', function() ]]) end - feed("<c-w>j") if multigrid then screen:expect{grid=[[ @@ -2652,16 +2923,16 @@ describe('floating windows', function() x | {0:~ }| ## grid 3 - {1:^y }| - {2:~ }| + ^y | + {0:~ }| ]]} else screen:expect([[ x | {0:~ }| {5:[No Name] [+] }| - {1:^y }| - {2:~ }| + ^y | + {0:~ }| {4:[No Name] [+] }| | ]]) @@ -2686,8 +2957,8 @@ describe('floating windows', function() {0:~ }| {0:~ }| ## grid 3 - {1:^y }| - {2:~ }| + ^y | + {0:~ }| ]], float_pos=expected_pos} else eq({false, "UI doesn't support external windows"}, @@ -2710,11 +2981,10 @@ describe('floating windows', function() x | {0:~ }| ## grid 3 - {1:^y }| - {2:~ }| + ^y | + {0:~ }| ]]) end - end) it('movements with nested split layout', function() @@ -2779,8 +3049,8 @@ describe('floating windows', function() 4 | {0:~ }| ## grid 3 - ^5 | - {0:~ }| + {1:^5 }| + {2:~ }| ## grid 4 2 | {0:~ }| @@ -2795,8 +3065,8 @@ describe('floating windows', function() screen:expect([[ 1 {5:│}2 | {0:~ }{5:│}{0:~ }| - {5:[No N}^5 {5:ame] [+] }| - 3 {0:~ } | + {5:[No N}{1:^5 }{5:ame] [+] }| + 3 {2:~ } | {0:~ }{5:│}{0:~ }| {5:[No Name] [+] [No Name] [+] }| :enew | @@ -2978,8 +3248,8 @@ describe('floating windows', function() {0:~ }| {0:~ }| ## grid 3 - {1:y }| - {2:~ }| + y | + {0:~ }| ## grid 4 ^ | {0:~ }| @@ -3009,8 +3279,8 @@ describe('floating windows', function() {0:~ }| {0:~ }| ## grid 3 - {1:y }| - {2:~ }| + y | + {0:~ }| ## grid 4 | {0:~ }| @@ -3037,8 +3307,8 @@ describe('floating windows', function() {0:~ }| {0:~ }| ## grid 3 - {1:y }| - {2:~ }| + y | + {0:~ }| ## grid 4 ^ | {0:~ }| diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 39170337d7..3ee3f173d6 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -1274,17 +1274,18 @@ describe("'winhighlight' highlight", function() command('set number') command('set colorcolumn=2') command('set cursorcolumn') + feed('k') command('split') command('set winhl=LineNr:Background1,CursorColumn:Background2,' ..'ColorColumn:ErrorMsg') screen:expect([[ - {1: 1 }v{15:e}ry tex{5:t} | - {1: 2 }m{15:o}re tex^t | + {1: 1 }v{15:e}ry tex^t | + {1: 2 }m{15:o}re tex{5:t} | {0:~ }| {3:[No Name] [+] }| - {9: 1 }v{17:e}ry tex{18:t} | - {9: 2 }m{17:o}re text | + {9: 1 }v{17:e}ry text | + {9: 2 }m{17:o}re tex{18:t} | {4:[No Name] [+] }| | ]]) diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 536264019c..c215ece2f2 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -938,11 +938,11 @@ describe(":substitute, inccommand=split", function() feed(":%s/tw") -- 'cursorline' is NOT active during preview. screen:expect([[ - Inc substitution on | {12:tw}o lines | Inc substitution on | {12:tw}o lines | | + {15:~ }| {11:[No Name] [+] }| |2| {12:tw}o lines | |4| {12:tw}o lines | @@ -1185,6 +1185,7 @@ describe(":substitute, inccommand=split", function() end) it("clears preview if non-previewable command is edited #5585", function() + feed('gg') -- Put a non-previewable command in history. feed_command("echo 'foo'") -- Start an incomplete :substitute command. @@ -2084,11 +2085,11 @@ describe(":substitute", function() feed(":%s/[0-9]\\n\\zs[A-Z]/OKO") screen:expect([[ - 1 2 3 | {12:OKO} B C | 4 5 6 | {12:OKO} Y Z | 7 8 9 | + | {11:[No Name] [+] }| |1| 1 2 3 | |2| {12:OKO} B C | @@ -2204,11 +2205,11 @@ describe(":substitute", function() feed("/KKK") screen:expect([[ - x | afa {12:KKK}adf la;lkd {12:KKK}alx | | {15:~ }| {15:~ }| + {15:~ }| {11:[No Name] [+] }| |3| afa {12:KKK}adf la;lkd {12:KKK}alx | {15:~ }| @@ -2256,11 +2257,11 @@ describe(":substitute", function() common_setup(screen, "split", multibyte_text) feed(":%s/£.*ѫ/X¥¥") screen:expect([[ - {12:X¥¥} | a{12:X¥¥}¥KOL | £ ¥ libm | £ ¥ | | + {15:~ }| {11:[No Name] [+] }| |1| {12:X¥¥} PEPPERS | |2| {12:X¥¥} | @@ -2275,11 +2276,11 @@ describe(":substitute", function() feed("\\ra££ ¥") screen:expect([[ - {12:a££ ¥} | a{12:X¥¥} | {12:a££ ¥}¥KOL | £ ¥ libm | £ ¥ | + | {11:[No Name] [+] }| |1| {12:X¥¥} | |2|{12: a££ ¥} PEPPERS | @@ -2378,7 +2379,6 @@ describe(":substitute", function() feed("\\rѫ ab \\rXXXX") screen:expect([[ - 7 8 9 | K L M | {12:JLKR £} | {12:ѫ ab } | @@ -2387,6 +2387,7 @@ describe(":substitute", function() {12:ѫ ab } | {12:XXXX} e f | {12:JLKR £} | + {12:ѫ ab } | {11:[No Name] [+] }| | 7| {12:JLKR £} | | 8|{12: ѫ ab } | @@ -2480,14 +2481,15 @@ describe(":substitute", function() ]]) feed("<C-c>") + feed('gg') wait() feed([[:%s/\(some\)\@<lt>!thing/one/]]) screen:expect([[ - something | every{12:one} | someone | {15:~ }| {15:~ }| + {15:~ }| {11:[No Name] [+] }| |2| every{12:one} | {15:~ }| @@ -2525,11 +2527,11 @@ describe(":substitute", function() wait() feed([[:%s/some\(thing\)\@!/every/]]) screen:expect([[ - everything | {12:every}one | {15:~ }| {15:~ }| {15:~ }| + {15:~ }| {11:[No Name] [+] }| |3| {12:every}one | {15:~ }| diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua index 7805ed3cb9..c1a350dc34 100644 --- a/test/functional/ui/mouse_spec.lua +++ b/test/functional/ui/mouse_spec.lua @@ -649,13 +649,14 @@ describe('ui/mouse/input', function() mouse scrolling ]]) screen:try_resize(53, 14) + feed('k') feed_command('sp', 'vsp') screen:expect([[ lines {4:│}lines | to {4:│}to | test {4:│}test | - mouse scrolling {4:│}mouse scrolling | - ^ {4:│} | + ^mouse scrolling {4:│}mouse scrolling | + {4:│} | {0:~ }{4:│}{0:~ }| {5:[No Name] [+] }{4:[No Name] [+] }| to | @@ -672,8 +673,8 @@ describe('ui/mouse/input', function() feed('<ScrollWheelDown><0,0>') end screen:expect([[ - mouse scrolling {4:│}lines | - ^ {4:│}to | + ^mouse scrolling {4:│}lines | + {4:│}to | {0:~ }{4:│}test | {0:~ }{4:│}mouse scrolling | {0:~ }{4:│} | @@ -693,8 +694,8 @@ describe('ui/mouse/input', function() feed('<ScrollWheelUp><27,0>') end screen:expect([[ - mouse scrolling {4:│}text | - ^ {4:│}with | + ^mouse scrolling {4:│}text | + {4:│}with | {0:~ }{4:│}many | {0:~ }{4:│}lines | {0:~ }{4:│}to | @@ -715,8 +716,8 @@ describe('ui/mouse/input', function() feed('<ScrollWheelUp><27,7><ScrollWheelUp>') end screen:expect([[ - mouse scrolling {4:│}text | - ^ {4:│}with | + ^mouse scrolling {4:│}text | + {4:│}with | {0:~ }{4:│}many | {0:~ }{4:│}lines | {0:~ }{4:│}to | diff --git a/test/functional/ui/output_spec.lua b/test/functional/ui/output_spec.lua index 87b489fd71..38c4527a5b 100644 --- a/test/functional/ui/output_spec.lua +++ b/test/functional/ui/output_spec.lua @@ -51,7 +51,8 @@ describe("shell command :!", function() end) it("throttles shell-command output greater than ~10KB", function() - if helpers.skip_fragile(pending) then + if helpers.skip_fragile(pending, + (os.getenv("TRAVIS") and helpers.os_name() == "osx")) then return end child_session.feed_data( diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index 9a8c5a5789..1e6ebb87f5 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -1198,20 +1198,20 @@ describe('builtin popupmenu', function() command("split") screen:expect([[ - xx | choice^ | + {1:~ }| {n:word }{1: }| {s:choice }{4: }| {n:text } | - {n:thing } | + {n:thing }{1: }| {3:[No Name] [+] }| {2:-- INSERT --} | ]]) meths.input_mouse('wheel', 'down', '', 0, 6, 15) screen:expect([[ - xx | choice^ | + {1:~ }| {n:word }{1: }| {s:choice }{4: }| {n:text } | diff --git a/test/functional/ui/syntax_conceal_spec.lua b/test/functional/ui/syntax_conceal_spec.lua index d678784dc9..00e94ef94b 100644 --- a/test/functional/ui/syntax_conceal_spec.lua +++ b/test/functional/ui/syntax_conceal_spec.lua @@ -356,16 +356,17 @@ describe('Screen', function() end) it('between windows', function() + feed('k') command("split") screen:expect([[ foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | foo barf bar barf egg^s | + foo {1:b} bar {1:b} eggs | | {2:[No Name] [+] }| foo {1:b} bar {1:b} eggs | foo {1:b} bar {1:b} eggs | - | + foo {1:b} bar {1:b} eggs | {3:[No Name] [+] }| | ]]) @@ -379,7 +380,7 @@ describe('Screen', function() {3:[No Name] [+] }| foo {1:b} bar {1:b} eggs | foo barf bar barf egg^s | - | + foo {1:b} bar {1:b} eggs | {2:[No Name] [+] }| | ]]) |