diff options
author | John Hawthorn <john.hawthorn@gmail.com> | 2014-08-30 19:26:22 -0700 |
---|---|---|
committer | John Hawthorn <john.hawthorn@gmail.com> | 2014-08-30 19:48:29 -0700 |
commit | b7305897f1c6d6f499003657b352ccbe6ed1faba (patch) | |
tree | 2b488196c00326620bfd7087e42d6bb4355810c9 | |
parent | 57e9b44d776259838fe44609bb717cef8caef4e1 (diff) |
scoring: Prefer consecutive matches
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | fzytest.c | 8 | ||||
-rw-r--r-- | match.c | 8 |
3 files changed, 10 insertions, 10 deletions
@@ -48,10 +48,10 @@ nnoremap <leader>s :call FzyCommand("ag . --no-color -l -g ''", ":sp")<cr> fzy attempts to present the best matches first. The following considerations are weighted when sorting: -It prefers matching the beginning of words: `amo` is likely to match <tt><b>a</b>pp/<b>m</b>odels/<b>o</b>rder.rb</tt>. - It prefers consecutive characters: `file` will match <tt><b>file</b></tt> over <tt><b>fil</b>t<b>e</b>r</tt>. +It prefers matching the beginning of words: `amp` is likely to match <tt><b>a</b>pp/<b>m</b>odels/<b>p</b>osts.rb</tt>. + It prefers shorter matches: `abce` matches <tt><b>abc</b>d<b>e</b>f</tt> over <tt><b>abc</b> d<b>e</b></tt>. It prefers shorter candidates: `test` matches <tt><b>test</b>s</tt> over <tt><b>test</b>ing</b></tt>. @@ -29,8 +29,8 @@ int test_match(){ } int test_scoring(){ - /* App/Models/Order is better than App/MOdels/foo */ - assert(match("amo", "app/models/foo") < match("amo", "app/models/order")); + /* App/Models/Order is better than App/MOdels/zRder */ + assert(match("amor", "app/models/order") > match("amor", "app/models/zrder")); /* App/MOdels/foo is better than App/M/fOo */ assert(match("amo", "app/m/foo") < match("amo", "app/models/foo")); @@ -72,8 +72,8 @@ int test_positions_2(){ * We should prefer matching the 'o' in order, since it's the beginning * of a word. */ - size_t positions[3]; - match_positions("amo", "app/models/order", positions); + size_t positions[4]; + match_positions("amor", "app/models/order", positions); assert(positions[0] == 0); assert(positions[1] == 4); assert(positions[2] == 11); @@ -77,10 +77,10 @@ double calculate_score(const char *needle, const char *haystack, size_t *positio #define SCORE_GAP_TRAILING -0.005 #define SCORE_GAP_INNER -0.01 #define SCORE_MATCH_CONSECUTIVE 1.0 -#define SCORE_MATCH_SLASH 1.5 -#define SCORE_MATCH_WORD 1.2 -#define SCORE_MATCH_CAPITAL 1.1 -#define SCORE_MATCH_DOT 0.8 +#define SCORE_MATCH_SLASH 0.9 +#define SCORE_MATCH_WORD 0.8 +#define SCORE_MATCH_CAPITAL 0.7 +#define SCORE_MATCH_DOT 0.6 /* Which positions are beginning of words */ char last_ch = '\0'; |