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.
|
/// 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();
|
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_PMSI) == win_hl_attr(curwin, HLF_PSI)
|
||||||
&& win_hl_attr(curwin, HLF_PMNI) == win_hl_attr(curwin, HLF_PNI))) {
|
&& 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,7 +468,7 @@ static void pum_puts_with_attr(int col, char *text, int attr)
|
|||||||
while (*ptr != NUL) {
|
while (*ptr != NUL) {
|
||||||
int char_len = utfc_ptr2len(ptr);
|
int char_len = utfc_ptr2len(ptr);
|
||||||
int cells = utf_ptr2cells(ptr);
|
int cells = utf_ptr2cells(ptr);
|
||||||
int new_attr = attr;
|
int new_attr = win_hl_attr(curwin, (int)hlf);
|
||||||
|
|
||||||
if (ga != NULL) {
|
if (ga != NULL) {
|
||||||
// Handle fuzzy matching
|
// Handle fuzzy matching
|
||||||
@@ -481,15 +481,13 @@ static void pum_puts_with_attr(int col, char *text, int attr)
|
|||||||
actual_char_pos++;
|
actual_char_pos++;
|
||||||
}
|
}
|
||||||
if (actual_char_pos == match_pos[0]) {
|
if (actual_char_pos == match_pos[0]) {
|
||||||
new_attr = win_hl_attr(curwin, (attr == win_hl_attr(curwin, HLF_PSI)
|
new_attr = win_hl_attr(curwin, hlf == HLF_PSI ? HLF_PMSI : HLF_PMNI);
|
||||||
? HLF_PMSI : HLF_PMNI));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (!in_fuzzy && ptr < text + leader_len
|
} else if (!in_fuzzy && ptr < text + leader_len
|
||||||
&& strncmp(text, match_leader, leader_len) == 0) {
|
&& strncmp(text, match_leader, leader_len) == 0) {
|
||||||
new_attr = win_hl_attr(curwin, (attr == win_hl_attr(curwin, HLF_PSI)
|
new_attr = win_hl_attr(curwin, hlf == HLF_PSI ? HLF_PMSI : HLF_PMNI);
|
||||||
? HLF_PMSI : HLF_PMNI));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
grid_line_puts(col, ptr, char_len, new_attr);
|
grid_line_puts(col, ptr, char_len, new_attr);
|
||||||
@@ -517,11 +515,9 @@ void pum_redraw(void)
|
|||||||
int thumb_height = 1;
|
int thumb_height = 1;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
#define HA(hlf) (win_hl_attr(curwin, (hlf)))
|
|
||||||
// "word" "kind" "extra text"
|
// "word" "kind" "extra text"
|
||||||
const int attrsNorm[3] = { HA(HLF_PNI), HA(HLF_PNK), HA(HLF_PNX) };
|
const hlf_T hlfsNorm[3] = { HLF_PNI, HLF_PNK, HLF_PNX };
|
||||||
const int attrsSel[3] = { HA(HLF_PSI), HA(HLF_PSK), HA(HLF_PSX) };
|
const hlf_T hlfsSel[3] = { HLF_PSI, HLF_PSK, HLF_PSX };
|
||||||
#undef HA
|
|
||||||
|
|
||||||
int grid_width = pum_width;
|
int grid_width = pum_width;
|
||||||
int col_off = 0;
|
int col_off = 0;
|
||||||
@@ -588,8 +584,9 @@ void pum_redraw(void)
|
|||||||
|
|
||||||
for (int i = 0; i < pum_height; i++) {
|
for (int i = 0; i < pum_height; i++) {
|
||||||
int idx = i + pum_first;
|
int idx = i + pum_first;
|
||||||
const int *const attrs = (idx == pum_selected) ? attrsSel : attrsNorm;
|
const hlf_T *const hlfs = (idx == pum_selected) ? hlfsSel : hlfsNorm;
|
||||||
int attr = attrs[0]; // start with "word" highlight
|
hlf_T hlf = hlfs[0]; // start with "word" highlight
|
||||||
|
int attr = win_hl_attr(curwin, (int)hlf);
|
||||||
|
|
||||||
grid_line_start(&pum_grid, row);
|
grid_line_start(&pum_grid, row);
|
||||||
|
|
||||||
@@ -611,7 +608,8 @@ void pum_redraw(void)
|
|||||||
int totwidth = 0;
|
int totwidth = 0;
|
||||||
|
|
||||||
for (int round = 0; round < 3; round++) {
|
for (int round = 0; round < 3; round++) {
|
||||||
attr = attrs[round];
|
hlf = hlfs[round];
|
||||||
|
attr = win_hl_attr(curwin, (int)hlf);
|
||||||
int width = 0;
|
int width = 0;
|
||||||
char *s = NULL;
|
char *s = NULL;
|
||||||
|
|
||||||
@@ -664,12 +662,12 @@ void pum_redraw(void)
|
|||||||
size++;
|
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(rt_start);
|
||||||
xfree(st);
|
xfree(st);
|
||||||
grid_col -= width;
|
grid_col -= width;
|
||||||
} else {
|
} else {
|
||||||
pum_puts_with_attr(grid_col, st, attr);
|
pum_puts_with_attr(grid_col, st, hlf);
|
||||||
xfree(st);
|
xfree(st);
|
||||||
grid_col += width;
|
grid_col += width;
|
||||||
}
|
}
|
||||||
|
@@ -4597,14 +4597,14 @@ describe('builtin popupmenu', function()
|
|||||||
endif
|
endif
|
||||||
return {
|
return {
|
||||||
\ 'words': [
|
\ 'words': [
|
||||||
\ { 'word': 'foo',},
|
\ { 'word': 'foo', 'kind': 'fookind' },
|
||||||
\ { 'word': 'foobar',},
|
\ { 'word': 'foobar', 'kind': 'fookind' },
|
||||||
\ { 'word': 'fooBaz',},
|
\ { 'word': 'fooBaz', 'kind': 'fookind' },
|
||||||
\ { 'word': 'foobala',},
|
\ { 'word': 'foobala', 'kind': 'fookind' },
|
||||||
\ { 'word': '你好',},
|
\ { 'word': '你好' },
|
||||||
\ { 'word': '你好吗',},
|
\ { 'word': '你好吗' },
|
||||||
\ { 'word': '你不好吗',},
|
\ { 'word': '你不好吗' },
|
||||||
\ { 'word': '你可好吗',},
|
\ { 'word': '你可好吗' },
|
||||||
\]}
|
\]}
|
||||||
endfunc
|
endfunc
|
||||||
set omnifunc=Omni_test
|
set omnifunc=Omni_test
|
||||||
@@ -4615,10 +4615,10 @@ describe('builtin popupmenu', function()
|
|||||||
feed('i<C-X><C-O>')
|
feed('i<C-X><C-O>')
|
||||||
local pum_start = [[
|
local pum_start = [[
|
||||||
^ |
|
^ |
|
||||||
{s:foo }{1: }|
|
{s:foo fookind }{1: }|
|
||||||
{n:foobar }{1: }|
|
{n:foobar fookind }{1: }|
|
||||||
{n:fooBaz }{1: }|
|
{n:fooBaz fookind }{1: }|
|
||||||
{n:foobala }{1: }|
|
{n:foobala fookind }{1: }|
|
||||||
{n:你好 }{1: }|
|
{n:你好 }{1: }|
|
||||||
{n:你好吗 }{1: }|
|
{n:你好吗 }{1: }|
|
||||||
{n:你不好吗 }{1: }|
|
{n:你不好吗 }{1: }|
|
||||||
@@ -4630,10 +4630,10 @@ describe('builtin popupmenu', function()
|
|||||||
feed('fo')
|
feed('fo')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
fo^ |
|
fo^ |
|
||||||
{ms:fo}{s:o }{1: }|
|
{ms:fo}{s:o fookind }{1: }|
|
||||||
{mn:fo}{n:obar }{1: }|
|
{mn:fo}{n:obar fookind }{1: }|
|
||||||
{mn:fo}{n:oBaz }{1: }|
|
{mn:fo}{n:oBaz fookind }{1: }|
|
||||||
{mn:fo}{n:obala }{1: }|
|
{mn:fo}{n:obala fookind }{1: }|
|
||||||
{1:~ }|*14
|
{1:~ }|*14
|
||||||
{2:-- }{5:match 1 of 8} |
|
{2:-- }{5:match 1 of 8} |
|
||||||
]])
|
]])
|
||||||
@@ -4664,10 +4664,10 @@ describe('builtin popupmenu', function()
|
|||||||
feed('S<C-X><C-O>')
|
feed('S<C-X><C-O>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
^ |
|
^ |
|
||||||
{1: }{s: oof}|
|
{1: }{s: dnikoof oof}|
|
||||||
{1: }{n: raboof}|
|
{1: }{n: dnikoof raboof}|
|
||||||
{1: }{n: zaBoof}|
|
{1: }{n: dnikoof zaBoof}|
|
||||||
{1: }{n: alaboof}|
|
{1: }{n: dnikoof alaboof}|
|
||||||
{1: }{n: 好你}|
|
{1: }{n: 好你}|
|
||||||
{1: }{n: 吗好你}|
|
{1: }{n: 吗好你}|
|
||||||
{1: }{n: 吗好不你}|
|
{1: }{n: 吗好不你}|
|
||||||
@@ -4678,10 +4678,10 @@ describe('builtin popupmenu', function()
|
|||||||
feed('fo')
|
feed('fo')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
^ of|
|
^ of|
|
||||||
{1: }{s: o}{ms:of}|
|
{1: }{s: dnikoof o}{ms:of}|
|
||||||
{1: }{n: rabo}{mn:of}|
|
{1: }{n: dnikoof rabo}{mn:of}|
|
||||||
{1: }{n: zaBo}{mn:of}|
|
{1: }{n: dnikoof zaBo}{mn:of}|
|
||||||
{1: }{n: alabo}{mn:of}|
|
{1: }{n: dnikoofalabo}{mn:of}|
|
||||||
{1: ~}|*14
|
{1: ~}|*14
|
||||||
{2:-- }{5:match 1 of 8} |
|
{2:-- }{5:match 1 of 8} |
|
||||||
]])
|
]])
|
||||||
@@ -4694,10 +4694,10 @@ describe('builtin popupmenu', function()
|
|||||||
feed('fo')
|
feed('fo')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
fo^ |
|
fo^ |
|
||||||
{ms:fo}{s:o }{1: }|
|
{ms:fo}{s:o fookind }{1: }|
|
||||||
{mn:fo}{n:obar }{1: }|
|
{mn:fo}{n:obar fookind }{1: }|
|
||||||
{mn:fo}{n:oBaz }{1: }|
|
{mn:fo}{n:oBaz fookind }{1: }|
|
||||||
{mn:fo}{n:obala }{1: }|
|
{mn:fo}{n:obala fookind }{1: }|
|
||||||
{1:~ }|*14
|
{1:~ }|*14
|
||||||
{2:-- }{5:match 1 of 8} |
|
{2:-- }{5:match 1 of 8} |
|
||||||
]])
|
]])
|
||||||
|
@@ -1358,14 +1358,14 @@ func Test_pum_highlights_match()
|
|||||||
endif
|
endif
|
||||||
return {
|
return {
|
||||||
\ 'words': [
|
\ 'words': [
|
||||||
\ { 'word': 'foo',},
|
\ { 'word': 'foo', 'kind': 'fookind' },
|
||||||
\ { 'word': 'foobar',},
|
\ { 'word': 'foobar', 'kind': 'fookind' },
|
||||||
\ { 'word': 'fooBaz',},
|
\ { 'word': 'fooBaz', 'kind': 'fookind' },
|
||||||
\ { 'word': 'foobala',},
|
\ { 'word': 'foobala', 'kind': 'fookind' },
|
||||||
\ { 'word': '你好',},
|
\ { 'word': '你好' },
|
||||||
\ { 'word': '你好吗',},
|
\ { 'word': '你好吗' },
|
||||||
\ { 'word': '你不好吗',},
|
\ { 'word': '你不好吗' },
|
||||||
\ { 'word': '你可好吗',},
|
\ { 'word': '你可好吗' },
|
||||||
\]}
|
\]}
|
||||||
endfunc
|
endfunc
|
||||||
set omnifunc=Omni_test
|
set omnifunc=Omni_test
|
||||||
|
Reference in New Issue
Block a user