mirror of
https://github.com/neovim/neovim.git
synced 2026-04-27 17:54:10 +00:00
vim-patch:9.1.1452: completion: redundant check for completion flags (#34434)
Problem: completion: redundant check for completion flags
Solution: refactor code slightly (glepnir)
refactor: nest fuzzy completion logic to avoid duplicate flag checks
- Combine COT_FUZZY checks into single nested condition
- Reduce redundant bitwise operations in ins_compl_new_leader()
closes: vim/vim#17494
ecf8f15884
Co-authored-by: glepnir <glephunter@gmail.com>
This commit is contained in:
@@ -2106,6 +2106,7 @@ static bool ins_compl_need_restart(void)
|
|||||||
/// May also search for matches again if the previous search was interrupted.
|
/// May also search for matches again if the previous search was interrupted.
|
||||||
static void ins_compl_new_leader(void)
|
static void ins_compl_new_leader(void)
|
||||||
{
|
{
|
||||||
|
unsigned cur_cot_flags = get_cot_flags();
|
||||||
ins_compl_del_pum();
|
ins_compl_del_pum();
|
||||||
ins_compl_delete(true);
|
ins_compl_delete(true);
|
||||||
ins_compl_insert_bytes(compl_leader.data + get_compl_len(), -1);
|
ins_compl_insert_bytes(compl_leader.data + get_compl_len(), -1);
|
||||||
@@ -2127,19 +2128,18 @@ static void ins_compl_new_leader(void)
|
|||||||
compl_restarting = false;
|
compl_restarting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// When 'cot' contains "fuzzy" set the cp_score
|
// When 'cot' contains "fuzzy" set the cp_score and maybe sort
|
||||||
if (get_cot_flags() & kOptCotFlagFuzzy) {
|
if (cur_cot_flags & kOptCotFlagFuzzy) {
|
||||||
set_fuzzy_score();
|
set_fuzzy_score();
|
||||||
}
|
// Sort the matches linked list based on fuzzy score
|
||||||
// Sort the matches linked list based on fuzzy score
|
if (!(cur_cot_flags & kOptCotFlagNosort)) {
|
||||||
unsigned cur_cot_flags = get_cot_flags();
|
sort_compl_match_list(cp_compare_fuzzy);
|
||||||
if ((cur_cot_flags & kOptCotFlagFuzzy) && !(cur_cot_flags & kOptCotFlagNosort)) {
|
if ((cur_cot_flags & (kOptCotFlagNoinsert|kOptCotFlagNoselect)) == kOptCotFlagNoinsert
|
||||||
sort_compl_match_list(cp_compare_fuzzy);
|
&& compl_first_match) {
|
||||||
if ((cur_cot_flags & kOptCotFlagNoinsert) && !(cur_cot_flags & kOptCotFlagNoselect)
|
compl_shown_match = compl_first_match;
|
||||||
&& compl_first_match) {
|
if (compl_shows_dir_forward()) {
|
||||||
compl_shown_match = compl_first_match;
|
compl_shown_match = compl_first_match->cp_next;
|
||||||
if (compl_shows_dir_forward()) {
|
}
|
||||||
compl_shown_match = compl_first_match->cp_next;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user