Christian Brabandt <[email protected]> wrote:

> On Mi, 14 Okt 2020, Maxim Kim wrote:
>
> > Hi, I wonder why "better" candidate has lower score than the others:
> >
> > https://i.imgur.com/NPhKNsZ.png
> >
> > tried to search `vimrc` and `.vim/vimrc` has lower score than 
> > `.vim/vimrc_colors`.
>
> The neighbor '_' adds an additional bonus for scoring. Therefore it
> scores higher. Perhaps we need to add an additional bonus, if the match
> ends at the string. Something like this perhaps:
>
> diff --git a/src/search.c b/src/search.c
> index 349eae035..5ccc35564 100644
> --- a/src/search.c
> +++ b/src/search.c
> @@ -4257,6 +4257,8 @@ typedef struct
>  // bonus if match occurs after a separator
>  #define SEPARATOR_BONUS 30
>  // bonus if match is uppercase and prev is lower
> +#define ENDMATCH_SEQUENTIAL_BONUS 35
> +// bonus if match is sequential and ends the match string
>  #define CAMEL_BONUS 30
>  // bonus if the first letter is matched
>  #define FIRST_LETTER_BONUS 15
> @@ -4318,6 +4320,10 @@ fuzzy_match_compute_score(
>             // Sequential
>             if (currIdx == (prevIdx + 1))
>                 score += SEQUENTIAL_BONUS;
> +
> +           // End of match
> +           if ((int)currIdx == strSz-1)
> +               score += ENDMATCH_SEQUENTIAL_BONUS;
>         }
>
>         // Check for bonuses based on neighbor character value
>
> I am unsure, whether this bonus should only apply, if we had a previous
> match as well, or in general only for the end of match.


If I understand this solution, searching for "vimrc" will
prefer "foo_vimrc" over "vimrc_foo", which does not
look ideal.

Regards
Dominique

-- 
-- 
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/CAON-T_jYAqdtDga2mMmhKQB39bBKP_tgTCcGy0Nk95qhx4P4Sg%40mail.gmail.com.

Raspunde prin e-mail lui