vim-patch:9.1.0534: completion wrong with fuzzy when cycling back to original (#29588)

Problem:  completion wrong with fuzzy when cycling back to original
          (Quan Nguyen)
Solution: reset show_match_ok when cp_score is zero (glepnir)

fixes: vim/vim#15095
closes: vim/vim#15105

65407ce1d2

Co-authored-by: glepnir <glephunter@gmail.com>
This commit is contained in:
zeertzjq
2024-07-06 22:44:37 +08:00
committed by GitHub
parent bdc6e38781
commit 7a54d707fa
3 changed files with 41 additions and 3 deletions

View File

@@ -1240,6 +1240,10 @@ static int ins_compl_build_pum(void)
did_find_shown_match = true;
max_fuzzy_score = comp->cp_score;
compl_shown_match = comp;
}
if (!shown_match_ok && comp == compl_shown_match && !compl_no_select) {
cur = i;
shown_match_ok = true;
}
@@ -1250,8 +1254,6 @@ static int ins_compl_build_pum(void)
if (!compl_no_select
&& (max_fuzzy_score > 0
|| (compl_leader == NULL || lead_len == 0))) {
shown_match_ok = true;
cur = 0;
if (match_at_original_text(compl_shown_match)) {
compl_shown_match = shown_compl;
}
@@ -1299,6 +1301,7 @@ static int ins_compl_build_pum(void)
// sort by the largest score of fuzzy match
qsort(compl_match_array, (size_t)compl_match_arraysize, sizeof(pumitem_T),
ins_compl_fuzzy_cmp);
shown_match_ok = true;
}
if (!shown_match_ok) { // no displayed match at all
@@ -3651,7 +3654,9 @@ static compl_T *find_comp_when_fuzzy(void)
if (compl_match_array == NULL
|| (is_forward && compl_selected_item == compl_match_arraysize - 1)
|| (is_backward && compl_selected_item == 0)) {
return compl_first_match;
return compl_first_match != compl_shown_match
? compl_first_match
: (compl_first_match->cp_prev ? compl_first_match->cp_prev : NULL);
}
if (is_forward) {