// bonus for adjacent matches; this is higher than SEPARATOR_BONUS so that
// matching a whole word is preferred.
#define SEQUENTIAL_BONUS 40
-// bonus if match occurs after a separator
-#define SEPARATOR_BONUS 30
+// bonus if match occurs after a path separator
+#define PATH_SEPARATOR_BONUS 30
+// bonus if match occurs after a word separator
+#define WORD_SEPARATOR_BONUS 25
// bonus if match is uppercase and prev is lower
#define CAMEL_BONUS 30
// bonus if the first letter is matched
// Camel case
int neighbor = ' ';
int curr;
- int neighborSeparator;
if (has_mbyte)
{
if (vim_islower(neighbor) && vim_isupper(curr))
score += CAMEL_BONUS;
- // Separator
- neighborSeparator = neighbor == '_' || neighbor == ' ';
- if (neighborSeparator)
- score += SEPARATOR_BONUS;
+ // Bonus if the match follows a separator character
+ if (neighbor == '/' || neighbor == '\\')
+ score += PATH_SEPARATOR_BONUS;
+ else if (neighbor == ' ' || neighbor == '_')
+ score += WORD_SEPARATOR_BONUS;
}
else
{
call assert_equal(['.vim/vimrc', '.vim/vimrc_colors', '.vim/v_i_m_r_c'], ['.vim/vimrc', '.vim/vimrc_colors', '.vim/v_i_m_r_c']->matchfuzzy('vimrc'))
" gap penalty
call assert_equal(['xxayybxxxx', 'xxayyybxxx', 'xxayyyybxx'], ['xxayyyybxx', 'xxayyybxxx', 'xxayybxxxx']->matchfuzzy('ab'))
+ " path separator vs word separator
+ call assert_equal(['color/setup.vim', 'color\\setup.vim', 'color setup.vim', 'color_setup.vim', 'colorsetup.vim'], matchfuzzy(['colorsetup.vim', 'color setup.vim', 'color/setup.vim', 'color_setup.vim', 'color\\setup.vim'], 'setup.vim'))
" match multiple words (separated by space)
call assert_equal(['foo bar baz'], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzy('baz foo'))