diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-10-09 08:15:14 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2024-10-10 07:21:02 +0800 |
commit | 8450752f46e1482bf34b7f05e484cca740f61075 (patch) | |
tree | 58abd1753cfbf7185a1f7ed224ff473e5a1bb8e8 /src/nvim/popupmenu.c | |
parent | cd8e15e3373dc9544d582640f043d3dee83a953d (diff) | |
download | rneovim-8450752f46e1482bf34b7f05e484cca740f61075.tar.gz rneovim-8450752f46e1482bf34b7f05e484cca740f61075.tar.bz2 rneovim-8450752f46e1482bf34b7f05e484cca740f61075.zip |
vim-patch:9.1.0771: completion attribute hl_group is confusing
Problem: Currently completion attribute hl_group is combined with
all items, which is redundant and confusing with kind_hlgroup
Solution: Renamed to abbr_hlgroup and combine it only with the abbr item
(glepnir).
closes: vim/vim#15818
https://github.com/vim/vim/commit/0fe17f8ffbd2588ecd2bf42dced556897bc64f89
Co-authored-by: glepnir <glephunter@gmail.com>
Diffstat (limited to 'src/nvim/popupmenu.c')
-rw-r--r-- | src/nvim/popupmenu.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c index ddcb819054..3f64e841e2 100644 --- a/src/nvim/popupmenu.c +++ b/src/nvim/popupmenu.c @@ -654,11 +654,14 @@ void pum_redraw(void) int item_type = order[j]; hlf = hlfs[item_type]; attr = win_hl_attr(curwin, (int)hlf); - if (pum_array[idx].pum_user_hlattr > 0) { - attr = hl_combine_attr(attr, pum_array[idx].pum_user_hlattr); + int orig_attr = attr; + int user_abbr_hlattr = pum_array[idx].pum_user_abbr_hlattr; + int user_kind_hlattr = pum_array[idx].pum_user_kind_hlattr; + if (item_type == CPT_ABBR && user_abbr_hlattr > 0) { + attr = hl_combine_attr(attr, user_abbr_hlattr); } - if (item_type == CPT_KIND && pum_array[idx].pum_user_kind_hlattr > 0) { - attr = hl_combine_attr(attr, pum_array[idx].pum_user_kind_hlattr); + if (item_type == CPT_KIND && user_kind_hlattr > 0) { + attr = hl_combine_attr(attr, user_kind_hlattr); } int width = 0; char *s = NULL; @@ -684,8 +687,10 @@ void pum_redraw(void) *p = saved; } - int user_hlattr = pum_array[idx].pum_user_hlattr; - int *attrs = pum_compute_text_attrs(st, hlf, user_hlattr); + int *attrs = NULL; + if (item_type == CPT_ABBR) { + attrs = pum_compute_text_attrs(st, hlf, user_abbr_hlattr); + } if (pum_rl) { char *rt = reverse_text(st); @@ -727,7 +732,10 @@ void pum_redraw(void) grid_col += width; } - xfree(attrs); + if (attrs != NULL) { + xfree(attrs); + attrs = NULL; + } if (*p != TAB) { break; @@ -735,10 +743,10 @@ void pum_redraw(void) // Display two spaces for a Tab. if (pum_rl) { - grid_line_puts(grid_col - 1, " ", 2, attr); + grid_line_puts(grid_col - 1, " ", 2, orig_attr); grid_col -= 2; } else { - grid_line_puts(grid_col, " ", 2, attr); + grid_line_puts(grid_col, " ", 2, orig_attr); grid_col += 2; } totwidth += 2; @@ -772,7 +780,7 @@ void pum_redraw(void) grid_line_fill(col_off - basic_width - n + 1, grid_col + 1, schar_from_ascii(' '), attr); grid_col = col_off - basic_width - n; } else { - grid_line_fill(grid_col, col_off + basic_width + n, schar_from_ascii(' '), attr); + grid_line_fill(grid_col, col_off + basic_width + n, schar_from_ascii(' '), orig_attr); grid_col = col_off + basic_width + n; } totwidth = basic_width + n; |