feat(ui): sign/statuscolumn can combine highlight attrs #31575

Problem:
Since e049c6e4c0, most statusline-like UI elements can combine
highlight attrs, except for sign/statuscolumn.

Solution:
Implement for sign/statuscolumn.
This commit is contained in:
luukvbaal 2024-12-14 19:21:50 +01:00 committed by GitHub
parent f9dd682621
commit 433b342baa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 265 additions and 239 deletions

View File

@ -307,7 +307,7 @@ UI
which controls the tool used to open the given path or URL. If you want to
globally set this, you can override vim.ui.open using the same approach
described at |vim.paste()|.
- `vim.ui.open()` now supports
`vim.ui.open()` now supports
[lemonade](https://github.com/lemonade-command/lemonade) as an option for
opening urls/files. This is handy if you are in an ssh connection and use
`lemonade`.
@ -317,7 +317,6 @@ UI
|hl-PmenuMatch|.
• |vim.diagnostic.setqflist()| updates an existing quickfix list with the
given title if found
• |ui-messages| content chunks now also contain the highlight group ID.
==============================================================================
@ -339,9 +338,9 @@ These existing features changed their behavior.
more emoji characters than before, including those encoded with multiple
emoji codepoints combined with ZWJ (zero width joiner) codepoints.
Text in the 'statusline', 'tabline', and 'winbar' now inherits highlights
from the respective |hl-StatusLine|, |hl-TabLine|, and |hl-WinBar| highlight
groups.
Custom highlights in 'rulerformat', 'statuscolumn', 'statusline', 'tabline',
'winbar' and the number column (through |:sign-define| `numhl`) now combine
with their respective highlight groups, as opposed to |hl-Normal|.
• |vim.on_key()| callbacks won't be invoked recursively when a callback itself
consumes input.

View File

@ -462,10 +462,12 @@ void fill_foldcolumn(win_T *wp, foldinfo_T foldinfo, linenr_T lnum, int attr, in
static void draw_sign(bool nrcol, win_T *wp, winlinevars_T *wlv, int sign_idx, int sign_cul_attr)
{
SignTextAttrs sattr = wlv->sattrs[sign_idx];
int scl_attr = win_hl_attr(wp, use_cursor_line_highlight(wp, wlv->lnum) ? HLF_CLS : HLF_SC);
if (sattr.text[0] && wlv->row == wlv->startrow + wlv->filler_lines && wlv->filler_todo <= 0) {
int attr = (use_cursor_line_highlight(wp, wlv->lnum) && sign_cul_attr)
? sign_cul_attr : sattr.hl_id ? syn_id2attr(sattr.hl_id) : 0;
attr = hl_combine_attr(scl_attr, attr);
int fill = nrcol ? number_width(wp) + 1 : SIGN_WIDTH;
draw_col_fill(wlv, schar_from_ascii(' '), fill, attr);
int sign_pos = wlv->off - SIGN_WIDTH - (int)nrcol;
@ -474,8 +476,7 @@ static void draw_sign(bool nrcol, win_T *wp, winlinevars_T *wlv, int sign_idx, i
linebuf_char[sign_pos + 1] = sattr.text[1];
} else {
assert(!nrcol); // handled in draw_lnum_col()
int attr = win_hl_attr(wp, use_cursor_line_highlight(wp, wlv->lnum) ? HLF_CLS : HLF_SC);
draw_col_fill(wlv, schar_from_ascii(' '), SIGN_WIDTH, attr);
draw_col_fill(wlv, schar_from_ascii(' '), SIGN_WIDTH, scl_attr);
}
}
@ -559,8 +560,8 @@ static void draw_lnum_col(win_T *wp, winlinevars_T *wlv, int sign_num_attr, int
} else {
// Draw the line number (empty space after wrapping).
int width = number_width(wp) + 1;
int attr = (sign_num_attr > 0 && wlv->filler_todo <= 0)
? sign_num_attr : get_line_number_attr(wp, wlv);
int attr = hl_combine_attr(get_line_number_attr(wp, wlv),
wlv->filler_todo <= 0 ? sign_num_attr : 0);
if (wlv->row == wlv->startrow + wlv->filler_lines
&& (wp->w_skipcol == 0 || wlv->row > 0 || (wp->w_p_nu && wp->w_p_rnu))) {
char buf[32];
@ -640,7 +641,7 @@ static void draw_statuscol(win_T *wp, winlinevars_T *wlv, linenr_T lnum, int vir
draw_col_buf(wp, wlv, transbuf, translen, attr, false);
p = sp->start;
int hl = sp->userhl;
attr = hl < 0 ? syn_id2attr(-hl) : stcp->num_attr;
attr = hl < 0 ? hl_combine_attr(stcp->num_attr, syn_id2attr(-hl)) : stcp->num_attr;
}
size_t translen = transstr_buf(p, buf + len - p, transbuf, MAXPATHL, true);
draw_col_buf(wp, wlv, transbuf, translen, attr, false);

View File

@ -1731,7 +1731,7 @@ describe('API/extmarks', function()
-- mark with invalidate is removed
command('d2')
screen:expect([[
S2^aaa bbb ccc |
{7:S2}^aaa bbb ccc |
{7: }aaa bbb ccc |*3
{7: } |
|
@ -1739,9 +1739,9 @@ describe('API/extmarks', function()
-- mark is restored with undo_restore == true
command('silent undo')
screen:expect([[
S1{7: }^aaa bbb ccc |
S2S1aaa bbb ccc |
S2{7: }aaa bbb ccc |
{7:S1 }^aaa bbb ccc |
{7:S2S1}aaa bbb ccc |
{7:S2 }aaa bbb ccc |
{7: }aaa bbb ccc |*2
|
]])

View File

@ -26,6 +26,9 @@ describe('signs', function()
-- oldtest: Test_sign_cursor_position()
it('are drawn correctly', function()
local screen = Screen.new(75, 6)
screen:add_extra_attr_ids({
[100] = { foreground = Screen.colors.Blue4, background = Screen.colors.Yellow },
})
exec([[
call setline(1, [repeat('x', 75), 'mmmm', 'yyyy'])
call cursor(2,1)
@ -37,7 +40,7 @@ describe('signs', function()
screen:expect([[
{7: }xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
{7: }xx |
{10:=>}^mmmm |
{100:=>}^mmmm |
{7: }yyyy |
{1:~ }|
|
@ -48,7 +51,7 @@ describe('signs', function()
screen:expect([[
{7: }xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
{7: }xx |
{10:-)}^mmmm |
{100:-)}^mmmm |
{7: }yyyy |
{1:~ }|
|
@ -59,7 +62,7 @@ describe('signs', function()
screen:expect([[
{7: }xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
{7: }xx |
{10:-)}{4:^mmmm }|
{100:-)}{4:^mmmm }|
{7: }yyyy |
{1:~ }|
|

View File

@ -631,7 +631,7 @@ describe('decorations providers', function()
{14: }hello97 |
{14: }hello98 |
{14: }hello99 |
X ^hello100 |
{14:X }^hello100 |
{14: }hello101 |
{14: }hello102 |
{14: }hello103 |
@ -2301,13 +2301,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 +5067,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 +5085,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 +5102,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 +5122,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 +5141,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 +5159,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 +5179,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 +5198,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 +5222,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 +5247,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 +5267,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 +5296,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 +5316,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 +5346,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 +5386,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 +5403,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 +5455,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 +5475,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 +5490,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 +5504,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 +5540,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 +5556,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 +5568,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 +5589,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 +5602,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 +5625,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
|

View File

@ -1046,6 +1046,8 @@ describe('float window', function()
[26] = {blend = 80, background = Screen.colors.Gray0};
[27] = {foreground = Screen.colors.Black, background = Screen.colors.LightGrey};
[28] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey};
[29] = {background = Screen.colors.Yellow1, foreground = Screen.colors.Blue4};
[30] = {background = Screen.colors.Grey, foreground = Screen.colors.Blue4, bold = true};
}
screen:set_default_attr_ids(attrs)
end)
@ -1451,14 +1453,14 @@ describe('float window', function()
[2:----------------------------------------]|*6
[3:----------------------------------------]|
## grid 2
{19: }{17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
{19: }{29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
{19: }{14: 2 }{22:y} |
{19: }{14: 3 }{22: } |
{0:~ }|*3
## grid 3
|
## grid 4
{17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x }|
{29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x }|
{19: }{15:y }|
{19: }{15: }|
{15: }|
@ -1466,9 +1468,9 @@ describe('float window', function()
else
screen:expect([[
{19: }{17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
{19: }{29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
{19: }{14: 2 }{22:y} |
{19: }{14: 3 }{22: } {17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x } |
{19: }{14: 3 }{22: } {29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x } |
{0:~ }{19: }{15:y }{0: }|
{0:~ }{19: }{15: }{0: }|
{0:~ }{15: }{0: }|
@ -1551,14 +1553,14 @@ describe('float window', function()
[2:----------------------------------------]|*6
[3:----------------------------------------]|
## grid 2
{19: }{17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
{19: }{29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
{19: }{14: 2 }{22:y} |
{19: }{14: 3 }{22: } |
{0:~ }|*3
## grid 3
|
## grid 4
{17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x }|
{29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x }|
{19: }{15:y }|
{19: }{15: }|
{15: }|
@ -1566,9 +1568,9 @@ describe('float window', function()
else
screen:expect([[
{19: }{17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
{19: }{29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
{19: }{14: 2 }{22:y} |
{19: }{14: 3 }{22: } {17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x } |
{19: }{14: 3 }{22: } {29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x } |
{0:~ }{19: }{15:y }{0: }|
{0:~ }{19: }{15: }{0: }|
{0:~ }{15: }{0: }|
@ -1621,7 +1623,7 @@ describe('float window', function()
[2:----------------------------------------]|*6
[3:----------------------------------------]|
## grid 2
{20: 1}{19: }{22:^x}{21: }|
{20: 1}{30: }{22:^x}{21: }|
{14: 2}{19: }{22:y} |
{14: 3}{19: }{22: } |
{0:~ }|*3
@ -1634,7 +1636,7 @@ describe('float window', function()
]], float_pos={[4] = {1001, "NW", 1, 4, 10, true}}}
else
screen:expect{grid=[[
{20: 1}{19: }{22:^x}{21: }|
{20: 1}{30: }{22:^x}{21: }|
{14: 2}{19: }{22:y} |
{14: 3}{19: }{22: } {15:x } |
{0:~ }{15:y }{0: }|

View File

@ -14,6 +14,12 @@ describe('Signs', function()
screen = Screen.new()
screen:add_extra_attr_ids {
[100] = { bold = true, foreground = Screen.colors.Magenta1 },
[101] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.Yellow1 },
[102] = { foreground = Screen.colors.Brown, background = Screen.colors.Yellow },
[103] = { background = Screen.colors.Yellow, reverse = true },
[104] = { reverse = true, foreground = Screen.colors.Grey100, background = Screen.colors.Red },
[105] = { bold = true, background = Screen.colors.Red1, foreground = Screen.colors.Gray100 },
[106] = { foreground = Screen.colors.Brown, reverse = true },
}
end)
@ -27,8 +33,8 @@ describe('Signs', function()
sign place 2 line=2 name=piet2 buffer=1
]])
screen:expect([[
{10:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}a |
{10:𠜎̀́̂̃̄̅}b |
{101:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}a |
{101:𠜎̀́̂̃̄̅}b |
{7: }^ |
{1:~ }|*10
|
@ -45,9 +51,9 @@ describe('Signs', function()
sign place 3 line=1 name=pietx buffer=1
]])
screen:expect([[
{10:>!}a |
{101:>!}a |
{7: }b |
{10:>>}c |
{101:>>}c |
{7: }^ |
{1:~ }|*9
|
@ -80,13 +86,13 @@ describe('Signs', function()
]])
screen:expect([[
{7: }{21:^a }|
{10:>>}b |
{101:>>}b |
{7: }c |
{7: } |
{1:~ }|*2
{3:[No Name] [+] }|
{7: }{21:a }|
{10:>>}b |
{101:>>}b |
{7: }c |
{7: } |
{1:~ }|
@ -110,16 +116,23 @@ describe('Signs', function()
sign place 6 line=4 name=pietxx buffer=1
]])
screen:expect([[
{10:>>}{8: 1 }a |
{101:>>}{8: 1 }a |
{7: }{8: 2 }{9:b }|
{7: }{13: 3 }c |
{10:>>}{13: 4 }{9:^ }|
{101:>>}{13: 4 }{9:^ }|
{1:~ }|*9
|
]])
-- Check that 'statuscolumn' correctly applies numhl
exec('set statuscolumn=%s%=%l\\ ')
screen:expect_unchanged()
screen:expect([[
{102:>>}{8: 1 }a |
{7: }{8: 2 }{9:b }|
{7: }{13: 3 }c |
{101:>>}{13: 4 }{9:^ }|
{1:~ }|*9
|
]])
end)
it('highlights the cursorline sign with culhl', function()
@ -132,33 +145,33 @@ describe('Signs', function()
set cursorline
]])
screen:expect([[
{10:>>}a |
{10:>>}b |
{101:>>}a |
{101:>>}b |
{9:>>}{21:^c }|
{1:~ }|*10
|
]])
feed('k')
screen:expect([[
{10:>>}a |
{101:>>}a |
{9:>>}{21:^b }|
{10:>>}c |
{101:>>}c |
{1:~ }|*10
|
]])
exec('set nocursorline')
screen:expect([[
{10:>>}a |
{10:>>}^b |
{10:>>}c |
{101:>>}a |
{101:>>}^b |
{101:>>}c |
{1:~ }|*10
|
]])
exec('set cursorline cursorlineopt=line')
screen:expect([[
{10:>>}a |
{10:>>}{21:^b }|
{10:>>}c |
{101:>>}a |
{101:>>}{21:^b }|
{101:>>}c |
{1:~ }|*10
|
]])
@ -166,16 +179,24 @@ describe('Signs', function()
exec('hi! link SignColumn IncSearch')
feed('Go<esc>2G')
screen:expect([[
{10:>>}a |
{9:>>}^b |
{10:>>}c |
{103:>>}a |
{104:>>}^b |
{103:>>}c |
{2: } |
{1:~ }|*9
|
]])
-- Check that 'statuscolumn' cursorline/signcolumn highlights are the same (#21726)
exec('set statuscolumn=%s')
screen:expect_unchanged()
screen:expect([[
{102:>>}a |
{105:>>}^b |
{102:>>}c |
{106: } |
{1:~ }|*9
|
]])
end)
it('multiple signs #9295', function()
@ -196,7 +217,7 @@ describe('Signs', function()
screen:expect([[
{7: }{8: 1 }a |
{7: }{8: 2 }b |
WW{10:>>}{8: 3 }c |
{7:WW}{101:>>}{8: 3 }c |
{7: }{8: 4 }^ |
{1:~ }|*9
|
@ -209,9 +230,9 @@ describe('Signs', function()
sign place 3 line=2 name=pietError buffer=1
]])
screen:expect([[
{9:XX}{10:>>}{8: 1 }a |
{10:>>}{9:XX}{8: 2 }b |
WW{10:>>}{8: 3 }c |
{9:XX}{101:>>}{8: 1 }a |
{101:>>}{9:XX}{8: 2 }b |
{7:WW}{101:>>}{8: 3 }c |
{7: }{8: 4 }^ |
{1:~ }|*9
|
@ -220,8 +241,8 @@ describe('Signs', function()
exec('set signcolumn=yes:1')
screen:expect([[
{9:XX}{8: 1 }a |
{10:>>}{8: 2 }b |
WW{8: 3 }c |
{101:>>}{8: 2 }b |
{7:WW}{8: 3 }c |
{7: }{8: 4 }^ |
{1:~ }|*9
|
@ -229,9 +250,9 @@ describe('Signs', function()
-- "auto:3" accommodates all the signs we defined so far.
exec('set signcolumn=auto:3')
local s3 = [[
{9:XX}{10:>>}{7: }{8: 1 }a |
{10:>>}{9:XX}{7: }{8: 2 }b |
WW{10:>>}{9:XX}{8: 3 }c |
{9:XX}{101:>>}{7: }{8: 1 }a |
{101:>>}{9:XX}{7: }{8: 2 }b |
{7:WW}{101:>>}{9:XX}{8: 3 }c |
{7: }{8: 4 }^ |
{1:~ }|*9
|
@ -240,9 +261,9 @@ describe('Signs', function()
-- Check "yes:9".
exec('set signcolumn=yes:9')
screen:expect([[
{9:XX}{10:>>}{7: }{8: 1 }a |
{10:>>}{9:XX}{7: }{8: 2 }b |
WW{10:>>}{9:XX}{7: }{8: 3 }c |
{9:XX}{101:>>}{7: }{8: 1 }a |
{101:>>}{9:XX}{7: }{8: 2 }b |
{7:WW}{101:>>}{9:XX}{7: }{8: 3 }c |
{7: }{8: 4 }^ |
{1:~ }|*9
|
@ -255,8 +276,8 @@ describe('Signs', function()
exec('3move1')
exec('2d')
screen:expect([[
{9:XX}{10:>>}{8: 1 }a |
{10:>>}{9:XX}{8: 2 }^b |
{9:XX}{101:>>}{8: 1 }a |
{101:>>}{9:XX}{8: 2 }^b |
{7: }{8: 3 } |
{1:~ }|*10
|
@ -264,8 +285,8 @@ describe('Signs', function()
-- character deletion does not delete signs.
feed('x')
screen:expect([[
{9:XX}{10:>>}{8: 1 }a |
{10:>>}{9:XX}{8: 2 }^ |
{9:XX}{101:>>}{8: 1 }a |
{101:>>}{9:XX}{8: 2 }^ |
{7: }{8: 3 } |
{1:~ }|*10
|
@ -301,7 +322,7 @@ describe('Signs', function()
exec('sign define pietSearch text=>> texthl=Search')
exec('sign place 1 line=1 name=pietSearch buffer=1')
screen:expect([[
{10:>>}{7: }{8: 1 }a |
{101:>>}{7: }{8: 1 }a |
{7: }{8: 2 }b |
{7: }{8: 3 }c |
{7: }{8: 4 }^ |
@ -316,7 +337,7 @@ describe('Signs', function()
sign place 4 line=1 name=pietSearch buffer=1
]])
screen:expect([[
{10:>>>>>>>>}{8: 1 }a |
{101:>>>>>>>>}{8: 1 }a |
{7: }{8: 2 }b |
{7: }{8: 3 }c |
{7: }{8: 4 }^ |
@ -328,7 +349,7 @@ describe('Signs', function()
screen:expect_unchanged()
exec('sign unplace 4')
screen:expect([[
{10:>>>>>>}{8: 1 }a |
{101:>>>>>>}{8: 1 }a |
{7: }{8: 2 }b |
{7: }{8: 3 }c |
{7: }{8: 4 }^ |
@ -345,7 +366,7 @@ describe('Signs', function()
sign place 8 line=1 name=pietSearch buffer=1
]])
screen:expect([[
{10:>>>>>>>>>>}{8: 1 }a |
{101:>>>>>>>>>>}{8: 1 }a |
{7: }{8: 2 }b |
{7: }{8: 3 }c |
{7: }{8: 4 }^ |
@ -375,7 +396,7 @@ describe('Signs', function()
-- single column with 1 sign with text and one sign without
exec('sign place 1 line=1 name=pietSearch buffer=1')
screen:expect([[
{10:>>}{8: 1 }a |
{101:>>}{8: 1 }a |
{7: }{8: 2 }b |
{7: }{8: 3 }c |
{7: }{8: 4 }^ |
@ -396,7 +417,7 @@ describe('Signs', function()
-- line number should be drawn if sign has no text
-- no signcolumn, line number for "a" is Search, for "b" is Error, for "c" is LineNr
screen:expect([[
{10: >> }a |
{101: >> }a |
{9: 2 }b |
{8: 3 }c |
{8: 4 }^ |
@ -406,7 +427,7 @@ describe('Signs', function()
-- number column on wrapped part of a line should be empty
feed('gg100aa<Esc>')
screen:expect([[
{10: >> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{101: >> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{9: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{9: }aa^a |
{9: 2 }b |
@ -423,7 +444,7 @@ describe('Signs', function()
-- number column on virtual lines should be empty
screen:expect([[
{8: }VIRT LINES |
{10: >> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{101: >> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{9: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{9: }aa^a |
{9: 2 }b |
@ -439,7 +460,7 @@ describe('Signs', function()
exec('sign place 100000 line=1 name=piet buffer=1')
feed(':sign place<cr>')
screen:expect([[
{10:>>} |
{101:>>} |
{1:~ }|*6
{3: }|
:sign place |
@ -452,7 +473,7 @@ describe('Signs', function()
feed('<cr>')
screen:expect([[
{10:>>}^ |
{101:>>}^ |
{1:~ }|*12
|
]])
@ -470,7 +491,7 @@ describe('Signs', function()
{7: }a |
{7: }^c |
{7: }d |
>>e |
{7:>>}e |
{1:~ }|*9
|
]])
@ -498,7 +519,7 @@ describe('Signs', function()
{7: }b |
{7: }c |
{7: }d |
>>e |
{7:>>}e |
{1:~ }|*7
|
]])
@ -550,7 +571,7 @@ describe('Signs', function()
exec('silent undo')
screen:expect([[
{7: }1 |
S1^2 |
{7:S1}^2 |
{7: }3 |
{7: }4 |
{1:~ }|*9
@ -575,23 +596,19 @@ describe('Signs', function()
sign place 2 line=9 name=S2
]])
-- Now placed at end of buffer
local s1 = {
grid = [[
S2^ |
{1:~ }|*12
|
]],
}
local s1 = [[
{7:S2}^ |
{1:~ }|*12
|
]]
screen:expect(s1)
-- Signcolumn tracking used to not count signs placed beyond end of buffer here
exec('set signcolumn=auto:9')
screen:expect({
grid = [[
S2S1^ |
{1:~ }|*12
|
]],
})
screen:expect([[
{7:S2S1}^ |
{1:~ }|*12
|
]])
-- Unplacing the sign does not crash by decrementing tracked signs below zero
exec('sign unplace 1')
screen:expect(s1)
@ -658,7 +675,7 @@ describe('Signs', function()
{7: }497 {7: }2 |
{7: }498 {7: }3 |
{7: }499 {7: }4 |
! ^500 {7: }5 |
{7:! }^500 {7: }5 |
{3:[No Name] [+] }{2:[No Name] [+] }|
|
]])
@ -675,7 +692,7 @@ describe('Signs', function()
{7: }497 {7: }2 |
{7: }498 {7: }3 |
{7: }499 {7: }4 |
! ^500 {7: }5 |
{7:! }^500 {7: }5 |
{3:[No Name] [+] }{2:[No Name] [+] }|
:lua log, needs_clear = {}, true |
]])

View File

@ -236,6 +236,11 @@ describe('statuscolumn', function()
command("call setline(1,repeat([repeat('aaaaa',10)],16))")
screen:add_extra_attr_ids {
[100] = { foreground = Screen.colors.Red, background = Screen.colors.LightGray },
[101] = {
bold = true,
background = Screen.colors.WebGray,
foreground = Screen.colors.DarkBlue,
},
}
command('hi! CursorLine guifg=Red guibg=NONE')
screen:expect([[
@ -308,7 +313,7 @@ describe('statuscolumn', function()
{7: }{8: }{7: }{8: }aaaaaa |
{7: }{8: 7}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: }{7: }{8: }aaaaaa |
{7:+}{15: 8}{7: }{15: }{100:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{101:+}{15: 8}{101: }{15: }{100:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{7: }{8: 9}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: }{7: }{8: }aaaaaa |
{7: }{8:10}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
@ -326,7 +331,7 @@ describe('statuscolumn', function()
{7: }{8: 6}{7: }{8: }aaaaaa |
{7: }{8: 7}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: 7}{7: }{8: }aaaaaa |
{7:+}{15: 8}{7: }{15: }{100:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{101:+}{15: 8}{101: }{15: }{100:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{7: }{8: 9}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: 9}{7: }{8: }aaaaaa |
{7: }{8:10}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
@ -344,7 +349,7 @@ describe('statuscolumn', function()
{7: }{8: 2}{7: }{8: }aaaaaaa |
{7: }{8: 1}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: 1}{7: }{8: }aaaaaaa |
{7:+}{15: 0}{7: }{15: }{100:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{101:+}{15: 0}{101: }{15: }{100:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{7: }{8: 1}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: 1}{7: }{8: }aaaaaaa |
{7: }{8: 2}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
@ -361,7 +366,7 @@ describe('statuscolumn', function()
{7: }{8: }{7: }{8: }aaaaaaa |
{7: }{8: 1}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: }{7: }{8: }aaaaaaa |
{7:+}{15: 0}{7: }{15: }{100:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{101:+}{15: 0}{101: }{15: }{100:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{7: }{8: 1}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: }{7: }{8: }aaaaaaa |
{7: }{8: 2}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
@ -386,7 +391,7 @@ describe('statuscolumn', function()
{7: }{8: }{7: }{8: }aaaaaaaaaaaaaaaaaaaaa |
{7: }{8: 1}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: }{7: }{8: }aaaaaaaaaaaaaaaaaaaaa |
{7:+}{15: 0}{7: }{15: }{100:^+-- 1 line: aaaaaaaaaaaaaaaa}|
{101:+}{15: 0}{101: }{15: }{100:^+-- 1 line: aaaaaaaaaaaaaaaa}|
{7: }{8: 1}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }{8: }{7: }{8: }aaaaaaaaaaaaaaaaaaaaa |
{7: }{8: 2}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
@ -397,7 +402,7 @@ describe('statuscolumn', function()
command('set cpoptions+=n')
feed('Hgjg0')
screen:expect([[
{7: }{15: 0}{8:>>}{7: }{15: }{19:aaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{101: }{15: 0>>}{101: }{15: }{19:aaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{7: }{19:^aaaaaaaaaaaaaaaaaaaaa }|
{7: }{8: 3}{1:>!}{7: }{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
{7: }aaaaaaaaaaaaaaaaaaaaa |
@ -416,7 +421,7 @@ describe('statuscolumn', function()
command('sign unplace 2')
feed('J2gjg0')
screen:expect([[
{7: }{15: 0}{8:>>}{7: }{15: }{19:aaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{101: }{15: 0>>}{101: }{15: }{19:aaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{7: } {19:aaaaaaaaaaaaaaaaaaaaa aaaaaaa}|
{7: } {19:aaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{7: } {19:^aaaaaaaaaaaaaa }|
@ -434,7 +439,7 @@ describe('statuscolumn', function()
command('set nobreakindent')
feed('$g0')
screen:expect([[
{7: }{15: 0}{8:>>}{7: }{15: }{19:aaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{101: }{15: 0>>}{101: }{15: }{19:aaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{7: }{19:aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaa}|
{7: }{19:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
{7: }{19:^aaaa }|