diff options
author | glepnir <glephunter@gmail.com> | 2024-07-27 18:06:21 +0800 |
---|---|---|
committer | glepnir <glephunter@gmail.com> | 2024-07-27 18:10:33 +0800 |
commit | bc8a776ef8afd53ac7b045eeed8935284e1cc4d4 (patch) | |
tree | 419ac15227febb2b3ed1acbd1186bcc60d695fa4 /src/nvim/popupmenu.c | |
parent | f132f8e9d43e3e5f56079bcae40d87b871d7b61b (diff) | |
download | rneovim-bc8a776ef8afd53ac7b045eeed8935284e1cc4d4.tar.gz rneovim-bc8a776ef8afd53ac7b045eeed8935284e1cc4d4.tar.bz2 rneovim-bc8a776ef8afd53ac7b045eeed8935284e1cc4d4.zip |
vim-patch:9.1.0619: tests: test_popup fails
Problem: tests: test_popup fails
(after v9.1.0618)
Solution: Correct test, move combining extra attributes to
pum_compute_text_attrs() (glepnir)
closes: vim/vim#15353
https://github.com/vim/vim/commit/8754efe437fcb17ad2c64192f8722e08d68e032e
Co-authored-by: glepnir <glephunter@gmail.com>
Diffstat (limited to 'src/nvim/popupmenu.c')
-rw-r--r-- | src/nvim/popupmenu.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c index 78952177a6..5fee636020 100644 --- a/src/nvim/popupmenu.c +++ b/src/nvim/popupmenu.c @@ -440,7 +440,7 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i /// Computes attributes of text on the popup menu. /// Returns attributes for every cell, or NULL if all attributes are the same. -static int *pum_compute_text_attrs(char *text, hlf_T hlf) +static int *pum_compute_text_attrs(char *text, hlf_T hlf, int extra_hlattr) { if ((hlf != HLF_PSI && hlf != HLF_PNI) || (win_hl_attr(curwin, HLF_PMSI) == win_hl_attr(curwin, HLF_PSI) @@ -486,6 +486,9 @@ static int *pum_compute_text_attrs(char *text, hlf_T hlf) } else if (matched_start && ptr < text + leader_len) { new_attr = win_hl_attr(curwin, hlf == HLF_PSI ? HLF_PMSI : HLF_PMNI); } + if (extra_hlattr > 0) { + new_attr = hl_combine_attr(new_attr, extra_hlattr); + } int char_cells = utf_ptr2cells(ptr); for (int i = 0; i < char_cells; i++) { @@ -506,7 +509,7 @@ static int *pum_compute_text_attrs(char *text, hlf_T hlf) /// Displays text on the popup menu with specific attributes. static void pum_grid_puts_with_attrs(int col, int cells, const char *text, int textlen, - const int *attrs, int extra_hlattr) + const int *attrs) { const int col_start = col; const char *ptr = text; @@ -515,9 +518,6 @@ static void pum_grid_puts_with_attrs(int col, int cells, const char *text, int t while (*ptr != NUL && (textlen < 0 || ptr < text + textlen)) { int char_len = utfc_ptr2len(ptr); int attr = attrs[pum_rl ? (col_start + cells - col - 1) : (col - col_start)]; - if (extra_hlattr > 0) { - attr = hl_combine_attr(extra_hlattr , attr); - } grid_line_puts(col, ptr, char_len, attr); col += utf_ptr2cells(ptr); ptr += char_len; @@ -666,7 +666,7 @@ void pum_redraw(void) *p = saved; } - int *attrs = pum_compute_text_attrs(st, hlf); + int *attrs = pum_compute_text_attrs(st, hlf, pum_array[idx].pum_extrahlattr); if (pum_rl) { char *rt = reverse_text(st); @@ -691,7 +691,7 @@ void pum_redraw(void) if (attrs == NULL) { grid_line_puts(grid_col - cells + 1, rt, -1, attr); } else { - pum_grid_puts_with_attrs(grid_col - cells + 1, cells, rt, -1, attrs, pum_array[idx].pum_extrahlattr); + pum_grid_puts_with_attrs(grid_col - cells + 1, cells, rt, -1, attrs); } xfree(rt_start); @@ -701,7 +701,7 @@ void pum_redraw(void) if (attrs == NULL) { grid_line_puts(grid_col, st, -1, attr); } else { - pum_grid_puts_with_attrs(grid_col, vim_strsize(st), st, -1, attrs, pum_array[idx].pum_extrahlattr); + pum_grid_puts_with_attrs(grid_col, vim_strsize(st), st, -1, attrs); } xfree(st); |