fix(signs): priority of extmark signs (#19718)

This commit is contained in:
Lewis Russell 2022-08-11 17:26:17 +01:00 committed by GitHub
parent 996fc2256b
commit a27756cc24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 6 deletions

View File

@ -2610,8 +2610,9 @@ nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {*opts})
the extmark end position (if it exists) will be shifted in the extmark end position (if it exists) will be shifted in
when new text is inserted (true for right, false for when new text is inserted (true for right, false for
left). Defaults to false. left). Defaults to false.
• priority: a priority value for the highlight group. For • priority: a priority value for the highlight group or sign
example treesitter highlighting uses a value of 100. attribute. For example treesitter highlighting uses a
value of 100.
• strict: boolean that indicates extmark should not be • strict: boolean that indicates extmark should not be
placed if the line or column value is past the end of the placed if the line or column value is past the end of the
buffer or end of the line respectively. Defaults to true. buffer or end of the line respectively. Defaults to true.

View File

@ -441,8 +441,9 @@ Array nvim_buf_get_extmarks(Buffer buffer, Integer ns_id, Object start, Object e
/// the extmark end position (if it exists) will be shifted /// the extmark end position (if it exists) will be shifted
/// in when new text is inserted (true for right, false /// in when new text is inserted (true for right, false
/// for left). Defaults to false. /// for left). Defaults to false.
/// - priority: a priority value for the highlight group. For /// - priority: a priority value for the highlight group or sign
/// example treesitter highlighting uses a value of 100. /// attribute. For example treesitter highlighting uses a
/// value of 100.
/// - strict: boolean that indicates extmark should not be placed /// - strict: boolean that indicates extmark should not be placed
/// if the line or column value is past the end of the /// if the line or column value is past the end of the
/// buffer or end of the line respectively. Defaults to true. /// buffer or end of the line respectively. Defaults to true.

View File

@ -385,7 +385,7 @@ void decor_redraw_signs(buf_T *buf, int row, int *num_signs, sign_attrs_T sattrs
int j; int j;
for (j = (*num_signs); j > 0; j--) { for (j = (*num_signs); j > 0; j--) {
if (sattrs[j].sat_prio <= decor->priority) { if (sattrs[j - 1].sat_prio >= decor->priority) {
break; break;
} }
sattrs[j] = sattrs[j - 1]; sattrs[j] = sattrs[j - 1];

View File

@ -1681,7 +1681,7 @@ l5
screen:expect{grid=[[ screen:expect{grid=[[
S4S1^l1 | S4S1^l1 |
S2x l2 | x S2l2 |
S5{1: }l3 | S5{1: }l3 |
{1: }l4 | {1: }l4 |
{1: }l5 | {1: }l5 |
@ -1779,6 +1779,34 @@ l5
]]} ]]}
end) 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) end)
describe('decorations: virt_text', function() describe('decorations: virt_text', function()