aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/popupmenu.c16
-rw-r--r--test/old/testdir/test_popup.vim4
2 files changed, 10 insertions, 10 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);
diff --git a/test/old/testdir/test_popup.vim b/test/old/testdir/test_popup.vim
index 6881abcc0f..1bba1d9397 100644
--- a/test/old/testdir/test_popup.vim
+++ b/test/old/testdir/test_popup.vim
@@ -1516,9 +1516,9 @@ func Test_pum_extrahl()
endif
return {
\ 'words': [
- \ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'W', 'extrahl': 'StrikeFake' },
+ \ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'W', 'hl_group': 'StrikeFake' },
\ { 'word': 'aword2', 'menu': 'extra text 2', 'kind': 'W', },
- \ { 'word': '你好', 'menu': 'extra text 3', 'kind': 'W', 'extrahl': 'StrikeFake' },
+ \ { 'word': '你好', 'menu': 'extra text 3', 'kind': 'W', 'hl_group': 'StrikeFake' },
\]}
endfunc
set completeopt=menu