diff options
Diffstat (limited to 'test/functional/ui')
-rw-r--r-- | test/functional/ui/decorations_spec.lua | 208 | ||||
-rw-r--r-- | test/functional/ui/highlight_spec.lua | 8 | ||||
-rw-r--r-- | test/functional/ui/inccommand_user_spec.lua | 34 | ||||
-rw-r--r-- | test/functional/ui/searchhl_spec.lua | 30 | ||||
-rw-r--r-- | test/functional/ui/statuscolumn_spec.lua | 15 |
5 files changed, 277 insertions, 18 deletions
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index b9080cbcf5..54441984a3 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -8,6 +8,7 @@ local exec_lua = helpers.exec_lua local exec = helpers.exec local expect_events = helpers.expect_events local meths = helpers.meths +local funcs = helpers.funcs local curbufmeths = helpers.curbufmeths local command = helpers.command local assert_alive = helpers.assert_alive @@ -651,7 +652,7 @@ describe('extmark decorations', function() [16] = {blend = 30, background = Screen.colors.Red1, foreground = Screen.colors.Magenta1}; [17] = {bold = true, foreground = Screen.colors.Brown, background = Screen.colors.LightGrey}; [18] = {background = Screen.colors.LightGrey}; - [19] = {foreground = Screen.colors.Cyan4, background = Screen.colors.LightGrey}; + [19] = {foreground = Screen.colors.DarkCyan, background = Screen.colors.LightGrey}; [20] = {foreground = tonumber('0x180606'), background = tonumber('0xf13f3f')}; [21] = {foreground = Screen.colors.Gray0, background = tonumber('0xf13f3f')}; [22] = {foreground = tonumber('0xb20000'), background = tonumber('0xf13f3f')}; @@ -662,6 +663,9 @@ describe('extmark decorations', function() [27] = {background = Screen.colors.Plum1}; [28] = {underline = true, foreground = Screen.colors.SlateBlue}; [29] = {foreground = Screen.colors.SlateBlue, background = Screen.colors.LightGray, underline = true}; + [30] = {foreground = Screen.colors.DarkCyan, background = Screen.colors.LightGray, underline = true}; + [31] = {underline = true, foreground = Screen.colors.DarkCyan}; + [32] = {underline = true}; } ns = meths.create_namespace 'test' @@ -827,26 +831,62 @@ describe('extmark decorations', function() end -- ?古古古古?古古 | | ]]} + end) - screen:try_resize(50, 2) + it('virt_text_hide hides overlay virtual text when extmark is off-screen', function() + screen:try_resize(50, 3) command('set nowrap') - meths.buf_set_lines(0, 12, 12, true, {'-- ' .. ('…'):rep(57)}) - feed('G') - meths.buf_set_extmark(0, ns, 12, 123, { virt_text={{'!!!!!', 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true}) + meths.buf_set_lines(0, 0, -1, true, {'-- ' .. ('…'):rep(57)}) + meths.buf_set_extmark(0, ns, 0, 0, { virt_text={{'?????', 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true}) + meths.buf_set_extmark(0, ns, 0, 123, { virt_text={{'!!!!!', 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true}) screen:expect{grid=[[ - ^-- …………………………………………………………………………………………………………{4:!!!!!}……| + {4:^?????}……………………………………………………………………………………………………{4:!!!!!}……| + {1:~ }| | ]]} feed('40zl') screen:expect{grid=[[ ^………{4:!!!!!}……………………………… | + {1:~ }| + | + ]]} + feed('3zl') + screen:expect{grid=[[ + {4:^!!!!!}……………………………… | + {1:~ }| + | + ]]} + feed('7zl') + screen:expect{grid=[[ + ^………………………… | + {1:~ }| | ]]} - feed('10zl') + + command('set wrap smoothscroll') screen:expect{grid=[[ + {4:?????}……………………………………………………………………………………………………{4:!!!!!}……| ^………………………… | | ]]} + feed('<C-E>') + screen:expect{grid=[[ + {1:<<<}………………^… | + {1:~ }| + | + ]]} + screen:try_resize(40, 3) + screen:expect{grid=[[ + {1:<<<}{4:!!!!!}……………………………^… | + {1:~ }| + | + ]]} + feed('<C-Y>') + screen:expect{grid=[[ + {4:?????}……………………………………………………………………………………………| + ………{4:!!!!!}……………………………^… | + | + ]]} end) it('can have virtual text of overlay position and styling', function() @@ -1338,7 +1378,56 @@ describe('extmark decorations', function() screen:expect_unchanged(true) end) - it('highlights the beginning of a TAB char correctly', function() + it('highlight is combined with syntax and sign linehl #20004', function() + screen:try_resize(50, 3) + insert([[ + function Func() + end]]) + feed('gg') + command('set ft=lua') + command('syntax on') + meths.buf_set_extmark(0, ns, 0, 0, { end_col = 3, hl_mode = 'combine', hl_group = 'Visual' }) + command('hi default MyLine gui=underline') + command('sign define CurrentLine linehl=MyLine') + funcs.sign_place(6, 'Test', 'CurrentLine', '', { lnum = 1 }) + screen:expect{grid=[[ + {30:^fun}{31:ction}{32: Func() }| + {6:end} | + | + ]]} + end) + + it('highlight works after TAB with sidescroll #14201', function() + screen:try_resize(50, 3) + command('set nowrap') + meths.buf_set_lines(0, 0, -1, true, {'\tword word word word'}) + meths.buf_set_extmark(0, ns, 0, 1, { end_col = 3, hl_group = 'ErrorMsg' }) + screen:expect{grid=[[ + ^ {4:wo}rd word word word | + {1:~ }| + | + ]]} + feed('7zl') + screen:expect{grid=[[ + {4:^wo}rd word word word | + {1:~ }| + | + ]]} + feed('zl') + screen:expect{grid=[[ + {4:^wo}rd word word word | + {1:~ }| + | + ]]} + feed('zl') + screen:expect{grid=[[ + {4:^o}rd word word word | + {1:~ }| + | + ]]} + end) + + it('highlights the beginning of a TAB char correctly #23734', function() screen:try_resize(50, 3) meths.buf_set_lines(0, 0, -1, true, {'this is the\ttab'}) meths.buf_set_extmark(0, ns, 0, 11, { end_col = 15, hl_group = 'ErrorMsg' }) @@ -1357,7 +1446,20 @@ describe('extmark decorations', function() ]]} end) - pending('highlight applies to a full Tab in visual block mode #23734', function() + it('highlight applies to a full TAB on line with matches #20885', function() + screen:try_resize(50, 3) + meths.buf_set_lines(0, 0, -1, true, {'\t-- match1', ' -- match2'}) + funcs.matchadd('Underlined', 'match') + meths.buf_set_extmark(0, ns, 0, 0, { end_row = 1, end_col = 0, hl_group = 'Visual' }) + meths.buf_set_extmark(0, ns, 1, 0, { end_row = 2, end_col = 0, hl_group = 'Visual' }) + screen:expect{grid=[[ + {18: ^ -- }{29:match}{18:1} | + {18: -- }{29:match}{18:2} | + | + ]]} + end) + + pending('highlight applies to a full TAB in visual block mode', function() screen:try_resize(50, 8) meths.buf_set_lines(0, 0, -1, true, {'asdf', '\tasdf', '\tasdf', '\tasdf', 'asdf'}) meths.buf_set_extmark(0, ns, 0, 0, {end_row = 5, end_col = 0, hl_group = 'Underlined'}) @@ -2125,34 +2227,55 @@ bbbbbbb]]) end) it('does not crash at column 0 when folded in a wide window', function() - screen:try_resize(82, 4) + screen:try_resize(82, 5) command('hi! CursorLine guibg=NONE guifg=Red gui=NONE') command('set cursorline') insert([[ aaaaa bbbbb + ccccc]]) meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'foo'}}, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 2, 0, { virt_text = {{'bar'}}, virt_text_pos = 'inline' }) screen:expect{grid=[[ fooaaaaa | bbbbb | + bar | {16:cccc^c }| | ]]} command('1,2fold') screen:expect{grid=[[ {17:+-- 2 lines: aaaaa·······························································}| + bar | {16:cccc^c }| {1:~ }| | ]]} - feed('k') + feed('2k') screen:expect{grid=[[ {18:^+-- 2 lines: aaaaa·······························································}| + bar | ccccc | {1:~ }| | ]]} + command('3,4fold') + screen:expect{grid=[[ + {18:^+-- 2 lines: aaaaa·······························································}| + {17:+-- 2 lines: ccccc·······························································}| + {1:~ }| + {1:~ }| + | + ]]} + feed('j') + screen:expect{grid=[[ + {17:+-- 2 lines: aaaaa·······························································}| + {18:^+-- 2 lines: ccccc·······························································}| + {1:~ }| + {1:~ }| + | + ]]} end) end) @@ -2164,7 +2287,7 @@ describe('decorations: virtual lines', function() screen:attach() screen:set_default_attr_ids { [1] = {bold=true, foreground=Screen.colors.Blue}; - [2] = {foreground = Screen.colors.Cyan4}; + [2] = {foreground = Screen.colors.DarkCyan}; [3] = {background = Screen.colors.Yellow1}; [4] = {bold = true}; [5] = {background = Screen.colors.Yellow, foreground = Screen.colors.Blue}; @@ -2883,6 +3006,30 @@ if (h->n_buckets < new_n_buckets) { // expand ]]} end) + it('does not show twice if end_row or end_col is specified #18622', function() + insert([[ + aaa + bbb + ccc + ddd]]) + meths.buf_set_extmark(0, ns, 0, 0, {end_row = 2, virt_lines = {{{'VIRT LINE 1', 'NonText'}}}}) + meths.buf_set_extmark(0, ns, 3, 0, {end_col = 2, virt_lines = {{{'VIRT LINE 2', 'NonText'}}}}) + screen:expect{grid=[[ + aaa | + {1:VIRT LINE 1} | + bbb | + ccc | + dd^d | + {1:VIRT LINE 2} | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + end) describe('decorations: signs', function() @@ -3195,8 +3342,8 @@ l5 insert(example_test3) feed 'gg' - helpers.command('sign define Oldsign text=O3') - helpers.command([[exe 'sign place 42 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]]) + command('sign define Oldsign text=O3') + 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}) @@ -3219,6 +3366,39 @@ l5 ]]} end) + it('does not overflow with many old signs #23852', function() + screen:try_resize(20, 3) + + command('set signcolumn:auto:9') + command('sign define Oldsign text=O3') + command([[exe 'sign place 01 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]]) + command([[exe 'sign place 02 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]]) + command([[exe 'sign place 03 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]]) + command([[exe 'sign place 04 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]]) + command([[exe 'sign place 05 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]]) + command([[exe 'sign place 06 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]]) + command([[exe 'sign place 07 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]]) + command([[exe 'sign place 08 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]]) + command([[exe 'sign place 09 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]]) + screen:expect{grid=[[ + O3O3O3O3O3O3O3O3O3^ | + {2:~ }| + | + ]]} + + meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S1', priority=1}) + screen:expect_unchanged() + + meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S5', priority=200}) + screen:expect{grid=[[ + O3O3O3O3O3O3O3O3S5^ | + {2:~ }| + | + ]]} + + assert_alive() + end) + it('does not set signcolumn for signs without text', function() screen:try_resize(20, 3) meths.set_option_value('signcolumn', 'auto', {}) diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 9a4be4573c..c68f4cf34c 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -426,7 +426,7 @@ describe('highlight', function() ^ | {2:~ }| | - ]],{ + ]], { [1] = {strikethrough = true}, [2] = {bold = true, foreground = Screen.colors.Blue1}, }) @@ -515,7 +515,7 @@ describe('highlight', function() {1:neovim} tabbed^ | {0:~ }| {5:-- INSERT --} | - ]],{ + ]], { [0] = {bold=true, foreground=Screen.colors.Blue}, [1] = {background = Screen.colors.Yellow, foreground = Screen.colors.Red, special = Screen.colors.Red}, @@ -527,7 +527,7 @@ describe('highlight', function() end) - it("'diff', syntax and extmark", function() + it("'diff', syntax and extmark #23722", function() local screen = Screen.new(25,10) screen:attach() exec([[ @@ -549,7 +549,7 @@ describe('highlight', function() {4:~ }| {8:[No Name] }| | - ]],{ + ]], { [0] = {Screen.colors.WebGray, foreground = Screen.colors.DarkBlue}, [1] = {background = Screen.colors.Grey, foreground = Screen.colors.Blue4}, [2] = {foreground = Screen.colors.Red, background = Screen.colors.LightBlue}, diff --git a/test/functional/ui/inccommand_user_spec.lua b/test/functional/ui/inccommand_user_spec.lua index 6329ece40a..9cc6e095c5 100644 --- a/test/functional/ui/inccommand_user_spec.lua +++ b/test/functional/ui/inccommand_user_spec.lua @@ -401,6 +401,40 @@ describe("'inccommand' for user commands", function() feed('e') assert_alive() end) + + it('no crash when adding highlight after :substitute #21495', function() + command('set inccommand=nosplit') + exec_lua([[ + vim.api.nvim_create_user_command("Crash", function() end, { + preview = function(_, preview_ns, _) + vim.cmd("%s/text/cats/g") + vim.api.nvim_buf_add_highlight(0, preview_ns, "Search", 0, 0, -1) + return 1 + end, + }) + ]]) + feed(':C') + screen:expect([[ + {1: cats on line 1} | + more cats on line 2 | + oh no, even more cats | + will the cats ever stop | + oh well | + did the cats stop | + why won't it stop | + make the cats stop | + | + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + :C^ | + ]]) + assert_alive() + end) end) describe("'inccommand' with multiple buffers", function() diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua index 3c8dceb8cb..1e42689200 100644 --- a/test/functional/ui/searchhl_spec.lua +++ b/test/functional/ui/searchhl_spec.lua @@ -512,6 +512,36 @@ describe('search highlighting', function() {1:~ }│{1:~ }| /file^ | ]]) + feed('<Esc>') + + command('set rtp^=test/functional/fixtures') + -- incsearch works after c_CTRL-R inserts clipboard register + + command('let @* = "first"') + feed('/<C-R>*') + screen:expect([[ + the {3:first} line │the {2:first} line | + in a little file │in a little file | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + /first^ | + ]]) + feed('<Esc>') + + command('let @+ = "little"') + feed('/<C-R>+') + screen:expect([[ + the first line │the first line | + in a {3:little} file │in a {2:little} file | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + /little^ | + ]]) + feed('<Esc>') end) it('works with incsearch and offset', function() diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index c218bd8fd6..6624fb008d 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -424,6 +424,21 @@ describe('statuscolumn', function() ]]) end) + it('does not corrupt the screen with minwid sign item', function() + screen:try_resize(screen._width, 3) + screen:set_default_attr_ids({ + [0] = {foreground = Screen.colors.Brown}, + [1] = {foreground = Screen.colors.Blue4, background = Screen.colors.Gray}, + }) + command([[set stc=%6s\ %l]]) + exec_lua('vim.api.nvim_buf_set_extmark(0, ns, 7, 0, {sign_text = "𒀀"})') + screen:expect([[ + {0: 𒀀 8}^aaaaa | + {0: }{1: }{0: 9}aaaaa | + | + ]]) + end) + for _, model in ipairs(mousemodels) do it("works with 'statuscolumn' clicks with mousemodel=" .. model, function() command('set mousemodel=' .. model) |