int *attrs = NULL;
char_u *leader = NULL;
int in_fuzzy;
- int matched_start = FALSE;
+ int matched_len = -1;
int_u char_pos = 0;
int is_select = FALSE;
if (in_fuzzy)
ga = fuzzy_match_str_with_pos(text, leader);
- else
- matched_start = MB_STRNICMP(text, leader, leader_len) == 0;
while (*ptr != NUL)
{
}
}
}
- else if (matched_start && ptr < text + leader_len)
+ else
{
- new_attr = highlight_attr[is_select ? HLF_PMSI : HLF_PMNI];
- new_attr = hl_combine_attr(highlight_attr[hlf], new_attr);
+ if (matched_len < 0 && MB_STRNICMP(ptr, leader, leader_len) == 0)
+ matched_len = leader_len;
+ if (matched_len > 0)
+ {
+ new_attr = highlight_attr[is_select ? HLF_PMSI : HLF_PMNI];
+ new_attr = hl_combine_attr(highlight_attr[hlf], new_attr);
+ matched_len--;
+ }
}
new_attr = hl_combine_attr(highlight_attr[HLF_PNI], new_attr);
--- /dev/null
+| +0&#ffffff0@49
+|~+0#4040ff13&| @48
+|~| @48
+|~| @48
+|~| @48
+|~| @48
+|~| @4| +0#0000001#ffd7ff255|o|n+0#0000e05&|e|A+0#0000001&| @10| +0#4040ff13#ffffff0@27
+|~| @4| +0#0000001#ffd7ff255|o| |n+0#0000e05&|e|B+0#0000001&|n|e|B| @6| +0#4040ff13#ffffff0@27
+|~| @4| +0#0000001#ffd7ff255|a|o|n+0#0000e05&|e|C+0#0000001&| @9| +0#4040ff13#ffffff0@27
+|:+0#0000000&|M|y|C|m|d| |n|e> @40
call StopVimInTerminal(buf)
endfunc
+" Test highlighting when pattern matches non-first character of item
+func Test_wildmenu_pum_hl_nonfirst()
+ CheckScreendump
+ let lines =<< trim END
+ set wildoptions=pum wildchar=<tab> wildmode=noselect,full
+ hi PmenuMatchSel ctermfg=6 ctermbg=7
+ hi PmenuMatch ctermfg=4 ctermbg=225
+ func T(a, c, p)
+ return ["oneA", "o neBneB", "aoneC"]
+ endfunc
+ command -nargs=1 -complete=customlist,T MyCmd
+ END
+
+ call writefile(lines, 'Xwildmenu_pum_hl_nonf', 'D')
+ let buf = RunVimInTerminal('-S Xwildmenu_pum_hl_nonf', #{rows: 10, cols: 50})
+
+ call term_sendkeys(buf, ":MyCmd ne\<tab>")
+ call VerifyScreenDump(buf, 'Test_wildmenu_pum_hl_match_nonf', {})
+ call term_sendkeys(buf, "\<Esc>")
+ call StopVimInTerminal(buf)
+endfunc
+
" Test highlighting matched text in cmdline completion popup menu.
func Test_wildmenu_pum_hl_match()
CheckScreendump