mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 14:38:32 +00:00
vim-patch:9.1.0485: Matched text shouldn't be highlighted in "kind" and "menu"
Problem: Matched text shouldn't be highlighted in "kind" and "menu".
Solution: Pass hlf_T instead of the attribute. Fix indent.
(zeertzjq)
closes: vim/vim#14996
afbe5359e9
This commit is contained in:
@@ -438,14 +438,14 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i
|
||||
}
|
||||
|
||||
/// Displays text on the popup menu with specific attributes.
|
||||
static void pum_puts_with_attr(int col, char *text, int attr)
|
||||
static void pum_puts_with_attr(int col, char *text, hlf_T hlf)
|
||||
{
|
||||
char *leader = ins_compl_leader();
|
||||
|
||||
if (leader == NULL || *leader == NUL
|
||||
if (leader == NULL || *leader == NUL || (hlf != HLF_PSI && hlf != HLF_PNI)
|
||||
|| (win_hl_attr(curwin, HLF_PMSI) == win_hl_attr(curwin, HLF_PSI)
|
||||
&& win_hl_attr(curwin, HLF_PMNI) == win_hl_attr(curwin, HLF_PNI))) {
|
||||
grid_line_puts(col, text, -1, attr);
|
||||
grid_line_puts(col, text, -1, win_hl_attr(curwin, (int)hlf));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -468,7 +468,7 @@ static void pum_puts_with_attr(int col, char *text, int attr)
|
||||
while (*ptr != NUL) {
|
||||
int char_len = utfc_ptr2len(ptr);
|
||||
int cells = utf_ptr2cells(ptr);
|
||||
int new_attr = attr;
|
||||
int new_attr = win_hl_attr(curwin, (int)hlf);
|
||||
|
||||
if (ga != NULL) {
|
||||
// Handle fuzzy matching
|
||||
@@ -481,15 +481,13 @@ static void pum_puts_with_attr(int col, char *text, int attr)
|
||||
actual_char_pos++;
|
||||
}
|
||||
if (actual_char_pos == match_pos[0]) {
|
||||
new_attr = win_hl_attr(curwin, (attr == win_hl_attr(curwin, HLF_PSI)
|
||||
? HLF_PMSI : HLF_PMNI));
|
||||
new_attr = win_hl_attr(curwin, hlf == HLF_PSI ? HLF_PMSI : HLF_PMNI);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (!in_fuzzy && ptr < text + leader_len
|
||||
&& strncmp(text, match_leader, leader_len) == 0) {
|
||||
new_attr = win_hl_attr(curwin, (attr == win_hl_attr(curwin, HLF_PSI)
|
||||
? HLF_PMSI : HLF_PMNI));
|
||||
new_attr = win_hl_attr(curwin, hlf == HLF_PSI ? HLF_PMSI : HLF_PMNI);
|
||||
}
|
||||
|
||||
grid_line_puts(col, ptr, char_len, new_attr);
|
||||
@@ -517,11 +515,9 @@ void pum_redraw(void)
|
||||
int thumb_height = 1;
|
||||
int n;
|
||||
|
||||
#define HA(hlf) (win_hl_attr(curwin, (hlf)))
|
||||
// "word" "kind" "extra text"
|
||||
const int attrsNorm[3] = { HA(HLF_PNI), HA(HLF_PNK), HA(HLF_PNX) };
|
||||
const int attrsSel[3] = { HA(HLF_PSI), HA(HLF_PSK), HA(HLF_PSX) };
|
||||
#undef HA
|
||||
// "word" "kind" "extra text"
|
||||
const hlf_T hlfsNorm[3] = { HLF_PNI, HLF_PNK, HLF_PNX };
|
||||
const hlf_T hlfsSel[3] = { HLF_PSI, HLF_PSK, HLF_PSX };
|
||||
|
||||
int grid_width = pum_width;
|
||||
int col_off = 0;
|
||||
@@ -588,8 +584,9 @@ void pum_redraw(void)
|
||||
|
||||
for (int i = 0; i < pum_height; i++) {
|
||||
int idx = i + pum_first;
|
||||
const int *const attrs = (idx == pum_selected) ? attrsSel : attrsNorm;
|
||||
int attr = attrs[0]; // start with "word" highlight
|
||||
const hlf_T *const hlfs = (idx == pum_selected) ? hlfsSel : hlfsNorm;
|
||||
hlf_T hlf = hlfs[0]; // start with "word" highlight
|
||||
int attr = win_hl_attr(curwin, (int)hlf);
|
||||
|
||||
grid_line_start(&pum_grid, row);
|
||||
|
||||
@@ -611,7 +608,8 @@ void pum_redraw(void)
|
||||
int totwidth = 0;
|
||||
|
||||
for (int round = 0; round < 3; round++) {
|
||||
attr = attrs[round];
|
||||
hlf = hlfs[round];
|
||||
attr = win_hl_attr(curwin, (int)hlf);
|
||||
int width = 0;
|
||||
char *s = NULL;
|
||||
|
||||
@@ -664,12 +662,12 @@ void pum_redraw(void)
|
||||
size++;
|
||||
}
|
||||
}
|
||||
pum_puts_with_attr(grid_col - size + 1, rt, attr);
|
||||
pum_puts_with_attr(grid_col - size + 1, rt, hlf);
|
||||
xfree(rt_start);
|
||||
xfree(st);
|
||||
grid_col -= width;
|
||||
} else {
|
||||
pum_puts_with_attr(grid_col, st, attr);
|
||||
pum_puts_with_attr(grid_col, st, hlf);
|
||||
xfree(st);
|
||||
grid_col += width;
|
||||
}
|
||||
|
@@ -4597,14 +4597,14 @@ describe('builtin popupmenu', function()
|
||||
endif
|
||||
return {
|
||||
\ 'words': [
|
||||
\ { 'word': 'foo',},
|
||||
\ { 'word': 'foobar',},
|
||||
\ { 'word': 'fooBaz',},
|
||||
\ { 'word': 'foobala',},
|
||||
\ { 'word': '你好',},
|
||||
\ { 'word': '你好吗',},
|
||||
\ { 'word': '你不好吗',},
|
||||
\ { 'word': '你可好吗',},
|
||||
\ { 'word': 'foo', 'kind': 'fookind' },
|
||||
\ { 'word': 'foobar', 'kind': 'fookind' },
|
||||
\ { 'word': 'fooBaz', 'kind': 'fookind' },
|
||||
\ { 'word': 'foobala', 'kind': 'fookind' },
|
||||
\ { 'word': '你好' },
|
||||
\ { 'word': '你好吗' },
|
||||
\ { 'word': '你不好吗' },
|
||||
\ { 'word': '你可好吗' },
|
||||
\]}
|
||||
endfunc
|
||||
set omnifunc=Omni_test
|
||||
@@ -4615,14 +4615,14 @@ describe('builtin popupmenu', function()
|
||||
feed('i<C-X><C-O>')
|
||||
local pum_start = [[
|
||||
^ |
|
||||
{s:foo }{1: }|
|
||||
{n:foobar }{1: }|
|
||||
{n:fooBaz }{1: }|
|
||||
{n:foobala }{1: }|
|
||||
{n:你好 }{1: }|
|
||||
{n:你好吗 }{1: }|
|
||||
{n:你不好吗 }{1: }|
|
||||
{n:你可好吗 }{1: }|
|
||||
{s:foo fookind }{1: }|
|
||||
{n:foobar fookind }{1: }|
|
||||
{n:fooBaz fookind }{1: }|
|
||||
{n:foobala fookind }{1: }|
|
||||
{n:你好 }{1: }|
|
||||
{n:你好吗 }{1: }|
|
||||
{n:你不好吗 }{1: }|
|
||||
{n:你可好吗 }{1: }|
|
||||
{1:~ }|*10
|
||||
{2:-- }{5:match 1 of 8} |
|
||||
]]
|
||||
@@ -4630,10 +4630,10 @@ describe('builtin popupmenu', function()
|
||||
feed('fo')
|
||||
screen:expect([[
|
||||
fo^ |
|
||||
{ms:fo}{s:o }{1: }|
|
||||
{mn:fo}{n:obar }{1: }|
|
||||
{mn:fo}{n:oBaz }{1: }|
|
||||
{mn:fo}{n:obala }{1: }|
|
||||
{ms:fo}{s:o fookind }{1: }|
|
||||
{mn:fo}{n:obar fookind }{1: }|
|
||||
{mn:fo}{n:oBaz fookind }{1: }|
|
||||
{mn:fo}{n:obala fookind }{1: }|
|
||||
{1:~ }|*14
|
||||
{2:-- }{5:match 1 of 8} |
|
||||
]])
|
||||
@@ -4664,24 +4664,24 @@ describe('builtin popupmenu', function()
|
||||
feed('S<C-X><C-O>')
|
||||
screen:expect([[
|
||||
^ |
|
||||
{1: }{s: oof}|
|
||||
{1: }{n: raboof}|
|
||||
{1: }{n: zaBoof}|
|
||||
{1: }{n: alaboof}|
|
||||
{1: }{n: 好你}|
|
||||
{1: }{n: 吗好你}|
|
||||
{1: }{n: 吗好不你}|
|
||||
{1: }{n: 吗好可你}|
|
||||
{1: }{s: dnikoof oof}|
|
||||
{1: }{n: dnikoof raboof}|
|
||||
{1: }{n: dnikoof zaBoof}|
|
||||
{1: }{n: dnikoof alaboof}|
|
||||
{1: }{n: 好你}|
|
||||
{1: }{n: 吗好你}|
|
||||
{1: }{n: 吗好不你}|
|
||||
{1: }{n: 吗好可你}|
|
||||
{1: ~}|*10
|
||||
{2:-- }{5:match 1 of 8} |
|
||||
]])
|
||||
feed('fo')
|
||||
screen:expect([[
|
||||
^ of|
|
||||
{1: }{s: o}{ms:of}|
|
||||
{1: }{n: rabo}{mn:of}|
|
||||
{1: }{n: zaBo}{mn:of}|
|
||||
{1: }{n: alabo}{mn:of}|
|
||||
{1: }{s: dnikoof o}{ms:of}|
|
||||
{1: }{n: dnikoof rabo}{mn:of}|
|
||||
{1: }{n: dnikoof zaBo}{mn:of}|
|
||||
{1: }{n: dnikoofalabo}{mn:of}|
|
||||
{1: ~}|*14
|
||||
{2:-- }{5:match 1 of 8} |
|
||||
]])
|
||||
@@ -4694,10 +4694,10 @@ describe('builtin popupmenu', function()
|
||||
feed('fo')
|
||||
screen:expect([[
|
||||
fo^ |
|
||||
{ms:fo}{s:o }{1: }|
|
||||
{mn:fo}{n:obar }{1: }|
|
||||
{mn:fo}{n:oBaz }{1: }|
|
||||
{mn:fo}{n:obala }{1: }|
|
||||
{ms:fo}{s:o fookind }{1: }|
|
||||
{mn:fo}{n:obar fookind }{1: }|
|
||||
{mn:fo}{n:oBaz fookind }{1: }|
|
||||
{mn:fo}{n:obala fookind }{1: }|
|
||||
{1:~ }|*14
|
||||
{2:-- }{5:match 1 of 8} |
|
||||
]])
|
||||
|
@@ -1358,14 +1358,14 @@ func Test_pum_highlights_match()
|
||||
endif
|
||||
return {
|
||||
\ 'words': [
|
||||
\ { 'word': 'foo',},
|
||||
\ { 'word': 'foobar',},
|
||||
\ { 'word': 'fooBaz',},
|
||||
\ { 'word': 'foobala',},
|
||||
\ { 'word': '你好',},
|
||||
\ { 'word': '你好吗',},
|
||||
\ { 'word': '你不好吗',},
|
||||
\ { 'word': '你可好吗',},
|
||||
\ { 'word': 'foo', 'kind': 'fookind' },
|
||||
\ { 'word': 'foobar', 'kind': 'fookind' },
|
||||
\ { 'word': 'fooBaz', 'kind': 'fookind' },
|
||||
\ { 'word': 'foobala', 'kind': 'fookind' },
|
||||
\ { 'word': '你好' },
|
||||
\ { 'word': '你好吗' },
|
||||
\ { 'word': '你不好吗' },
|
||||
\ { 'word': '你可好吗' },
|
||||
\]}
|
||||
endfunc
|
||||
set omnifunc=Omni_test
|
||||
|
Reference in New Issue
Block a user