Christian wrote:

> Indeed. Initially I thought adding a bonus for a word boundary would be
> needed, therefore my naive attempt to score additionally on the end of
> the match. So how about this, which adds an additional bonus only for a
> complete match.
> 
> iff --git a/src/search.c b/src/search.c
> index 349eae035..d7adcc59f 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
> @@ -4292,6 +4294,7 @@ fuzzy_match_compute_score(
>      int                i;
>      char_u     *p = str;
>      matchidx_T sidx = 0;
> +    int                full_match = 0;
>  
>      // Initialize score
>      score = 100;
> @@ -4317,7 +4320,10 @@ fuzzy_match_compute_score(
>  
>             // Sequential
>             if (currIdx == (prevIdx + 1))
> +           {
>                 score += SEQUENTIAL_BONUS;
> +               full_match++;
> +           }
>         }
>  
>         // Check for bonuses based on neighbor character value
> @@ -4358,6 +4364,10 @@ fuzzy_match_compute_score(
>             score += FIRST_LETTER_BONUS;
>         }
>      }
> +
> +    if (full_match == numMatches-1)
> +       score += ENDMATCH_SEQUENTIAL_BONUS;
> +           // End of match
>      return score;
>  }

An extra score for a whole match makes a big jump.  It might work better
when giving a match a bit of extra score if the previous character also
matched.  Thus the more consequtive characters match the better.  This
seems to make sense: matches spread out over a line of text score lower
than when some matches group together.  And reach the maximum when they
are all together.

-- 
>From "know your smileys":
 :-)-O  Smiling doctor with stethoscope

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            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/202010151923.09FJNvF5155175%40masaka.moolenaar.net.

Raspunde prin e-mail lui