Hi Christian,
On Thu, Oct 15, 2020 at 9:33 AM Christian Brabandt <[email protected]>
wrote:
>
> >
> > Yeah, but shouldn't a complete match get an additional bonus?
> >
> >
> > Yes. A complete sequential match should get an additional bonus. But the
> > changes you posted only checks for whether the previous character is
> matched
> > and it doesn't check for a complete match. For example, when searching
> > for 'abc' in 'xabcy' and 'axxxxbc', it will give preference to
> axxxxbc than
> > xabcy.
>
> 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.
>
The change looks good to me. Some tests need to be updated after this
change as they are failing with this change.
Note that when searching for 'vimrc' in '_vim_rc' and '.vimrc', the
_vim_rc string will have a higher score than .vimrc because of the two
underscores.
Some minor comments below.
>
> 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
>
Can you move the comment before the #define?
> #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;
>
These functions are using camel case variable names. To be consistent,
can you change the name to fullMatch?
Regards,
Yegappan
>
> // 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;
> }
>
>
>
>
--
--
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/CAAW7x7%3D3UCfnnFOAad2tNBfkzBGJz-vpoKFtskFwNnAo13v6Bg%40mail.gmail.com.