summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-06-14 20:24:22 +0200
committerChristian Brabandt <cb@256bit.org>2024-06-14 20:24:22 +0200
commitafbe5359e981e5d19ad23c394aefe60395c3648e (patch)
tree9f5afd2c8f6b910b2447aee5cc3610386dfb09f1
parentc509c009bbc07eff678a9239a5813398e180f019 (diff)
patch 9.1.0485: Matched text shouldn't be highlighted in "kind" and "menu"v9.1.0485
Problem: Matched text shouldn't be highlighted in "kind" and "menu". Solution: Pass hlf_T instead of the attribute. Fix indent. (zeertzjq) closes: #14996 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
-rw-r--r--src/popupmenu.c118
-rw-r--r--src/testdir/dumps/Test_pum_highlights_03.dump8
-rw-r--r--src/testdir/dumps/Test_pum_highlights_06.dump8
-rw-r--r--src/testdir/dumps/Test_pum_highlights_07.dump8
-rw-r--r--src/testdir/test_popup.vim16
-rw-r--r--src/version.c2
6 files changed, 82 insertions, 78 deletions
diff --git a/src/popupmenu.c b/src/popupmenu.c
index 09ed57427f..7fb29d6358 100644
--- a/src/popupmenu.c
+++ b/src/popupmenu.c
@@ -420,7 +420,7 @@ pum_under_menu(int row, int col, int only_redrawing)
* displays text on the popup menu with specific attributes.
*/
static void
-pum_screen_put_with_attr(int row, int col, char_u *text, int textlen, int attr)
+pum_screen_put_with_attr(int row, int col, char_u *text, int textlen, hlf_T hlf)
{
int i;
int leader_len;
@@ -434,69 +434,68 @@ pum_screen_put_with_attr(int row, int col, char_u *text, int textlen, int attr)
char_u *leader = ins_compl_leader();
int in_fuzzy = (get_cot_flags() & COT_FUZZY) != 0;
- if (leader == NULL || *leader == NUL ||
- (highlight_attr[HLF_PMSI] == highlight_attr[HLF_PSI] &&
- highlight_attr[HLF_PMNI] == highlight_attr[HLF_PNI]))
+ if (leader == NULL || *leader == NUL || (hlf != HLF_PSI && hlf != HLF_PNI)
+ || (highlight_attr[HLF_PMSI] == highlight_attr[HLF_PSI]
+ && highlight_attr[HLF_PMNI] == highlight_attr[HLF_PNI]))
{
- screen_puts_len(text, textlen, row, col, attr);
- return;
+ screen_puts_len(text, textlen, row, col, highlight_attr[hlf]);
+ return;
}
#ifdef FEAT_RIGHTLEFT
if (curwin->w_p_rl)
- rt_leader = reverse_text(leader);
+ rt_leader = reverse_text(leader);
#endif
match_leader = rt_leader != NULL ? rt_leader : leader;
leader_len = (int)STRLEN(match_leader);
if (in_fuzzy)
- ga = fuzzy_match_str_with_pos(text, match_leader);
+ ga = fuzzy_match_str_with_pos(text, match_leader);
// Render text with proper attributes
while (*ptr != NUL && ptr < text + textlen)
{
- char_len = mb_ptr2len(ptr);
- cells = mb_ptr2cells(ptr);
- new_attr = attr;
-
- if (ga != NULL)
- {
- // Handle fuzzy matching
- for (i = 0; i < ga->ga_len; i++)
- {
- int_u *match_pos = ((int_u *)ga->ga_data) + i;
- int_u actual_char_pos = 0;
- char_u *temp_ptr = text;
- while (temp_ptr < ptr)
- {
- temp_ptr += mb_ptr2len(temp_ptr);
- actual_char_pos++;
- }
- if (actual_char_pos == match_pos[0])
- {
- new_attr = highlight_attr[(attr == highlight_attr[HLF_PSI]
- ? HLF_PMSI : HLF_PMNI)];
- break;
- }
- }
- }
- else if (!in_fuzzy && (ptr - text < leader_len) &&
- (STRNCMP(text, match_leader, leader_len) == 0))
- new_attr = highlight_attr[(attr == highlight_attr[HLF_PSI]
- ? HLF_PMSI : HLF_PMNI)];
-
- screen_puts_len(ptr, char_len, row, col, new_attr);
- col += cells;
- ptr += char_len;
+ char_len = mb_ptr2len(ptr);
+ cells = mb_ptr2cells(ptr);
+ new_attr = highlight_attr[hlf];
+
+ if (ga != NULL)
+ {
+ // Handle fuzzy matching
+ for (i = 0; i < ga->ga_len; i++)
+ {
+ int_u *match_pos = ((int_u *)ga->ga_data) + i;
+ int_u actual_char_pos = 0;
+ char_u *temp_ptr = text;
+ while (temp_ptr < ptr)
+ {
+ temp_ptr += mb_ptr2len(temp_ptr);
+ actual_char_pos++;
+ }
+ if (actual_char_pos == match_pos[0])
+ {
+ new_attr = highlight_attr[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 = highlight_attr[hlf == HLF_PSI ? HLF_PMSI : HLF_PMNI];
+
+ screen_puts_len(ptr, char_len, row, col, new_attr);
+ col += cells;
+ ptr += char_len;
}
if (ga != NULL)
{
- ga_clear(ga);
- vim_free(ga);
+ ga_clear(ga);
+ vim_free(ga);
}
if (rt_leader)
- vim_free(rt_leader);
+ vim_free(rt_leader);
}
/*
@@ -509,8 +508,9 @@ pum_redraw(void)
int col;
int attr_scroll = highlight_attr[HLF_PSB];
int attr_thumb = highlight_attr[HLF_PST];
+ hlf_T *hlfs; // array used for highlights
+ hlf_T hlf;
int attr;
- int *attrs; // array used for highlights
int i;
int idx;
char_u *s;
@@ -521,17 +521,17 @@ pum_redraw(void)
int round;
int n;
- int attrsNorm[3];
- int attrsSel[3];
+ hlf_T hlfsNorm[3];
+ hlf_T hlfsSel[3];
// "word"
- attrsNorm[0] = highlight_attr[HLF_PNI];
- attrsSel[0] = highlight_attr[HLF_PSI];
+ hlfsNorm[0] = HLF_PNI;
+ hlfsSel[0] = HLF_PSI;
// "kind"
- attrsNorm[1] = highlight_attr[HLF_PNK];
- attrsSel[1] = highlight_attr[HLF_PSK];
+ hlfsNorm[1] = HLF_PNK;
+ hlfsSel[1] = HLF_PSK;
// "extra text"
- attrsNorm[2] = highlight_attr[HLF_PNX];
- attrsSel[2] = highlight_attr[HLF_PSX];
+ hlfsNorm[2] = HLF_PNX;
+ hlfsSel[2] = HLF_PSX;
if (call_update_screen)
{
@@ -566,8 +566,9 @@ pum_redraw(void)
for (i = 0; i < pum_height; ++i)
{
idx = i + pum_first;
- attrs = (idx == pum_selected) ? attrsSel : attrsNorm;
- attr = attrs[0]; // start with "word" highlight
+ hlfs = (idx == pum_selected) ? hlfsSel : hlfsNorm;
+ hlf = hlfs[0]; // start with "word" highlight
+ attr = highlight_attr[hlf];
// prepend a space if there is room
#ifdef FEAT_RIGHTLEFT
@@ -590,7 +591,8 @@ pum_redraw(void)
totwidth = 0;
for (round = 0; round < 3; ++round)
{
- attr = attrs[round];
+ hlf = hlfs[round];
+ attr = highlight_attr[hlf];
width = 0;
s = NULL;
switch (round)
@@ -650,7 +652,7 @@ pum_redraw(void)
size++;
}
}
- pum_screen_put_with_attr(row, col -size + 1, rt, (int)STRLEN(rt), attr);
+ pum_screen_put_with_attr(row, col - size + 1, rt, (int)STRLEN(rt), hlf);
vim_free(rt_start);
}
vim_free(st);
@@ -678,7 +680,7 @@ pum_redraw(void)
else
--cells;
}
- pum_screen_put_with_attr(row, col, st, size, attr);
+ pum_screen_put_with_attr(row, col, st, size, hlf);
vim_free(st);
}
col += width;
diff --git a/src/testdir/dumps/Test_pum_highlights_03.dump b/src/testdir/dumps/Test_pum_highlights_03.dump
index 259e498b7c..094660a37a 100644
--- a/src/testdir/dumps/Test_pum_highlights_03.dump
+++ b/src/testdir/dumps/Test_pum_highlights_03.dump
@@ -1,8 +1,8 @@
|f+0&#ffffff0|o> @72
-|f+0#00e0e07#ffd7ff255|o|o+0#0000001#e0e0e08| @11| +0#4040ff13#ffffff0@59
-|f+0#0000e05#ffd7ff255|o|o+0#0000001&|b|a|r| @8| +0#4040ff13#ffffff0@59
-|f+0#0000e05#ffd7ff255|o|o+0#0000001&|B|a|z| @8| +0#4040ff13#ffffff0@59
-|f+0#0000e05#ffd7ff255|o|o+0#0000001&|b|a|l|a| @7| +0#4040ff13#ffffff0@59
+|f+0#00e0e07#ffd7ff255|o|o+0#0000001#e0e0e08| @4|f|o@1|k|i|n|d| | +0#4040ff13#ffffff0@58
+|f+0#0000e05#ffd7ff255|o|o+0#0000001&|b|a|r| @1|f|o@1|k|i|n|d| | +0#4040ff13#ffffff0@58
+|f+0#0000e05#ffd7ff255|o|o+0#0000001&|B|a|z| @1|f|o@1|k|i|n|d| | +0#4040ff13#ffffff0@58
+|f+0#0000e05#ffd7ff255|o|o+0#0000001&|b|a|l|a| |f|o@1|k|i|n|d| | +0#4040ff13#ffffff0@58
|~| @73
|~| @73
|~| @73
diff --git a/src/testdir/dumps/Test_pum_highlights_06.dump b/src/testdir/dumps/Test_pum_highlights_06.dump
index cb9ca42e95..6675a3135d 100644
--- a/src/testdir/dumps/Test_pum_highlights_06.dump
+++ b/src/testdir/dumps/Test_pum_highlights_06.dump
@@ -1,8 +1,8 @@
| +0&#ffffff0@70|o>f|o|f
-| +0#4040ff13&@59| +0#0000001#e0e0e08@11|o|o+0#00e0e07#ffd7ff255|f
-| +0#4040ff13#ffffff0@59| +0#0000001#ffd7ff255@8|r|a|b|o|o+0#0000e05&|f
-| +0#4040ff13#ffffff0@59| +0#0000001#ffd7ff255@8|z|a|B|o|o+0#0000e05&|f
-| +0#4040ff13#ffffff0@59| +0#0000001#ffd7ff255@7|a|l|a|b|o|o+0#0000e05&|f
+| +0#4040ff13&@58| +0#0000001#e0e0e08@1|d|n|i|k|o@1|f| @3|o|o+0#00e0e07#ffd7ff255|f
+| +0#4040ff13#ffffff0@58| +0#0000001#ffd7ff255@1|d|n|i|k|o@1|f| |r|a|b|o|o+0#0000e05&|f
+| +0#4040ff13#ffffff0@58| +0#0000001#ffd7ff255@1|d|n|i|k|o@1|f| |z|a|B|o|o+0#0000e05&|f
+| +0#4040ff13#ffffff0@58| +0#0000001#ffd7ff255@1|d|n|i|k|o@1|f|a|l|a|b|o|o+0#0000e05&|f
| +0#4040ff13#ffffff0@73|~
| @73|~
| @73|~
diff --git a/src/testdir/dumps/Test_pum_highlights_07.dump b/src/testdir/dumps/Test_pum_highlights_07.dump
index 259e498b7c..094660a37a 100644
--- a/src/testdir/dumps/Test_pum_highlights_07.dump
+++ b/src/testdir/dumps/Test_pum_highlights_07.dump
@@ -1,8 +1,8 @@
|f+0&#ffffff0|o> @72
-|f+0#00e0e07#ffd7ff255|o|o+0#0000001#e0e0e08| @11| +0#4040ff13#ffffff0@59
-|f+0#0000e05#ffd7ff255|o|o+0#0000001&|b|a|r| @8| +0#4040ff13#ffffff0@59
-|f+0#0000e05#ffd7ff255|o|o+0#0000001&|B|a|z| @8| +0#4040ff13#ffffff0@59
-|f+0#0000e05#ffd7ff255|o|o+0#0000001&|b|a|l|a| @7| +0#4040ff13#ffffff0@59
+|f+0#00e0e07#ffd7ff255|o|o+0#0000001#e0e0e08| @4|f|o@1|k|i|n|d| | +0#4040ff13#ffffff0@58
+|f+0#0000e05#ffd7ff255|o|o+0#0000001&|b|a|r| @1|f|o@1|k|i|n|d| | +0#4040ff13#ffffff0@58
+|f+0#0000e05#ffd7ff255|o|o+0#0000001&|B|a|z| @1|f|o@1|k|i|n|d| | +0#4040ff13#ffffff0@58
+|f+0#0000e05#ffd7ff255|o|o+0#0000001&|b|a|l|a| |f|o@1|k|i|n|d| | +0#4040ff13#ffffff0@58
|~| @73
|~| @73
|~| @73
diff --git a/src/testdir/test_popup.vim b/src/testdir/test_popup.vim
index 86262887bb..ace1021a60 100644
--- a/src/testdir/test_popup.vim
+++ b/src/testdir/test_popup.vim
@@ -1351,14 +1351,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
diff --git a/src/version.c b/src/version.c
index 36761aaed5..7c8a10142e 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 485,
+/**/
484,
/**/
483,