summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2022-08-11 19:22:04 +0200
committerGitHub <noreply@github.com>2022-08-11 19:22:04 +0200
commit44205fe516990fc753fd7dc31f5929508c452cfd (patch)
tree8cd7307708d01a5da1224a5fa834ca8eaee9f4c1
parent4cd0ee49afab9770f75ae1205107cb3297b0daa8 (diff)
[Backport release-0.7] fix(signs): priority of extmark signs (#19718) (#19721)
fix(signs): priority of extmark signs (#19718) Co-authored-by: Lewis Russell <lewis6991@gmail.com>
-rw-r--r--runtime/doc/api.txt4
-rw-r--r--src/nvim/api/extmark.c5
-rw-r--r--src/nvim/decoration.c2
-rw-r--r--test/functional/ui/decorations_spec.lua30
4 files changed, 35 insertions, 6 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index 0db78a219a..f80970894a 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -2582,8 +2582,8 @@ nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {*opts})
inserted (true for right, false for left).
Defaults to false.
• priority: a priority value for the highlight
- group. For example treesitter highlighting
- uses a value of 100.
+ group or sign attribute. For example
+ treesitter highlighting uses a value of 100.
• strict: boolean that indicates extmark should
not be placed if the line or column value is
past the end of the buffer or end of the line
diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c
index 8dca37a321..fa1e4bc664 100644
--- a/src/nvim/api/extmark.c
+++ b/src/nvim/api/extmark.c
@@ -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
/// in when new text is inserted (true for right, false
/// for left). Defaults to false.
-/// - priority: a priority value for the highlight group. For
-/// example treesitter highlighting uses a value of 100.
+/// - priority: a priority value for the highlight group or sign
+/// attribute. For example treesitter highlighting uses a
+/// value of 100.
/// - strict: boolean that indicates extmark should not be placed
/// if the line or column value is past the end of the
/// buffer or end of the line respectively. Defaults to true.
diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c
index 930bbdae01..d991e2cf00 100644
--- a/src/nvim/decoration.c
+++ b/src/nvim/decoration.c
@@ -394,7 +394,7 @@ void decor_redraw_signs(buf_T *buf, int row, int *num_signs, sign_attrs_T sattrs
int j;
for (j = (*num_signs); j > 0; j--) {
- if (sattrs[j].sat_prio <= decor->priority) {
+ if (sattrs[j - 1].sat_prio >= decor->priority) {
break;
}
sattrs[j] = sattrs[j-1];
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index 309a9e6614..88c362fd2c 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -1636,7 +1636,7 @@ l5
screen:expect{grid=[[
S4S1^l1 |
- S2x l2 |
+ x S2l2 |
S5{1: }l3 |
{1: }l4 |
{1: }l5 |
@@ -1734,6 +1734,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()