Patch 8.2.4465
Problem: Fuzzy completion does not order matches properly.
Solution: Do not use regular expression match. (Yegappan Lakshmanan,
closes #9843)
Files: src/cmdexpand.c, src/search.c, src/testdir/test_cmdline.vim
*** ../vim-8.2.4464/src/cmdexpand.c 2022-02-24 13:28:36.570222354 +0000
--- src/cmdexpand.c 2022-02-25 13:44:18.535171473 +0000
***************
*** 2633,2638 ****
--- 2633,2639 ----
int score = 0;
int fuzzy = (fuzzystr != NULL);
int funcsort = FALSE;
+ int match;
// do this loop twice:
// round == 0: count the number of matching names
***************
*** 2647,2690 ****
if (*str == NUL) // skip empty strings
continue;
! if (vim_regexec(regmatch, str, (colnr_T)0) ||
! (fuzzy && ((score = fuzzy_match_str(str, fuzzystr)) != 0)))
{
! if (round)
{
- if (escaped)
- str = vim_strsave_escaped(str, (char_u *)" \t\\.");
- else
- str = vim_strsave(str);
- if (str == NULL)
- {
- FreeWild(count, *matches);
- if (fuzzy)
- fuzmatch_str_free(fuzmatch, count);
- *numMatches = 0;
- *matches = NULL;
- return FAIL;
- }
if (fuzzy)
! {
! fuzmatch[count].idx = count;
! fuzmatch[count].str = str;
! fuzmatch[count].score = score;
! }
! else
! (*matches)[count] = str;
# ifdef FEAT_MENU
! if (func == get_menu_names && str != NULL)
! {
! // test for separator added by get_menu_names()
! str += STRLEN(str) - 1;
! if (*str == '\001')
! *str = '.';
! }
! # endif
}
! ++count;
}
}
if (round == 0)
{
--- 2648,2699 ----
if (*str == NUL) // skip empty strings
continue;
! if (!fuzzy)
! match = vim_regexec(regmatch, str, (colnr_T)0);
! else
{
! score = fuzzy_match_str(str, fuzzystr);
! match = (score != 0);
! }
!
! if (!match)
! continue;
!
! if (round)
! {
! if (escaped)
! str = vim_strsave_escaped(str, (char_u *)" \t\\.");
! else
! str = vim_strsave(str);
! if (str == NULL)
{
if (fuzzy)
! fuzmatch_str_free(fuzmatch, count);
! else if (count > 0)
! FreeWild(count, *matches);
! *numMatches = 0;
! *matches = NULL;
! return FAIL;
! }
! if (fuzzy)
! {
! fuzmatch[count].idx = count;
! fuzmatch[count].str = str;
! fuzmatch[count].score = score;
! }
! else
! (*matches)[count] = str;
# ifdef FEAT_MENU
! if (func == get_menu_names && str != NULL)
! {
! // test for separator added by get_menu_names()
! str += STRLEN(str) - 1;
! if (*str == '\001')
! *str = '.';
}
! # endif
}
+ ++count;
}
if (round == 0)
{
*** ../vim-8.2.4464/src/search.c 2022-02-24 13:28:36.570222354 +0000
--- src/search.c 2022-02-25 13:44:18.535171473 +0000
***************
*** 5001,5007 ****
fuzzy_match_str(char_u *str, char_u *pat)
{
int score = 0;
! int_u matchpos[256];
if (str == NULL || pat == NULL)
return 0;
--- 5001,5007 ----
fuzzy_match_str(char_u *str, char_u *pat)
{
int score = 0;
! int_u matchpos[MAX_FUZZY_MATCHES];
if (str == NULL || pat == NULL)
return 0;
*** ../vim-8.2.4464/src/testdir/test_cmdline.vim 2022-02-24
13:28:36.570222354 +0000
--- src/testdir/test_cmdline.vim 2022-02-25 13:44:18.535171473 +0000
***************
*** 2757,2762 ****
--- 2757,2781 ----
call feedkeys(":let SVar\<Tab>\<C-B>\"\<CR>", 'tx')
call assert_equal('"let SomeVariable', @:)
+ " Test for sorting the results by the best match
+ %bw!
+ command T123format :
+ command T123goformat :
+ command T123TestFOrmat :
+ command T123fendoff :
+ command T123state :
+ command T123FendingOff :
+ set wildoptions=fuzzy
+ call feedkeys(":T123fo\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"T123format T123TestFOrmat T123FendingOff T123goformat
T123fendoff', @:)
+ delcommand T123format
+ delcommand T123goformat
+ delcommand T123TestFOrmat
+ delcommand T123fendoff
+ delcommand T123state
+ delcommand T123FendingOff
+ %bw
+
set wildoptions&
%bw!
endfunc
*** ../vim-8.2.4464/src/version.c 2022-02-24 17:59:05.260644871 +0000
--- src/version.c 2022-02-25 13:47:32.106368948 +0000
***************
*** 756,757 ****
--- 756,759 ----
{ /* Add new patch number below this line */
+ /**/
+ 4465,
/**/
--
hundred-and-one symptoms of being an internet addict:
94. Now admit it... How many of you have made "modem noises" into
the phone just to see if it was possible? :-)
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220225152608.DC9B41C1149%40moolenaar.net.