diff options
Diffstat (limited to 'test/functional/ui')
-rw-r--r-- | test/functional/ui/cmdline_highlight_spec.lua | 74 | ||||
-rw-r--r-- | test/functional/ui/decorations_spec.lua | 38 | ||||
-rw-r--r-- | test/functional/ui/fold_spec.lua | 7 | ||||
-rw-r--r-- | test/functional/ui/highlight_spec.lua | 341 | ||||
-rw-r--r-- | test/functional/ui/hlstate_spec.lua | 20 | ||||
-rw-r--r-- | test/functional/ui/inccommand_spec.lua | 17 | ||||
-rw-r--r-- | test/functional/ui/inccommand_user_spec.lua | 347 | ||||
-rw-r--r-- | test/functional/ui/input_spec.lua | 29 | ||||
-rw-r--r-- | test/functional/ui/messages_spec.lua | 13 | ||||
-rw-r--r-- | test/functional/ui/mouse_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/ui/output_spec.lua | 29 | ||||
-rw-r--r-- | test/functional/ui/screen.lua | 8 | ||||
-rw-r--r-- | test/functional/ui/statusline_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/ui/winbar_spec.lua | 134 |
14 files changed, 767 insertions, 294 deletions
diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index 384761ab17..fa5771a8b3 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -24,7 +24,6 @@ before_each(function() clear() screen = Screen.new(40, 8) screen:attach() - command("set display-=msgsep") source([[ highlight RBP1 guibg=Red highlight RBP2 guibg=Yellow @@ -152,6 +151,7 @@ before_each(function() SB={foreground = Screen.colors.Blue4}, E={foreground = Screen.colors.Red, background = Screen.colors.Blue}, M={bold = true}, + MSEP={bold = true, reverse = true}; }) end) @@ -298,22 +298,22 @@ describe('Command-line coloring', function() function() set_color_cb('SplittedMultibyteStart') start_prompt('echo "«') - screen:expect([[ - {EOB:~ }| - {EOB:~ }| + screen:expect{grid=[[ + | {EOB:~ }| {EOB:~ }| + {MSEP: }| :echo " | {ERR:E5405: Chunk 0 start 7 splits multibyte }| {ERR:character} | :echo "«^ | - ]]) + ]]} feed('»') screen:expect([[ + | {EOB:~ }| {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {MSEP: }| :echo " | {ERR:E5405: Chunk 0 start 7 splits multibyte }| {ERR:character} | @@ -325,10 +325,10 @@ describe('Command-line coloring', function() set_color_cb('SplittedMultibyteEnd') start_prompt('echo "«') screen:expect([[ + | {EOB:~ }| {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {MSEP: }| :echo " | {ERR:E5406: Chunk 0 end 7 splits multibyte ch}| {ERR:aracter} | @@ -339,10 +339,10 @@ describe('Command-line coloring', function() set_color_cb('Echoerring') start_prompt('e') screen:expect([[ + | {EOB:~ }| {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {MSEP: }| : | {ERR:E5407: Callback has thrown an exception:}| {ERR: Vim(echoerr):HERE} | @@ -398,10 +398,10 @@ describe('Command-line coloring', function() set_color_cb('Throwing') start_prompt('e') screen:expect([[ + | {EOB:~ }| {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {MSEP: }| : | {ERR:E5407: Callback has thrown an exception:}| {ERR: ABC} | @@ -412,10 +412,10 @@ describe('Command-line coloring', function() set_color_cb('SplittedMultibyteStart') start_prompt('let x = "«»«»«»«»«»"') screen:expect([[ + | {EOB:~ }| {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {MSEP: }| :let x = " | {ERR:E5405: Chunk 0 start 10 splits multibyte}| {ERR: character} | @@ -453,10 +453,10 @@ describe('Command-line coloring', function() screen:sleep(500) feed('<C-c>') screen:expect([[ + | {EOB:~ }| {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {MSEP: }| : | {ERR:E5407: Callback has thrown an exception:}| {ERR: Keyboard interrupt} | @@ -517,11 +517,11 @@ describe('Command-line coloring', function() set_color_cb('ReturningGlobal', '') start_prompt('#') screen:expect([[ + | {EOB:~ }| {EOB:~ }| {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {MSEP: }| : | {ERR:E5400: Callback should return list} | :#^ | @@ -531,11 +531,11 @@ describe('Command-line coloring', function() set_color_cb('ReturningGlobal', {{0, 1, 'Normal'}, 42}) start_prompt('#') screen:expect([[ + | {EOB:~ }| {EOB:~ }| {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {MSEP: }| : | {ERR:E5401: List item 1 is not a List} | :#^ | @@ -545,10 +545,10 @@ describe('Command-line coloring', function() set_color_cb('ReturningGlobal2', {{0, 1, 'Normal'}, {1}}) start_prompt('+') screen:expect([[ + | {EOB:~ }| {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {MSEP: }| :+ | {ERR:E5402: List item 1 has incorrect length:}| {ERR: 1 /= 3} | @@ -559,10 +559,10 @@ describe('Command-line coloring', function() set_color_cb('ReturningGlobal2', {{0, 1, 'Normal'}, {2, 3, 'Normal'}}) start_prompt('+') screen:expect([[ + | {EOB:~ }| {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {MSEP: }| :+ | {ERR:E5403: Chunk 1 start 2 not in range [1, }| {ERR:2)} | @@ -573,10 +573,10 @@ describe('Command-line coloring', function() set_color_cb('ReturningGlobal2', {{0, 1, 'Normal'}, {1, 3, 'Normal'}}) start_prompt('+') screen:expect([[ + | {EOB:~ }| {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {MSEP: }| :+ | {ERR:E5404: Chunk 1 end 3 not in range (1, 2]}| | @@ -800,10 +800,10 @@ describe('Ex commands coloring', function() it('does not crash when using `n` in debug mode', function() feed(':debug execute "echo 1"\n') screen:expect([[ + | {EOB:~ }| {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {MSEP: }| Entering Debug mode. Type "cont" to con| tinue. | cmd: execute "echo 1" | @@ -811,8 +811,8 @@ describe('Ex commands coloring', function() ]]) feed('n\n') screen:expect([[ - {EOB:~ }| - {EOB:~ }| + | + {MSEP: }| Entering Debug mode. Type "cont" to con| tinue. | cmd: execute "echo 1" | @@ -836,10 +836,10 @@ describe('Ex commands coloring', function() command("cnoremap <expr> x execute('throw 42')[-1]") feed(':#x') screen:expect([[ + | {EOB:~ }| {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {MSEP: }| :# | {ERR:Error detected while processing :} | {ERR:E605: Exception not caught: 42} | @@ -847,9 +847,9 @@ describe('Ex commands coloring', function() ]]) feed('<CR>') screen:expect([[ + | {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {MSEP: }| :# | {ERR:Error detected while processing :} | {ERR:E605: Exception not caught: 42} | @@ -864,9 +864,9 @@ describe('Ex commands coloring', function() meths.set_var('Nvim_color_cmdline', 42) feed(':#') screen:expect([[ + | {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {MSEP: }| : | {ERR:E5408: Unable to get g:Nvim_color_cmdlin}| {ERR:e callback: Vim:E6000: Argument is not a}| diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 9af5d386db..789f1c6487 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -193,7 +193,7 @@ describe('decorations providers', function() | ]]} - meths._set_hl_ns(ns1) + meths.set_hl_ns(ns1) screen:expect{grid=[[ {10: 1 }{11:// just to see if there was an accid}| {10: }{11:ent} | @@ -219,7 +219,7 @@ describe('decorations providers', function() local ns2 = a.nvim_create_namespace 'ns2' a.nvim_set_decoration_provider (ns2, { on_win = function (_, win, buf) - a.nvim__set_hl_ns(win == thewin and _G.ns1 or ns2) + a.nvim_set_hl_ns_fast(win == thewin and _G.ns1 or ns2) end; }) ]] @@ -266,7 +266,7 @@ describe('decorations providers', function() ]]} meths.set_hl(ns1, 'LinkGroup', {fg = 'Blue'}) - meths._set_hl_ns(ns1) + meths.set_hl_ns(ns1) screen:expect{grid=[[ // just to see if there was an accident | @@ -302,7 +302,7 @@ describe('decorations providers', function() ]]} meths.set_hl(ns1, 'LinkGroup', {fg = 'Blue', default=true}) - meths._set_hl_ns(ns1) + meths.set_hl_ns(ns1) feed 'k' screen:expect{grid=[[ @@ -1681,7 +1681,7 @@ l5 screen:expect{grid=[[ S4S1^l1 | - S2x l2 | + x S2l2 | S5{1: }l3 | {1: }l4 | {1: }l5 | @@ -1779,6 +1779,34 @@ l5 ]]} end) + it('works with priority #19716', function() + screen:try_resize(20, 3) + insert(example_text) + feed 'gg' + + helpers.command('sign define Oldsign text=O3') + helpers.command([[exe 'sign place 42 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]]) + + meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S4', priority=100}) + meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S2', priority=5}) + meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S5', priority=200}) + meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S1', priority=1}) + + screen:expect{grid=[[ + S1S2O3S4S5^l1 | + {1: }l2 | + | + ]]} + + -- Check truncation works too + meths.win_set_option(0, 'signcolumn', 'auto') + + screen:expect{grid=[[ + S5^l1 | + {1: }l2 | + | + ]]} + end) end) describe('decorations: virt_text', function() diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index c79fc2989c..6bb8bb81c6 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -1904,4 +1904,11 @@ describe("folded lines", function() describe('without ext_multigrid', function() with_ext_multigrid(false) end) + + it('no folds remains if :delete makes buffer empty #19671', function() + funcs.setline(1, {'foo', 'bar', 'baz'}) + command('2,3fold') + command('%delete') + eq(0, funcs.foldlevel(1)) + end) end) diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 946129b082..c5f882a831 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -3,9 +3,10 @@ local Screen = require('test.functional.ui.screen') local os = require('os') local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert local command, exec = helpers.command, helpers.exec -local eval, exc_exec = helpers.eval, helpers.exc_exec +local eval = helpers.eval local feed_command, eq = helpers.feed_command, helpers.eq local curbufmeths = helpers.curbufmeths +local meths = helpers.meths describe('colorscheme compatibility', function() before_each(function() @@ -92,16 +93,22 @@ describe('highlight defaults', function() before_each(function() clear() screen = Screen.new() + screen:set_default_attr_ids { + [0] = {bold=true, foreground=Screen.colors.Blue}; + [1] = {reverse = true, bold = true}; + [2] = {reverse = true}; + [3] = {bold = true}; + [4] = {bold = true, foreground = Screen.colors.SeaGreen}; + [5] = {foreground = Screen.colors.Red1, background = Screen.colors.WebGreen}; + [6] = {background = Screen.colors.Red1, foreground = Screen.colors.Grey100}; + [7] = {foreground = Screen.colors.Red}; + [8] = {foreground = Screen.colors.Blue}; + [9] = {italic = true}; + } screen:attach() - command("set display-=msgsep") end) it('window status bar', function() - screen:set_default_attr_ids({ - [0] = {bold=true, foreground=Screen.colors.Blue}, - [1] = {reverse = true, bold = true}, -- StatusLine - [2] = {reverse = true} -- StatusLineNC - }) feed_command('sp', 'vsp', 'vsp') screen:expect([[ ^ │ │ | @@ -200,31 +207,29 @@ describe('highlight defaults', function() ^ | {0:~ }| {0:~ }| - {1:-- INSERT --} | - ]], {[0] = {bold=true, foreground=Screen.colors.Blue}, - [1] = {bold = true}}) + {3:-- INSERT --} | + ]]) end) it('end of file markers', function() screen:try_resize(53, 4) screen:expect([[ ^ | - {1:~ }| - {1:~ }| + {0:~ }| + {0:~ }| | - ]], {[1] = {bold = true, foreground = Screen.colors.Blue}}) + ]]) end) it('"wait return" text', function() screen:try_resize(53, 4) feed(':ls<cr>') screen:expect([[ - {0:~ }| + {1: }| :ls | 1 %a "[No Name]" line 1 | - {1:Press ENTER or type command to continue}^ | - ]], {[0] = {bold=true, foreground=Screen.colors.Blue}, - [1] = {bold = true, foreground = Screen.colors.SeaGreen}}) + {4:Press ENTER or type command to continue}^ | + ]]) feed('<cr>') -- skip the "Press ENTER..." state or tests will hang end) @@ -237,8 +242,7 @@ describe('highlight defaults', function() {0:~ }| {0:~ }| -- INSERT -- | - ]], {[0] = {bold=true, foreground=Screen.colors.Blue}, - [1] = {bold=true}}) + ]]) feed('<esc>') feed_command('highlight CustomHLGroup guifg=red guibg=green') feed_command('highlight link ModeMsg CustomHLGroup') @@ -247,9 +251,8 @@ describe('highlight defaults', function() ^ | {0:~ }| {0:~ }| - {1:-- INSERT --} | - ]], {[0] = {bold=true, foreground=Screen.colors.Blue}, - [1] = {foreground = Screen.colors.Red, background = Screen.colors.Green}}) + {5:-- INSERT --} | + ]]) end) it('can be cleared by assigning NONE', function() @@ -258,14 +261,11 @@ describe('highlight defaults', function() feed_command('hi link TmpKeyword ErrorMsg') insert('neovim') screen:expect([[ - {1:neovi^m} | + {6:neovi^m} | {0:~ }| {0:~ }| | - ]], { - [0] = {bold=true, foreground=Screen.colors.Blue}, - [1] = {foreground = Screen.colors.White, background = Screen.colors.Red} - }) + ]]) feed_command("hi ErrorMsg term=NONE cterm=NONE ctermfg=NONE ctermbg=NONE" .. " gui=NONE guifg=NONE guibg=NONE guisp=NONE") screen:expect([[ @@ -273,7 +273,7 @@ describe('highlight defaults', function() {0:~ }| {0:~ }| | - ]], {[0] = {bold=true, foreground=Screen.colors.Blue}}) + ]]) end) it('linking updates window highlight immediately #16552', function() @@ -283,7 +283,7 @@ describe('highlight defaults', function() {0:~ }| {0:~ }| | - ]], {[0] = {bold=true, foreground=Screen.colors.Blue}}) + ]]) feed_command("hi NonTextAlt guifg=Red") feed_command("hi! link NonText NonTextAlt") screen:expect([[ @@ -305,56 +305,44 @@ describe('highlight defaults', function() feed_command('set listchars=space:.,tab:>-,trail:*,eol:¬ list') insert(' ne \t o\tv im ') screen:expect([[ - ne{0:.>----.}o{0:>-----}v{0:..}im{0:*^*¬} | - {0:~ }| - {0:~ }| + ne{7:.>----.}o{7:>-----}v{7:..}im{7:*^*¬} | + {7:~ }| + {7:~ }| | - ]], { - [0] = {foreground=Screen.colors.Red}, - [1] = {foreground=Screen.colors.Blue}, - }) + ]]) feed_command('highlight Whitespace gui=NONE guifg=#0000FF') screen:expect([[ - ne{1:.>----.}o{1:>-----}v{1:..}im{1:*^*}{0:¬} | - {0:~ }| - {0:~ }| + ne{8:.>----.}o{8:>-----}v{8:..}im{8:*^*}{7:¬} | + {7:~ }| + {7:~ }| :highlight Whitespace gui=NONE guifg=#0000FF | - ]], { - [0] = {foreground=Screen.colors.Red}, - [1] = {foreground=Screen.colors.Blue}, - }) + ]]) end) it('are sent to UIs', function() screen:try_resize(53, 4) - screen:set_default_attr_ids({ - [0] = {}, - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [2] = {bold = true, reverse = true}, - [3] = {italic=true} - }) screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| + {0:~ }| + {0:~ }| | - ]], hl_groups={EndOfBuffer=1, MsgSeparator=2}} + ]], hl_groups={EndOfBuffer=0, MsgSeparator=1}} command('highlight EndOfBuffer gui=italic') screen:expect{grid=[[ ^ | - {3:~ }| - {3:~ }| + {9:~ }| + {9:~ }| | - ]], hl_groups={EndOfBuffer=3, MsgSeparator=2}} + ]], hl_groups={EndOfBuffer=9, MsgSeparator=1}} command('highlight clear EndOfBuffer') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| + {0:~ }| + {0:~ }| | - ]], hl_groups={EndOfBuffer=1, MsgSeparator=2}} + ]], hl_groups={EndOfBuffer=0, MsgSeparator=1}} end) end) @@ -1788,6 +1776,7 @@ describe("'winhighlight' highlight", function() [26] = {background = Screen.colors.Red}, [27] = {background = Screen.colors.DarkBlue, bold = true, foreground = Screen.colors.Green1}, [28] = {bold = true, foreground = Screen.colors.Brown}, + [29] = {foreground = Screen.colors.Blue1, background = Screen.colors.Red, bold = true}; }) command("hi Background1 guibg=DarkBlue") command("hi Background2 guibg=DarkGreen") @@ -1821,7 +1810,7 @@ describe("'winhighlight' highlight", function() ]]) end) - it('handles invalid values', function() + it('handles undefined groups', function() command("set winhl=Normal:Background1") screen:expect([[ {1:^ }| @@ -1834,19 +1823,44 @@ describe("'winhighlight' highlight", function() | ]]) - eq('Vim(set):E474: Invalid argument: winhl=xxx:yyy', - exc_exec("set winhl=xxx:yyy")) - eq('Normal:Background1', eval('&winhl')) + command("set winhl=xxx:yyy") + eq('xxx:yyy', eval('&winhl')) screen:expect{grid=[[ - {1:^ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| | - ]], unchanged=true} + ]]} + end) + + it('can be changed to define different groups', function() + command("set winhl=EndOfBuffer:Background1") + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + command("set winhl=Normal:ErrorMsg") + screen:expect{grid=[[ + {15:^ }| + {29:~ }| + {29:~ }| + {29:~ }| + {29:~ }| + {29:~ }| + {29:~ }| + | + ]]} end) it('works local to the window', function() @@ -2271,4 +2285,191 @@ describe("'winhighlight' highlight", function() | ]]) end) + + + it("can override syntax groups", function() + command('syntax on') + command('syntax keyword Foobar foobar') + command('syntax keyword Article the') + command('hi Foobar guibg=#FF0000') + command('hi Article guifg=#00FF00 gui=bold') + insert('the foobar was foobar') + screen:expect([[ + {25:the} {26:foobar} was {26:fooba}| + {26:^r} | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + + command('split') + command('set winhl=Foobar:Background1,Article:ErrorMsg') + screen:expect{grid=[[ + {15:the} {1:foobar} was {1:fooba}| + {1:^r} | + {0:~ }| + {3:[No Name] [+] }| + {25:the} {26:foobar} was {26:fooba}| + {26:r} | + {4:[No Name] [+] }| + | + ]]} + end) + + it('can be disabled in newly opened window #19823', function() + command('split | set winhl=Normal:ErrorMsg | set winhl=') + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }| + {3:[No Name] }| + | + {0:~ }| + {4:[No Name] }| + | + ]]} + + helpers.assert_alive() + end) +end) + +describe('highlight namespaces', function() + local screen + local ns1, ns2 + + before_each(function() + clear() + screen = Screen.new(25,10) + screen:attach() + screen:set_default_attr_ids { + [1] = {foreground = Screen.colors.Blue, bold = true}; + [2] = {background = Screen.colors.DarkGrey}; + [3] = {italic = true, foreground = Screen.colors.DarkCyan, background = Screen.colors.DarkOrange4}; + [4] = {background = Screen.colors.Magenta4}; + [5] = {background = Screen.colors.Magenta4, foreground = Screen.colors.Crimson}; + [6] = {bold = true, reverse = true}; + [7] = {reverse = true}; + [8] = {foreground = Screen.colors.Gray20}; + } + + ns1 = meths.create_namespace 'grungy' + ns2 = meths.create_namespace 'ultrared' + + meths.set_hl(ns1, 'Normal', {bg='DarkGrey'}) + meths.set_hl(ns1, 'NonText', {bg='DarkOrange4', fg='DarkCyan', italic=true}) + meths.set_hl(ns2, 'Normal', {bg='DarkMagenta'}) + meths.set_hl(ns2, 'NonText', {fg='Crimson'}) + end) + + it('can be used globally', function() + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + meths.set_hl_ns(ns1) + screen:expect{grid=[[ + {2:^ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + | + ]]} + + meths.set_hl_ns(ns2) + screen:expect{grid=[[ + {4:^ }| + {5:~ }| + {5:~ }| + {5:~ }| + {5:~ }| + {5:~ }| + {5:~ }| + {5:~ }| + {5:~ }| + | + ]]} + + meths.set_hl_ns(0) + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + + it('can be used per window', function() + local win1 = meths.get_current_win() + command 'split' + local win2 = meths.get_current_win() + command 'split' + + meths.win_set_hl_ns(win1, ns1) + meths.win_set_hl_ns(win2, ns2) + + screen:expect{grid=[[ + ^ | + {1:~ }| + {6:[No Name] }| + {4: }| + {5:~ }| + {7:[No Name] }| + {2: }| + {3:~ }| + {7:[No Name] }| + | + ]]} + end) + + it('redraws correctly when ns=0', function() + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + meths.set_hl(0, 'EndOfBuffer', {fg='#333333'}) + screen:expect{grid=[[ + ^ | + {8:~ }| + {8:~ }| + {8:~ }| + {8:~ }| + {8:~ }| + {8:~ }| + {8:~ }| + {8:~ }| + | + ]]} + end) end) diff --git a/test/functional/ui/hlstate_spec.lua b/test/functional/ui/hlstate_spec.lua index df7f34aa7f..dc74d6d401 100644 --- a/test/functional/ui/hlstate_spec.lua +++ b/test/functional/ui/hlstate_spec.lua @@ -119,13 +119,15 @@ describe('ext_hlstate detailed highlights', function() [3] = {{bold = true, reverse = true}, {{hi_name = "StatusLine", ui_name = "StatusLine", kind = "ui"}}}, [4] = {{reverse = true}, {{hi_name = "StatusLineNC", ui_name = "StatusLineNC", kind = "ui"}}}, [5] = {{background = Screen.colors.Red, foreground = Screen.colors.Grey100}, {{hi_name = "ErrorMsg", ui_name = "LineNr", kind = "ui"}}}, - [6] = {{bold = true, reverse = true}, {{hi_name = "MsgSeparator", ui_name = "Normal", kind = "ui"}}}, + [6] = {{bold = true, reverse = true}, {{hi_name = "Normal", ui_name = "Normal", kind = "ui"}}}, [7] = {{foreground = Screen.colors.Brown, bold = true, reverse = true}, {6, 1}}, - [8] = {{foreground = Screen.colors.Blue1, bold = true, reverse = true}, {6, 2}}, - [9] = {{bold = true, foreground = Screen.colors.Brown}, {{hi_name = "Statement", ui_name = "NormalNC", kind = "ui"}}}, + [8] = {{foreground = Screen.colors.Blue1, bold = true, reverse = true}, {6, 14}}, + [9] = {{bold = true, foreground = Screen.colors.Brown}, {{hi_name = "NormalNC", ui_name = "NormalNC", kind = "ui"}}}, [10] = {{bold = true, foreground = Screen.colors.Brown}, {9, 1}}, - [11] = {{bold = true, foreground = Screen.colors.Blue1}, {9, 2}}, + [11] = {{bold = true, foreground = Screen.colors.Blue1}, {9, 14}}, [12] = {{}, {{hi_name = "MsgArea", ui_name = "MsgArea", kind = "ui"}}}, + [13] = {{background = Screen.colors.Red1, foreground = Screen.colors.Gray100}, {{ui_name = "LineNr", kind = "ui", hi_name = "LineNr"}}}; + [14] = {{bold = true, foreground = Screen.colors.Blue}, {{ui_name = "EndOfBuffer", kind = "ui", hi_name = "EndOfBuffer"}}}; }) command("set number") @@ -143,16 +145,16 @@ describe('ext_hlstate detailed highlights', function() ]]) command("set winhl=LineNr:ErrorMsg") - screen:expect([[ - {5: 1 }^ | - {2:~ }| - {2:~ }| + screen:expect{grid=[[ + {13: 1 }^ | + {14:~ }| + {14:~ }| {3:[No Name] }| {1: 1 } | {2:~ }| {4:[No Name] }| {12: }| - ]]) + ]]} command("set winhl=Normal:MsgSeparator,NormalNC:Statement") screen:expect([[ diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index d8dd546a8d..9ca4673efe 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -66,7 +66,6 @@ local function common_setup(screen, inccommand, text) command("syntax on") command("set nohlsearch") command("hi Substitute guifg=red guibg=yellow") - command("set display-=msgsep") screen:attach() screen:set_default_attr_ids({ [1] = {foreground = Screen.colors.Fuchsia}, @@ -142,11 +141,11 @@ describe(":substitute, 'inccommand' preserves", function() feed_command("ls") screen:expect([[ + BAC | {15:~ }| {15:~ }| {15:~ }| - {15:~ }| - {15:~ }| + {11: }| :ls | 1 %a + "[No Name]" | line 1 | @@ -1469,14 +1468,14 @@ describe("inccommand=nosplit", function() -- non-modifier prefix feed(':silent tabedit %s/tw/to') screen:expect([[ + Inc substitution on | two lines | Inc substitution on | two lines | | {15:~ }| {15:~ }| - {15:~ }| - {15:~ }| + {11: }| :silent tabedit %s/t| w/to^ | ]]) @@ -2656,6 +2655,7 @@ describe(":substitute", function() feed("\\rѫ ab \\rXXXX") screen:expect([[ + 7 8 9 | K L M | {12:JLKR £} | {12:ѫ ab } | @@ -2667,8 +2667,7 @@ describe(":substitute", function() {12:ѫ ab } | {11:[No Name] [+] }| | 7| {12:JLKR £} | - | 8|{12: ѫ ab } | - {10:[Preview] }| + {11: }| :%s/[a-z]/JLKR £\rѫ ab \rXXX| X^ | ]]) @@ -3001,8 +3000,8 @@ it('long :%s/ with inccommand does not collapse cmdline', function() feed(':%s/AAAAAAA', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A') screen:expect([[ - {15:~ }| - {15:~ }| + | + {11: }| :%s/AAAAAAAA| AAAAAAAAAAAA| AAAAAAA^ | diff --git a/test/functional/ui/inccommand_user_spec.lua b/test/functional/ui/inccommand_user_spec.lua index b5816f6fe6..0b25d4f8d2 100644 --- a/test/functional/ui/inccommand_user_spec.lua +++ b/test/functional/ui/inccommand_user_spec.lua @@ -7,61 +7,82 @@ local feed = helpers.feed local command = helpers.command local assert_alive = helpers.assert_alive --- Implements a :Replace command that works like :substitute. +-- Implements a :Replace command that works like :substitute and has multibuffer support. local setup_replace_cmd = [[ - local function show_replace_preview(buf, use_preview_win, preview_ns, preview_buf, matches) + local function show_replace_preview(use_preview_win, preview_ns, preview_buf, matches) -- Find the width taken by the largest line number, used for padding the line numbers local highest_lnum = math.max(matches[#matches][1], 1) local highest_lnum_width = math.floor(math.log10(highest_lnum)) local preview_buf_line = 0 - - vim.g.prevns = preview_ns - vim.g.prevbuf = preview_buf + local multibuffer = #matches > 1 for _, match in ipairs(matches) do - local lnum = match[1] - local line_matches = match[2] - local prefix - - if use_preview_win then - prefix = string.format( - '|%s%d| ', - string.rep(' ', highest_lnum_width - math.floor(math.log10(lnum))), - lnum - ) + local buf = match[1] + local buf_matches = match[2] + + if multibuffer and #buf_matches > 0 and use_preview_win then + local bufname = vim.api.nvim_buf_get_name(buf) + + if bufname == "" then + bufname = string.format("Buffer #%d", buf) + end vim.api.nvim_buf_set_lines( preview_buf, preview_buf_line, preview_buf_line, 0, - { prefix .. vim.api.nvim_buf_get_lines(buf, lnum - 1, lnum, false)[1] } + { bufname .. ':' } ) + + preview_buf_line = preview_buf_line + 1 end - for _, line_match in ipairs(line_matches) do - vim.api.nvim_buf_add_highlight( - buf, - preview_ns, - 'Substitute', - lnum - 1, - line_match[1], - line_match[2] - ) + for _, buf_match in ipairs(buf_matches) do + local lnum = buf_match[1] + local line_matches = buf_match[2] + local prefix if use_preview_win then - vim.api.nvim_buf_add_highlight( + prefix = string.format( + '|%s%d| ', + string.rep(' ', highest_lnum_width - math.floor(math.log10(lnum))), + lnum + ) + + vim.api.nvim_buf_set_lines( preview_buf, + preview_buf_line, + preview_buf_line, + 0, + { prefix .. vim.api.nvim_buf_get_lines(buf, lnum - 1, lnum, false)[1] } + ) + end + + for _, line_match in ipairs(line_matches) do + vim.api.nvim_buf_add_highlight( + buf, preview_ns, 'Substitute', - preview_buf_line, - #prefix + line_match[1], - #prefix + line_match[2] + lnum - 1, + line_match[1], + line_match[2] ) + + if use_preview_win then + vim.api.nvim_buf_add_highlight( + preview_buf, + preview_ns, + 'Substitute', + preview_buf_line, + #prefix + line_match[1], + #prefix + line_match[2] + ) + end end - end - preview_buf_line = preview_buf_line + 1 + preview_buf_line = preview_buf_line + 1 + end end if use_preview_win then @@ -72,94 +93,121 @@ local setup_replace_cmd = [[ end local function do_replace(opts, preview, preview_ns, preview_buf) - local pat1 = opts.fargs[1] or '' + local pat1 = opts.fargs[1] + + if not pat1 then return end + local pat2 = opts.fargs[2] or '' local line1 = opts.line1 local line2 = opts.line2 - - local buf = vim.api.nvim_get_current_buf() - local lines = vim.api.nvim_buf_get_lines(buf, line1 - 1, line2, 0) local matches = {} - for i, line in ipairs(lines) do - local startidx, endidx = 0, 0 - local line_matches = {} - local num = 1 + -- Get list of valid and listed buffers + local buffers = vim.tbl_filter( + function(buf) + if not (vim.api.nvim_buf_is_valid(buf) and vim.bo[buf].buflisted and buf ~= preview_buf) + then + return false + end - while startidx ~= -1 do - local match = vim.fn.matchstrpos(line, pat1, 0, num) - startidx, endidx = match[2], match[3] + -- Check if there's at least one window using the buffer + for _, win in ipairs(vim.api.nvim_tabpage_list_wins(0)) do + if vim.api.nvim_win_get_buf(win) == buf then + return true + end + end - if startidx ~= -1 then - line_matches[#line_matches+1] = { startidx, endidx } - end + return false + end, + vim.api.nvim_list_bufs() + ) - num = num + 1 - end + for _, buf in ipairs(buffers) do + local lines = vim.api.nvim_buf_get_lines(buf, line1 - 1, line2, false) + local buf_matches = {} - if #line_matches > 0 then - matches[#matches+1] = { line1 + i - 1, line_matches } - end - end + for i, line in ipairs(lines) do + local startidx, endidx = 0, 0 + local line_matches = {} + local num = 1 - local new_lines = {} + while startidx ~= -1 do + local match = vim.fn.matchstrpos(line, pat1, 0, num) + startidx, endidx = match[2], match[3] - for _, match in ipairs(matches) do - local lnum = match[1] - local line_matches = match[2] - local line = lines[lnum - line1 + 1] - local pat_width_differences = {} - - -- If previewing, only replace the text in current buffer if pat2 isn't empty - -- Otherwise, always replace the text - if pat2 ~= '' or not preview then - if preview then - for _, line_match in ipairs(line_matches) do - local startidx, endidx = unpack(line_match) - local pat_match = line:sub(startidx + 1, endidx) - - pat_width_differences[#pat_width_differences+1] = - #vim.fn.substitute(pat_match, pat1, pat2, 'g') - #pat_match + if startidx ~= -1 then + line_matches[#line_matches+1] = { startidx, endidx } end + + num = num + 1 end - new_lines[lnum] = vim.fn.substitute(line, pat1, pat2, 'g') + if #line_matches > 0 then + buf_matches[#buf_matches+1] = { line1 + i - 1, line_matches } + end end - -- Highlight the matches if previewing - if preview then - local idx_offset = 0 - for i, line_match in ipairs(line_matches) do - local startidx, endidx = unpack(line_match) - -- Starting index of replacement text - local repl_startidx = startidx + idx_offset - -- Ending index of the replacement text (if pat2 isn't empty) - local repl_endidx - - if pat2 ~= '' then - repl_endidx = endidx + idx_offset + pat_width_differences[i] - else - repl_endidx = endidx + idx_offset + local new_lines = {} + + for _, buf_match in ipairs(buf_matches) do + local lnum = buf_match[1] + local line_matches = buf_match[2] + local line = lines[lnum - line1 + 1] + local pat_width_differences = {} + + -- If previewing, only replace the text in current buffer if pat2 isn't empty + -- Otherwise, always replace the text + if pat2 ~= '' or not preview then + if preview then + for _, line_match in ipairs(line_matches) do + local startidx, endidx = unpack(line_match) + local pat_match = line:sub(startidx + 1, endidx) + + pat_width_differences[#pat_width_differences+1] = + #vim.fn.substitute(pat_match, pat1, pat2, 'g') - #pat_match + end end - if pat2 ~= '' then - idx_offset = idx_offset + pat_width_differences[i] - end + new_lines[lnum] = vim.fn.substitute(line, pat1, pat2, 'g') + end - line_matches[i] = { repl_startidx, repl_endidx } + -- Highlight the matches if previewing + if preview then + local idx_offset = 0 + for i, line_match in ipairs(line_matches) do + local startidx, endidx = unpack(line_match) + -- Starting index of replacement text + local repl_startidx = startidx + idx_offset + -- Ending index of the replacement text (if pat2 isn't empty) + local repl_endidx + + if pat2 ~= '' then + repl_endidx = endidx + idx_offset + pat_width_differences[i] + else + repl_endidx = endidx + idx_offset + end + + if pat2 ~= '' then + idx_offset = idx_offset + pat_width_differences[i] + end + + line_matches[i] = { repl_startidx, repl_endidx } + end end end - end - for lnum, line in pairs(new_lines) do - vim.api.nvim_buf_set_lines(buf, lnum - 1, lnum, false, { line }) + for lnum, line in pairs(new_lines) do + vim.api.nvim_buf_set_lines(buf, lnum - 1, lnum, false, { line }) + end + + matches[#matches+1] = { buf, buf_matches } end if preview then local lnum = vim.api.nvim_win_get_cursor(0)[1] -- Use preview window only if preview buffer is provided and range isn't just the current line local use_preview_win = (preview_buf ~= nil) and (line1 ~= lnum or line2 ~= lnum) - return show_replace_preview(buf, use_preview_win, preview_ns, preview_buf, matches) + return show_replace_preview(use_preview_win, preview_ns, preview_buf, matches) end end @@ -354,3 +402,120 @@ describe("'inccommand' for user commands", function() assert_alive() end) end) + +describe("'inccommand' with multiple buffers", function() + local screen + + before_each(function() + clear() + screen = Screen.new(40, 17) + screen:set_default_attr_ids({ + [1] = {background = Screen.colors.Yellow1}, + [2] = {foreground = Screen.colors.Blue1, bold = true}, + [3] = {reverse = true}, + [4] = {reverse = true, bold = true} + }) + screen:attach() + exec_lua(setup_replace_cmd) + command('set cmdwinheight=10') + insert[[ + foo bar baz + bar baz foo + baz foo bar + ]] + command('vsplit | enew') + insert[[ + bar baz foo + baz foo bar + foo bar baz + ]] + end) + + it('works', function() + command('set inccommand=nosplit') + feed(':Replace foo bar') + screen:expect([[ + bar baz {1:bar} │ {1:bar} bar baz | + baz {1:bar} bar │ bar baz {1:bar} | + {1:bar} bar baz │ baz {1:bar} bar | + │ | + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {4:[No Name] [+] }{3:[No Name] [+] }| + :Replace foo bar^ | + ]]) + feed('<CR>') + screen:expect([[ + bar baz bar │ bar bar baz | + baz bar bar │ bar baz bar | + bar bar baz │ baz bar bar | + ^ │ | + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {4:[No Name] [+] }{3:[No Name] [+] }| + :Replace foo bar | + ]]) + end) + + it('works with inccommand=split', function() + command('set inccommand=split') + feed(':Replace foo bar') + screen:expect([[ + bar baz {1:bar} │ {1:bar} bar baz | + baz {1:bar} bar │ bar baz {1:bar} | + {1:bar} bar baz │ baz {1:bar} bar | + │ | + {4:[No Name] [+] }{3:[No Name] [+] }| + Buffer #1: | + |1| {1:bar} bar baz | + |2| bar baz {1:bar} | + |3| baz {1:bar} bar | + Buffer #2: | + |1| bar baz {1:bar} | + |2| baz {1:bar} bar | + |3| {1:bar} bar baz | + | + {2:~ }| + {3:[Preview] }| + :Replace foo bar^ | + ]]) + feed('<CR>') + screen:expect([[ + bar baz bar │ bar bar baz | + baz bar bar │ bar baz bar | + bar bar baz │ baz bar bar | + ^ │ | + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {2:~ }│{2:~ }| + {4:[No Name] [+] }{3:[No Name] [+] }| + :Replace foo bar | + ]]) + end) +end) diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua index 0f4e97088c..05d55b94fb 100644 --- a/test/functional/ui/input_spec.lua +++ b/test/functional/ui/input_spec.lua @@ -321,13 +321,14 @@ describe('input non-printable chars', function() it("doesn't crash when echoing them back", function() write_file("Xtest-overwrite", [[foobar]]) local screen = Screen.new(60,8) - screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [3] = {bold = true, foreground = Screen.colors.SeaGreen4} - }) + screen:set_default_attr_ids { + [1] = {bold = true, foreground = Screen.colors.Blue1}; + [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}; + [3] = {bold = true, foreground = Screen.colors.SeaGreen4}; + [4] = {bold = true, reverse = true}; + } screen:attach() - command("set display-=msgsep shortmess-=F") + command("set shortmess-=F") feed_command("e Xtest-overwrite") screen:expect([[ @@ -346,11 +347,11 @@ describe('input non-printable chars', function() write_file("Xtest-overwrite", [[smurf]]) feed_command("w") screen:expect([[ + foobar | {1:~ }| {1:~ }| {1:~ }| - {1:~ }| - {1:~ }| + {4: }| "Xtest-overwrite" | {2:WARNING: The file has been changed since reading it!!!} | {3:Do you really want to write to it (y/n)?}^ | @@ -358,10 +359,10 @@ describe('input non-printable chars', function() feed("u") screen:expect([[ + foobar | {1:~ }| {1:~ }| - {1:~ }| - {1:~ }| + {4: }| "Xtest-overwrite" | {2:WARNING: The file has been changed since reading it!!!} | {3:Do you really want to write to it (y/n)?}u | @@ -370,9 +371,9 @@ describe('input non-printable chars', function() feed("\005") screen:expect([[ + foobar | {1:~ }| - {1:~ }| - {1:~ }| + {4: }| "Xtest-overwrite" | {2:WARNING: The file has been changed since reading it!!!} | {3:Do you really want to write to it (y/n)?}u | @@ -382,8 +383,8 @@ describe('input non-printable chars', function() feed("n") screen:expect([[ - {1:~ }| - {1:~ }| + foobar | + {4: }| "Xtest-overwrite" | {2:WARNING: The file has been changed since reading it!!!} | {3:Do you really want to write to it (y/n)?}u | diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index e7eaedba2d..2cff7c1cf4 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1243,6 +1243,19 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim | ]]) end) + + it('echo messages are shown correctly when getchar() immediately follows', function() + feed([[:echo 'foo' | echo 'bar' | call getchar()<CR>]]) + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {3: }| + foo | + bar^ | + ]]) + end) end) describe('ui/ext_messages', function() diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua index e389b7ab89..9896b11218 100644 --- a/test/functional/ui/mouse_spec.lua +++ b/test/functional/ui/mouse_spec.lua @@ -32,7 +32,7 @@ describe('ui/mouse/input', function() [6] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, [7] = {bold = true, foreground = Screen.colors.SeaGreen4}, }) - command("set display-=msgsep mousemodel=extend") + command("set mousemodel=extend") feed('itesting<cr>mouse<cr>support and selection<esc>') screen:expect([[ testing | diff --git a/test/functional/ui/output_spec.lua b/test/functional/ui/output_spec.lua index 71c6410013..9bb067ed8e 100644 --- a/test/functional/ui/output_spec.lua +++ b/test/functional/ui/output_spec.lua @@ -100,45 +100,52 @@ describe("shell command :!", function() pending('missing printf') end local screen = Screen.new(50, 4) + screen:set_default_attr_ids { + [1] = {bold = true, reverse = true}; + [2] = {bold = true, foreground = Screen.colors.SeaGreen}; + [3] = {foreground = Screen.colors.Blue}; + } screen:attach() - command("set display-=msgsep") -- Print TAB chars. #2958 feed([[:!printf '1\t2\t3'<CR>]]) - screen:expect([[ - ~ | + screen:expect{grid=[[ + {1: }| :!printf '1\t2\t3' | 1 2 3 | - Press ENTER or type command to continue^ | - ]]) + {2:Press ENTER or type command to continue}^ | + ]]} feed([[<CR>]]) + -- Print BELL control code. #4338 screen.bell = false feed([[:!printf '\007\007\007\007text'<CR>]]) screen:expect{grid=[[ - ~ | + {1: }| :!printf '\007\007\007\007text' | text | - Press ENTER or type command to continue^ | + {2:Press ENTER or type command to continue}^ | ]], condition=function() eq(true, screen.bell) end} feed([[<CR>]]) + -- Print BS control code. feed([[:echo system('printf ''\010\n''')<CR>]]) screen:expect([[ - ~ | - ^H | + {1: }| + {3:^H} | | - Press ENTER or type command to continue^ | + {2:Press ENTER or type command to continue}^ | ]]) feed([[<CR>]]) + -- Print LF control code. feed([[:!printf '\n'<CR>]]) screen:expect([[ :!printf '\n' | | | - Press ENTER or type command to continue^ | + {2:Press ENTER or type command to continue}^ | ]]) feed([[<CR>]]) end) diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index ea98705394..6ee9e7b393 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -546,7 +546,7 @@ function Screen:_wait(check, flags) return true end - run_session(self._session, flags.request_cb, notification_cb, nil, minimal_timeout) + local eof = run_session(self._session, flags.request_cb, notification_cb, nil, minimal_timeout) if not did_flush then err = "no flush received" elseif not checked then @@ -557,9 +557,9 @@ function Screen:_wait(check, flags) end end - if not success_seen then + if not success_seen and not eof then did_miminal_timeout = true - run_session(self._session, flags.request_cb, notification_cb, nil, timeout-minimal_timeout) + eof = run_session(self._session, flags.request_cb, notification_cb, nil, timeout-minimal_timeout) end local did_warn = false @@ -600,8 +600,10 @@ between asynchronous (feed(), nvim_input()) and synchronous API calls. if err then + if eof then err = err..'\n\n'..eof[2] end busted.fail(err, 3) elseif did_warn then + if eof then print(eof[2]) end local tb = debug.traceback() local index = string.find(tb, '\n%s*%[C]') print(string.sub(tb,1,index)) diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua index f3735c8e4c..add5144e1b 100644 --- a/test/functional/ui/statusline_spec.lua +++ b/test/functional/ui/statusline_spec.lua @@ -394,7 +394,7 @@ describe('global statusline', function() meths.input_mouse('left', 'drag', '', 0, 14, 10) eq(1, meths.get_option('cmdheight')) meths.input_mouse('left', 'drag', '', 0, 15, 10) - eq(0, meths.get_option('cmdheight')) + eq(1, meths.get_option('cmdheight')) meths.input_mouse('left', 'drag', '', 0, 14, 10) eq(1, meths.get_option('cmdheight')) end) diff --git a/test/functional/ui/winbar_spec.lua b/test/functional/ui/winbar_spec.lua index 60fa10da87..8976c4371f 100644 --- a/test/functional/ui/winbar_spec.lua +++ b/test/functional/ui/winbar_spec.lua @@ -579,47 +579,95 @@ describe('winbar', function() end) end) -it('local winbar works with tabs', function() - clear() - local screen = Screen.new(60, 13) - screen:attach() - screen:set_default_attr_ids({ - [1] = {bold = true}, - [2] = {reverse = true}, - [3] = {bold = true, foreground = Screen.colors.Blue}, - [4] = {underline = true, background = Screen.colors.LightGray} - }) - meths.set_option_value('winbar', 'foo', { scope = 'local', win = 0 }) - command('tabnew') - screen:expect([[ - {4: [No Name] }{1: [No Name] }{2: }{4:X}| - ^ | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - | - ]]) - command('tabnext') - screen:expect{grid=[[ - {1: [No Name] }{4: [No Name] }{2: }{4:X}| - {1:foo }| - ^ | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - | - ]]} +describe('local winbar with tabs', function() + local screen + before_each(function() + clear() + screen = Screen.new(60, 10) + screen:attach() + screen:set_default_attr_ids({ + [1] = {bold = true}, + [2] = {reverse = true}, + [3] = {bold = true, foreground = Screen.colors.Blue}, + [4] = {underline = true, background = Screen.colors.LightGray} + }) + meths.set_option_value('winbar', 'foo', { scope = 'local', win = 0 }) + end) + + it('works', function() + command('tabnew') + screen:expect([[ + {4: [No Name] }{1: [No Name] }{2: }{4:X}| + ^ | + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + | + ]]) + command('tabnext') + screen:expect{grid=[[ + {1: [No Name] }{4: [No Name] }{2: }{4:X}| + {1:foo }| + ^ | + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + | + ]]} + end) + + it('can edit new empty buffer #19458', function() + insert [[ + some + goofy + text]] + screen:expect{grid=[[ + {1:foo }| + some | + goofy | + tex^t | + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + | + ]]} + + -- this used to throw an E315 ml_get error + command 'tabedit' + screen:expect{grid=[[ + {4: + [No Name] }{1: [No Name] }{2: }{4:X}| + ^ | + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + | + ]]} + + command 'tabprev' + screen:expect{grid=[[ + {1: + [No Name] }{4: [No Name] }{2: }{4:X}| + {1:foo }| + some | + goofy | + tex^t | + {3:~ }| + {3:~ }| + {3:~ }| + {3:~ }| + | + ]]} + end) end) |