patch 9.1.1452: completion: redundant check for completion flags Commit: https://github.com/vim/vim/commit/ecf8f15884bc794ae07d5beac0d595013154c795 Author: glepnir <glephun...@gmail.com> Date: Tue Jun 10 20:52:41 2025 +0200
patch 9.1.1452: completion: redundant check for completion flags 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: #17494 Signed-off-by: glepnir <glephun...@gmail.com> Signed-off-by: Christian Brabandt <c...@256bit.org> diff --git a/src/insexpand.c b/src/insexpand.c index 9ee73e15e..2d398877b 100644 --- a/src/insexpand.c +++ b/src/insexpand.c @@ -2316,6 +2316,7 @@ ins_compl_need_restart(void) static void ins_compl_new_leader(void) { + int cur_cot_flags = get_cot_flags(); ins_compl_del_pum(); ins_compl_delete(); ins_compl_insert_bytes(compl_leader.string + get_compl_len(), -1); @@ -2350,20 +2351,21 @@ ins_compl_new_leader(void) compl_restarting = FALSE; } - // When 'cot' contains "fuzzy" set the cp_score - if (get_cot_flags() & COT_FUZZY) - set_fuzzy_score(); - // Sort the matches linked list based on fuzzy score - int cur_cot_flags = get_cot_flags(); - if ((cur_cot_flags & COT_FUZZY) && !(cur_cot_flags & COT_NOSORT)) + // When 'cot' contains "fuzzy" set the cp_score and maybe sort + if (cur_cot_flags & COT_FUZZY) { - sort_compl_match_list(cp_compare_fuzzy); - if ((cur_cot_flags & COT_NOINSERT) && !(cur_cot_flags & COT_NOSELECT) - && compl_first_match) + set_fuzzy_score(); + // Sort the matches linked list based on fuzzy score + if (!(cur_cot_flags & COT_NOSORT)) { - compl_shown_match = compl_first_match; - if (compl_shows_dir_forward()) - compl_shown_match = compl_first_match->cp_next; + sort_compl_match_list(cp_compare_fuzzy); + if ((cur_cot_flags & (COT_NOINSERT | COT_NOSELECT)) == COT_NOINSERT + && compl_first_match) + { + compl_shown_match = compl_first_match; + if (compl_shows_dir_forward()) + compl_shown_match = compl_first_match->cp_next; + } } } diff --git a/src/version.c b/src/version.c index da96e54a0..9e37c250b 100644 --- a/src/version.c +++ b/src/version.c @@ -709,6 +709,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1452, /**/ 1451, /**/ -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1uP4Cb-00BrDC-Oz%40256bit.org.