aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/decorations_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/ui/decorations_spec.lua')
-rw-r--r--test/functional/ui/decorations_spec.lua401
1 files changed, 265 insertions, 136 deletions
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index fbf16f3afe..7969dd5d3b 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -509,6 +509,69 @@ describe('decorations providers', function()
]]}
end)
+ it('can have virtual text of the style: eol_right_align', function()
+ insert(mulholland)
+ setup_provider [[
+ local hl = api.nvim_get_hl_id_by_name "ErrorMsg"
+ local test_ns = api.nvim_create_namespace "mulholland"
+ function on_do(event, ...)
+ if event == "line" then
+ local win, buf, line = ...
+ api.nvim_buf_set_extmark(buf, test_ns, line, 0, {
+ virt_text = {{'+'}, {'1234567890', 'ErrorMsg'}};
+ virt_text_pos='eol_right_align';
+ ephemeral = true;
+ })
+ end
+ end
+ ]]
+
+ screen:expect{grid=[[
+ // just to see if there was an accident |
+ // on Mulholland Drive +{2:1234567890}|
+ try_start(); +{2:1234567890}|
+ bufref_T save_buf; +{2:1234567890}|
+ switch_buffer(&save_buf, buf); +{2:12345678}|
+ posp = getmark(mark, false); +{2:1234567890}|
+ restore_buffer(&save_buf);^ +{2:1234567890}|
+ |
+ ]]}
+ end)
+
+ it('multiple eol_right_align', function()
+ insert(mulholland)
+ setup_provider [[
+ local hl = api.nvim_get_hl_id_by_name "ErrorMsg"
+ local test_ns = api.nvim_create_namespace "mulholland"
+ function on_do(event, ...)
+ if event == "line" then
+ local win, buf, line = ...
+ api.nvim_buf_set_extmark(buf, test_ns, line, 0, {
+ virt_text = {{'11111'}};
+ virt_text_pos='eol_right_align';
+ ephemeral = true;
+ })
+ api.nvim_buf_set_extmark(0, test_ns, line, 0, {
+ virt_text = {{'22222'}};
+ virt_text_pos='eol_right_align';
+ ephemeral = true;
+ })
+ end
+ end
+ ]]
+
+ screen:expect{grid=[[
+ // just to see if there was an accident |
+ // on Mulholland Drive 11111 22222|
+ try_start(); 11111 22222|
+ bufref_T save_buf; 11111 22222|
+ switch_buffer(&save_buf, buf); 11111 222|
+ posp = getmark(mark, false); 11111 22222|
+ restore_buffer(&save_buf);^ 11111 22222|
+ |
+ ]]}
+ end)
+
it('virtual text works with wrapped lines', function()
insert(mulholland)
feed('ggJj3JjJ')
@@ -631,7 +694,7 @@ describe('decorations providers', function()
{14: }hello97 |
{14: }hello98 |
{14: }hello99 |
- X ^hello100 |
+ {14:X }^hello100 |
{14: }hello101 |
{14: }hello102 |
{14: }hello103 |
@@ -744,6 +807,30 @@ describe('decorations providers', function()
]])
eq(2, exec_lua([[return _G.cnt]]))
end)
+
+ it('can do large changes to the marktree', function()
+ insert("line1 with a lot of text\nline2 with a lot of text")
+ setup_provider([[
+ function on_do(event, _, _, row)
+ if event == 'win' or (event == 'line' and row == 1) then
+ vim.api.nvim_buf_clear_namespace(0, ns1, 0, -1)
+ for i = 0,1 do
+ for j = 0,23 do
+ vim.api.nvim_buf_set_extmark(0, ns1, i, j, {hl_group='ErrorMsg', end_col = j+1})
+ end
+ end
+ end
+ end
+ ]])
+
+ -- Doesn't crash when modifying the marktree between line1 and line2
+ screen:expect([[
+ {2:line1 with a lot of text} |
+ {2:line2 with a lot of tex^t} |
+ {1:~ }|*5
+ |
+ ]])
+ end)
end)
local example_text = [[
@@ -810,6 +897,9 @@ describe('extmark decorations', function()
[42] = {undercurl = true, special = Screen.colors.Red};
[43] = {background = Screen.colors.Yellow, undercurl = true, special = Screen.colors.Red};
[44] = {background = Screen.colors.LightMagenta};
+ [45] = { background = Screen.colors.Red, special = Screen.colors.Red, foreground = Screen.colors.Red };
+ [46] = { background = Screen.colors.Blue, foreground = Screen.colors.Blue, special = Screen.colors.Red };
+ [47] = { background = Screen.colors.Green, foreground = Screen.colors.Blue, special = Screen.colors.Red };
}
ns = api.nvim_create_namespace 'test'
@@ -1900,6 +1990,46 @@ describe('extmark decorations', function()
]]}
end)
+ it('highlight can combine multiple groups', function()
+ screen:try_resize(50, 3)
+ command('hi Group1 guibg=Red guifg=Red guisp=Red')
+ command('hi Group2 guibg=Blue guifg=Blue')
+ command('hi Group3 guibg=Green')
+ insert([[example text]])
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { end_row=1, hl_group = {} })
+ screen:expect([[
+ example tex^t |
+ {1:~ }|
+ |
+ ]])
+
+ api.nvim_buf_clear_namespace(0, ns, 0, -1)
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { end_row=1, hl_group = {'Group1'} })
+ screen:expect([[
+ {45:example tex^t} |
+ {1:~ }|
+ |
+ ]])
+ api.nvim_buf_clear_namespace(0, ns, 0, -1)
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { end_row = 1, hl_group = {'Group1', 'Group2'} })
+ screen:expect([[
+ {46:example tex^t} |
+ {1:~ }|
+ |
+ ]])
+ api.nvim_buf_clear_namespace(0, ns, 0, -1)
+ api.nvim_buf_set_extmark(0, ns, 0, 0, { end_row = 1, hl_group = {'Group1', 'Group2', 'Group3'}, hl_eol=true })
+ screen:expect([[
+ {47:example tex^t }|
+ {1:~ }|
+ |
+ ]])
+
+ eq('Invalid hl_group: hl_group item',
+ pcall_err(api.nvim_buf_set_extmark, 0, ns, 0, 0, { end_row = 1, hl_group = {'Group1', 'Group2', {'fail'}}, hl_eol=true }))
+ end)
+
+
it('highlight works after TAB with sidescroll #14201', function()
screen:try_resize(50, 3)
command('set nowrap')
@@ -2301,13 +2431,16 @@ describe('extmark decorations', function()
it('works with both hl_group and sign_hl_group', function()
screen:try_resize(50, 3)
+ screen:add_extra_attr_ids({
+ [100] = { background = Screen.colors.WebGray, foreground = Screen.colors.Blue, bold = true },
+ })
insert('abcdefghijklmn')
api.nvim_buf_set_extmark(0, ns, 0, 0, {sign_text='S', sign_hl_group='NonText', hl_group='Error', end_col=14})
- screen:expect{grid=[[
- {1:S }{4:abcdefghijklm^n} |
+ screen:expect([[
+ {100:S }{9:abcdefghijklm^n} |
{1:~ }|
|
- ]]}
+ ]])
end)
it('virt_text_repeat_linebreak repeats virtual text on wrapped lines', function()
@@ -5064,16 +5197,16 @@ l5
api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S'})
- screen:expect{grid=[[
+ screen:expect([[
{7: }^l1 |
- S l2 |
+ {7:S }l2 |
{7: }l3 |
{7: }l4 |
{7: }l5 |
{7: } |
{1:~ }|*3
|
- ]]}
+ ]])
end)
it('can add a single sign (with end row)', function()
@@ -5082,16 +5215,16 @@ l5
api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S', end_row=1})
- screen:expect{grid=[[
+ screen:expect([[
{7: }^l1 |
- S l2 |
+ {7:S }l2 |
{7: }l3 |
{7: }l4 |
{7: }l5 |
{7: } |
{1:~ }|*3
|
- ]]}
+ ]])
end)
it('can add a single sign and text highlight', function()
@@ -5099,16 +5232,16 @@ l5
feed 'gg'
api.nvim_buf_set_extmark(0, ns, 1, 0, {sign_text='S', hl_group='Todo', end_col=1})
- screen:expect{grid=[[
+ screen:expect([[
{7: }^l1 |
- S {100:l}2 |
+ {7:S }{100:l}2 |
{7: }l3 |
{7: }l4 |
{7: }l5 |
{7: } |
{1:~ }|*3
|
- ]]}
+ ]])
api.nvim_buf_clear_namespace(0, ns, 0, -1)
end)
@@ -5119,16 +5252,16 @@ l5
api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S', end_row = 2})
- screen:expect{grid=[[
+ screen:expect([[
{7: }^l1 |
- S l2 |
- S l3 |
+ {7:S }l2 |
+ {7:S }l3 |
{7: }l4 |
{7: }l5 |
{7: } |
{1:~ }|*3
|
- ]]}
+ ]])
end)
it('can add multiple signs (multiple extmarks)', function()
@@ -5138,16 +5271,16 @@ l5
api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S1'})
api.nvim_buf_set_extmark(0, ns, 3, -1, {sign_text='S2', end_row = 4})
- screen:expect{grid=[[
+ screen:expect([[
{7: }^l1 |
- S1l2 |
+ {7:S1}l2 |
{7: }l3 |
- S2l4 |
- S2l5 |
+ {7:S2}l4 |
+ {7:S2}l5 |
{7: } |
{1:~ }|*3
|
- ]]}
+ ]])
end)
it('can add multiple signs (multiple extmarks) 2', function()
@@ -5156,16 +5289,16 @@ l5
api.nvim_buf_set_extmark(0, ns, 3, -1, {sign_text='S1'})
api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S2', end_row = 3})
- screen:expect{grid=[[
+ screen:expect([[
{7: }^l1 |
- S2{7: }l2 |
- S2{7: }l3 |
- S2S1l4 |
+ {7:S2 }l2 |
+ {7:S2 }l3 |
+ {7:S2S1}l4 |
{7: }l5 |
{7: } |
{1:~ }|*3
|
- ]]}
+ ]])
end)
it('can add multiple signs (multiple extmarks) 3', function()
@@ -5176,16 +5309,16 @@ l5
api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S1', end_row=2})
api.nvim_buf_set_extmark(0, ns, 2, -1, {sign_text='S2', end_row=3})
- screen:expect{grid=[[
+ screen:expect([[
{7: }^l1 |
- S1{7: }l2 |
- S2S1l3 |
- S2{7: }l4 |
+ {7:S1 }l2 |
+ {7:S2S1}l3 |
+ {7:S2 }l4 |
{7: }l5 |
{7: } |
{1:~ }|*3
|
- ]]}
+ ]])
end)
it('can add multiple signs (multiple extmarks) 4', function()
@@ -5195,16 +5328,16 @@ l5
api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1', end_row=0})
api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S2', end_row=1})
- screen:expect{grid=[[
- S1^l1 |
- S2l2 |
+ screen:expect([[
+ {7:S1}^l1 |
+ {7:S2}l2 |
{7: }l3 |
{7: }l4 |
{7: }l5 |
{7: } |
{1:~ }|*3
|
- ]]}
+ ]])
end)
it('works with old signs', function()
@@ -5219,16 +5352,16 @@ l5
api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S4'})
api.nvim_buf_set_extmark(0, ns, 2, -1, {sign_text='S5'})
- screen:expect{grid=[[
- S4S1^l1 |
- S2x l2 |
- S5{7: }l3 |
+ screen:expect([[
+ {7:S4S1}^l1 |
+ {7:S2x }l2 |
+ {7:S5 }l3 |
{7: }l4 |
{7: }l5 |
{7: } |
{1:~ }|*3
|
- ]]}
+ ]])
end)
it('works with old signs (with range)', function()
@@ -5244,16 +5377,16 @@ l5
api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S4'})
api.nvim_buf_set_extmark(0, ns, 2, -1, {sign_text='S5'})
- screen:expect{grid=[[
- S4S3S1^l1 |
- S3S2x l2 |
- S5S3{7: }l3 |
- S3{7: }l4 |
- S3{7: }l5 |
+ screen:expect([[
+ {7:S4S3S1}^l1 |
+ {7:S3S2x }l2 |
+ {7:S5S3 }l3 |
+ {7:S3 }l4 |
+ {7:S3 }l5 |
{7: } |
{1:~ }|*3
|
- ]]}
+ ]])
end)
it('can add a ranged sign (with start out of view)', function()
@@ -5264,14 +5397,14 @@ l5
api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='X', end_row=3})
- screen:expect{grid=[[
- X {7: }^l3 |
- X {7: }l4 |
+ screen:expect([[
+ {7:X }^l3 |
+ {7:X }l4 |
{7: }l5 |
{7: } |
{1:~ }|*5
|
- ]]}
+ ]])
end)
it('can add lots of signs', function()
@@ -5293,11 +5426,11 @@ l5
api.nvim_buf_set_extmark(0, ns, i, -1, { sign_text='Z' })
end
- screen:expect{grid=[[
- Z Y X W {100:a} {100:b} {100:c} {100:d} {100:e} {100:f} {100:g} {100:h} |*8
- Z Y X W {100:a} {100:b} {100:c} {100:d} {100:e} {100:f} {100:g} {100:^h} |
+ screen:expect([[
+ {7:Z Y X W }{100:a} {100:b} {100:c} {100:d} {100:e} {100:f} {100:g} {100:h} |*8
+ {7:Z Y X W }{100:a} {100:b} {100:c} {100:d} {100:e} {100:f} {100:g} {100:^h} |
|
- ]]}
+ ]])
end)
it('works with priority #19716', function()
@@ -5313,20 +5446,20 @@ l5
api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S5', priority=200})
api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1', priority=1})
- screen:expect{grid=[[
- S5S4O3S2S1^l1 |
+ screen:expect([[
+ {7:S5S4O3S2S1}^l1 |
{7: }l2 |
|
- ]]}
+ ]])
-- Check truncation works too
api.nvim_set_option_value('signcolumn', 'auto', {})
- screen:expect{grid=[[
- S5^l1 |
+ screen:expect([[
+ {7:S5}^l1 |
{7: }l2 |
|
- ]]}
+ ]])
end)
it('does not overflow with many old signs #23852', function()
@@ -5343,21 +5476,21 @@ l5
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^ |
+ screen:expect([[
+ {7:O3O3O3O3O3O3O3O3O3}^ |
{1:~ }|
|
- ]]}
+ ]])
api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1', priority=1})
screen:expect_unchanged()
api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S5', priority=200})
- screen:expect{grid=[[
- S5O3O3O3O3O3O3O3O3^ |
+ screen:expect([[
+ {7:S5O3O3O3O3O3O3O3O3}^ |
{1:~ }|
|
- ]]}
+ ]])
assert_alive()
end)
@@ -5383,12 +5516,12 @@ l5
api.nvim_buf_set_extmark(0, ns, 1, -1, {invalidate = true, sign_text='S3'})
feed('2Gdd')
- screen:expect{grid=[[
- S1l1 |
- S1^l3 |
- S1l4 |
+ screen:expect([[
+ {7:S1}l1 |
+ {7:S1}^l3 |
+ {7:S1}l4 |
|
- ]]}
+ ]])
end)
it('correct width with multiple overlapping signs', function()
@@ -5400,36 +5533,36 @@ l5
feed('gg')
local s1 = [[
- S2S1^l1 |
- S3S2l2 |
- S3S2l3 |
+ {7:S2S1}^l1 |
+ {7:S3S2}l2 |
+ {7:S3S2}l3 |
|
]]
- screen:expect{grid=s1}
+ screen:expect(s1)
-- Correct width when :move'ing a line with signs
command('move2')
- screen:expect{grid=[[
- S3{7: }l2 |
- S3S2S1^l1 |
+ screen:expect([[
+ {7:S3 }l2 |
+ {7:S3S2S1}^l1 |
{7: }l3 |
|
- ]]}
+ ]])
command('silent undo')
screen:expect{grid=s1}
command('d')
- screen:expect{grid=[[
- S3S2S1^l2 |
- S3S2{7: }l3 |
+ screen:expect([[
+ {7:S3S2S1}^l2 |
+ {7:S3S2 }l3 |
{7: }l4 |
|
- ]]}
+ ]])
command('d')
- screen:expect{grid=[[
- S3S2S1^l3 |
+ screen:expect([[
+ {7:S3S2S1}^l3 |
{7: }l4 |
{7: }l5 |
|
- ]]}
+ ]])
end)
it('correct width when adding and removing multiple signs', function()
@@ -5452,12 +5585,12 @@ l5
redraw!
call nvim_buf_del_extmark(0, ns, s1)
]])
- screen:expect{grid=[[
- S1^l1 |
- S1l2 |
- S1l3 |
+ screen:expect([[
+ {7:S1}^l1 |
+ {7:S1}l2 |
+ {7:S1}l3 |
|
- ]]}
+ ]])
end)
it('correct width when deleting lines', function()
@@ -5472,12 +5605,12 @@ l5
call nvim_buf_del_extmark(0, ns, s3)
norm 4Gdd
]])
- screen:expect{grid=[[
+ screen:expect([[
{7: }l3 |
- S2S1l5 |
+ {7:S2S1}l5 |
{7: }^ |
|
- ]]}
+ ]])
end)
it('correct width when splitting lines with signs on different columns', function()
@@ -5487,12 +5620,12 @@ l5
api.nvim_buf_set_extmark(0, ns, 0, 0, {sign_text='S1'})
api.nvim_buf_set_extmark(0, ns, 0, 1, {sign_text='S2'})
feed('a<cr><esc>')
- screen:expect{grid=[[
- S1l |
- S2^1 |
+ screen:expect([[
+ {7:S1}l |
+ {7:S2}^1 |
{7: }l2 |
|
- ]]}
+ ]])
end)
it('correct width after wiping a buffer', function()
@@ -5501,12 +5634,12 @@ l5
feed('gg')
local buf = api.nvim_get_current_buf()
api.nvim_buf_set_extmark(buf, ns, 0, 0, { sign_text = 'h' })
- screen:expect{grid=[[
- h ^l1 |
+ screen:expect([[
+ {7:h }^l1 |
{7: }l2 |
{7: }l3 |
|
- ]]}
+ ]])
api.nvim_win_set_buf(0, api.nvim_create_buf(false, true))
api.nvim_buf_delete(buf, {unload=true, force=true})
api.nvim_buf_set_lines(buf, 0, -1, false, {''})
@@ -5537,12 +5670,12 @@ l5
end)
]])
- screen:expect{grid=[[
- S1^l1 |
- S2l2 |
- S4l3 |
+ screen:expect([[
+ {7:S1}^l1 |
+ {7:S2}l2 |
+ {7:S4}l3 |
|
- ]]}
+ ]])
end)
it('no crash with sign after many marks #27137', function()
@@ -5553,11 +5686,11 @@ l5
end
api.nvim_buf_set_extmark(0, ns, 0, 0, {sign_text = 'S1'})
- screen:expect{grid=[[
- S1{9:^a} |
+ screen:expect([[
+ {7:S1}{9:^a} |
{1:~ }|*2
|
- ]]}
+ ]])
end)
it('correct sort order with multiple namespaces and same id', function()
@@ -5565,11 +5698,11 @@ l5
api.nvim_buf_set_extmark(0, ns, 0, 0, {sign_text = 'S1', id = 1})
api.nvim_buf_set_extmark(0, ns2, 0, 0, {sign_text = 'S2', id = 1})
- screen:expect{grid=[[
- S2S1^ |
+ screen:expect([[
+ {7:S2S1}^ |
{1:~ }|*8
|
- ]]}
+ ]])
end)
it('correct number of signs after deleting text (#27046)', function()
@@ -5586,12 +5719,12 @@ l5
api.nvim_buf_set_extmark(0, ns, 30, 0, {end_row = 30, end_col = 3, hl_group = 'Error'})
command('0d29')
- screen:expect{grid=[[
- S4S3S2S1{9:^foo} |
- S5{7: }{9:foo} |
+ screen:expect([[
+ {7:S4S3S2S1}{9:^foo} |
+ {7:S5 }{9:foo} |
{1:~ }|*7
29 fewer lines |
- ]]}
+ ]])
api.nvim_buf_clear_namespace(0, ns, 0, -1)
end)
@@ -5599,21 +5732,17 @@ l5
it([[correct numberwidth with 'signcolumn' set to "number" #28984]], function()
command('set number numberwidth=1 signcolumn=number')
api.nvim_buf_set_extmark(0, ns, 0, 0, { sign_text = 'S1' })
- screen:expect({
- grid = [[
- S1 ^ |
- {1:~ }|*8
- |
- ]]
- })
+ screen:expect([[
+ {7:S1 }^ |
+ {1:~ }|*8
+ |
+ ]])
api.nvim_buf_del_extmark(0, ns, 1)
- screen:expect({
- grid = [[
- {8:1 }^ |
- {1:~ }|*8
- |
- ]]
- })
+ screen:expect([[
+ {8:1 }^ |
+ {1:~ }|*8
+ |
+ ]])
end)
it('supports emoji as signs', function()
@@ -5626,10 +5755,10 @@ l5
api.nvim_buf_set_extmark(0, ns, 4, 0, {sign_text='❤x'})
screen:expect([[
{7: }^l1 |
- 🧑‍🌾l2 |
- ❤️l3 |
- ❤ l4 |
- ❤xl5 |
+ {7:🧑‍🌾}l2 |
+ {7:❤️}l3 |
+ {7:❤ }l4 |
+ {7:❤x}l5 |
{7: } |
{1:~ }|*3
|