vim-patch:9.1.0480: fuzzy string matching executed when not needed

Problem:  fuzzy string matching executed when not needed
Solution: when no leader is available, can skip fuzzy logic, so return
          early (glepnir)

closes: vim/vim#14986

1c29602662

Co-authored-by: glepnir <glephunter@gmail.com>
This commit is contained in:
zeertzjq 2024-06-14 04:36:44 +08:00
parent e2ef533025
commit 53b2817fd3

View File

@ -442,23 +442,24 @@ static void pum_puts_with_attr(int col, char *text, int attr)
{
char *leader = ins_compl_leader();
if ((win_hl_attr(curwin, HLF_PMSI) == win_hl_attr(curwin, HLF_PSI)
&& win_hl_attr(curwin, HLF_PMNI) == win_hl_attr(curwin, HLF_PNI))) {
if (leader == NULL || *leader == NUL
|| (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);
return;
}
char *rt_leader = NULL;
if (leader != NULL && curwin->w_p_rl) {
if (curwin->w_p_rl) {
rt_leader = reverse_text(leader);
}
char *match_leader = rt_leader != NULL ? rt_leader : leader;
size_t leader_len = match_leader ? strlen(match_leader) : 0;
size_t leader_len = strlen(match_leader);
const bool in_fuzzy = (get_cot_flags() & COT_FUZZY) != 0;
garray_T *ga = NULL;
if (match_leader != NULL && leader_len > 0 && in_fuzzy) {
if (in_fuzzy) {
ga = fuzzy_match_str_with_pos(text, match_leader);
}