diff options
author | Tobias Schmitz <tobiasschmitz2001@gmail.com> | 2024-05-21 18:21:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-21 09:21:42 -0700 |
commit | ad191be65e2b1641c181506166b1037b548d14a8 (patch) | |
tree | 1490e00ce91335bd990a4b276031ca5a7a3ce4d6 /src | |
parent | 8263ed46706671e6a9a21cbb5f9555dd42ff8085 (diff) | |
download | rneovim-ad191be65e2b1641c181506166b1037b548d14a8.tar.gz rneovim-ad191be65e2b1641c181506166b1037b548d14a8.tar.bz2 rneovim-ad191be65e2b1641c181506166b1037b548d14a8.zip |
feat(signs)!: place higher-priority signs from the left #27781
Problem:
Higher-priority signs may be hidden by lower-priority signs.
Solution:
Place higher-priority signs from the left.
Example:
nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='H', priority=1})
nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='W', priority=2})
nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='E', priority=3})
Before:
| |
H | W E |
^ | |
Not visible
After:
| |
| E W | H
| | ^
Not visible
Fixes #16632
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/decoration.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c index bcfae50c8e..303d0318b5 100644 --- a/src/nvim/decoration.c +++ b/src/nvim/decoration.c @@ -740,14 +740,15 @@ void decor_redraw_signs(win_T *wp, buf_T *buf, int row, SignTextAttrs sattrs[], if (kv_size(signs)) { int width = wp->w_minscwidth == SCL_NUM ? 1 : wp->w_scwidth; - int idx = MIN(width, num_text) - 1; + int len = MIN(width, num_text); + int idx = 0; qsort((void *)&kv_A(signs, 0), kv_size(signs), sizeof(kv_A(signs, 0)), sign_item_cmp); for (size_t i = 0; i < kv_size(signs); i++) { DecorSignHighlight *sh = kv_A(signs, i).sh; - if (idx >= 0 && sh->text[0]) { + if (idx < len && sh->text[0]) { memcpy(sattrs[idx].text, sh->text, SIGN_WIDTH * sizeof(sattr_T)); - sattrs[idx--].hl_id = sh->hl_id; + sattrs[idx++].hl_id = sh->hl_id; } if (*num_id == 0) { *num_id = sh->number_hl_id; |