diff options
author | luukvbaal <luukvbaal@gmail.com> | 2024-07-17 02:53:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-17 08:53:10 +0800 |
commit | f9a49fab0c9062cb0e5ed8fbb26579efda0e7a30 (patch) | |
tree | 4f25d544c354b48a1d591c004051571b28ae3e56 /src/nvim/sign.c | |
parent | 1f2f460b4a77a8ff58872e03c071b5d0d882dd44 (diff) | |
download | rneovim-f9a49fab0c9062cb0e5ed8fbb26579efda0e7a30.tar.gz rneovim-f9a49fab0c9062cb0e5ed8fbb26579efda0e7a30.tar.bz2 rneovim-f9a49fab0c9062cb0e5ed8fbb26579efda0e7a30.zip |
fix(column): modifying a sign should update placed signs (#29750)
Problem: Modifying a sign no longer updates already placed signs.
Solution: Loop over (newly-exposed) placed decorations when modifying a
sign definition. Update placed decor if it belongs to the sign
that is modified.
Diffstat (limited to 'src/nvim/sign.c')
-rw-r--r-- | src/nvim/sign.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/nvim/sign.c b/src/nvim/sign.c index fbd25493ef..9b2516ed83 100644 --- a/src/nvim/sign.c +++ b/src/nvim/sign.c @@ -404,19 +404,13 @@ static int sign_define_by_name(char *name, char *icon, char *text, char *linehl, char *culhl, char *numhl, int prio) { cstr_t *key; - sign_T **sp = (sign_T **)pmap_put_ref(cstr_t)(&sign_map, name, &key, NULL); + bool new_sign = false; + sign_T **sp = (sign_T **)pmap_put_ref(cstr_t)(&sign_map, name, &key, &new_sign); - if (*sp == NULL) { + if (new_sign) { *key = xstrdup(name); *sp = xcalloc(1, sizeof(sign_T)); (*sp)->sn_name = (char *)(*key); - } else { - // Signs may already exist, a redraw is needed in windows with a non-empty sign list. - FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { - if (buf_has_signs(wp->w_buffer)) { - redraw_buf_later(wp->w_buffer, UPD_NOT_VALID); - } - } } // Set values for a defined sign. @@ -441,6 +435,28 @@ static int sign_define_by_name(char *name, char *icon, char *text, char *linehl, } } + // Update already placed signs and redraw if necessary when modifying a sign. + if (!new_sign) { + bool did_redraw = false; + for (size_t i = 0; i < kv_size(decor_items); i++) { + DecorSignHighlight *sh = &kv_A(decor_items, i); + if (sh->sign_name && strcmp(sh->sign_name, name) == 0) { + memcpy(sh->text, (*sp)->sn_text, SIGN_WIDTH * sizeof(schar_T)); + sh->hl_id = (*sp)->sn_text_hl; + sh->line_hl_id = (*sp)->sn_line_hl; + sh->number_hl_id = (*sp)->sn_num_hl; + sh->cursorline_hl_id = (*sp)->sn_cul_hl; + if (!did_redraw) { + FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { + if (buf_has_signs(wp->w_buffer)) { + redraw_buf_later(wp->w_buffer, UPD_NOT_VALID); + } + } + did_redraw = true; + } + } + } + } return OK; } |