forked from aniani/vim
patch 8.2.4465: fuzzy completion does not order matches properly
Problem: Fuzzy completion does not order matches properly. Solution: Do not use regular expression match. (Yegappan Lakshmanan, closes #9843)
This commit is contained in:
committed by
Bram Moolenaar
parent
4d56b971cb
commit
5ec633b9b0
@@ -2633,6 +2633,7 @@ ExpandGeneric(
|
|||||||
int score = 0;
|
int score = 0;
|
||||||
int fuzzy = (fuzzystr != NULL);
|
int fuzzy = (fuzzystr != NULL);
|
||||||
int funcsort = FALSE;
|
int funcsort = FALSE;
|
||||||
|
int match;
|
||||||
|
|
||||||
// do this loop twice:
|
// do this loop twice:
|
||||||
// round == 0: count the number of matching names
|
// round == 0: count the number of matching names
|
||||||
@@ -2647,9 +2648,17 @@ ExpandGeneric(
|
|||||||
if (*str == NUL) // skip empty strings
|
if (*str == NUL) // skip empty strings
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (vim_regexec(regmatch, str, (colnr_T)0) ||
|
if (!fuzzy)
|
||||||
(fuzzy && ((score = fuzzy_match_str(str, fuzzystr)) != 0)))
|
match = vim_regexec(regmatch, str, (colnr_T)0);
|
||||||
|
else
|
||||||
{
|
{
|
||||||
|
score = fuzzy_match_str(str, fuzzystr);
|
||||||
|
match = (score != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!match)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (round)
|
if (round)
|
||||||
{
|
{
|
||||||
if (escaped)
|
if (escaped)
|
||||||
@@ -2658,9 +2667,10 @@ ExpandGeneric(
|
|||||||
str = vim_strsave(str);
|
str = vim_strsave(str);
|
||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
{
|
{
|
||||||
FreeWild(count, *matches);
|
|
||||||
if (fuzzy)
|
if (fuzzy)
|
||||||
fuzmatch_str_free(fuzmatch, count);
|
fuzmatch_str_free(fuzmatch, count);
|
||||||
|
else if (count > 0)
|
||||||
|
FreeWild(count, *matches);
|
||||||
*numMatches = 0;
|
*numMatches = 0;
|
||||||
*matches = NULL;
|
*matches = NULL;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@@ -2685,7 +2695,6 @@ ExpandGeneric(
|
|||||||
}
|
}
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (round == 0)
|
if (round == 0)
|
||||||
{
|
{
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
|
@@ -5001,7 +5001,7 @@ fuzzy_match_func_sort(fuzmatch_str_T *fm, int sz)
|
|||||||
fuzzy_match_str(char_u *str, char_u *pat)
|
fuzzy_match_str(char_u *str, char_u *pat)
|
||||||
{
|
{
|
||||||
int score = 0;
|
int score = 0;
|
||||||
int_u matchpos[256];
|
int_u matchpos[MAX_FUZZY_MATCHES];
|
||||||
|
|
||||||
if (str == NULL || pat == NULL)
|
if (str == NULL || pat == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -2757,6 +2757,25 @@ func Test_wildoptions_fuzzy()
|
|||||||
call feedkeys(":let SVar\<Tab>\<C-B>\"\<CR>", 'tx')
|
call feedkeys(":let SVar\<Tab>\<C-B>\"\<CR>", 'tx')
|
||||||
call assert_equal('"let SomeVariable', @:)
|
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&
|
set wildoptions&
|
||||||
%bw!
|
%bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
@@ -754,6 +754,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
4465,
|
||||||
/**/
|
/**/
|
||||||
4464,
|
4464,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user