fzy

terminal fuzzy finder picker

git clone https://9o.is/git/fzy.git

commit ab4b83c438a22c2309179e1602bfed3ad14dbd2e
parent 44055b969c5ee2a9fc1faba517627f1037a854dd
Author: John Hawthorn <john.hawthorn@gmail.com>
Date:   Wed, 30 Jul 2014 04:18:47 -0700

Lesser penalty for leading and trailing gaps

Diffstat:
Mfzytest.c | 4++++
Mmatch.c | 10++++++----
2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/fzytest.c b/fzytest.c @@ -44,6 +44,10 @@ int test_scoring(){ /* Prefer shorter matches */ assert(match("test", "tests") > match("test", "testing")); + /* Prefer shorter matches */ + assert(match("abc", " a b c ") > match("abc", " a b c ")); + assert(match("abc", " a b c ") > match("abc", " a b c ")); + return 0; } diff --git a/match.c b/match.c @@ -29,9 +29,9 @@ void mat_print(score_t *mat, int n, int m){ for(j = 0; j < m; j++){ score_t val = mat[i*m + j]; if(val == SCORE_MIN){ - fprintf(stderr, " -inf"); + fprintf(stderr, " -inf"); }else{ - fprintf(stderr, " %.2f", val); + fprintf(stderr, " % .2f", val); } } fprintf(stderr, "\n"); @@ -65,8 +65,8 @@ double calculate_score(const char *needle, const char *haystack, size_t *positio * M[][] Stores the best possible score at this position. */ -#define SCORE_GAP_LEADING -0.01 -#define SCORE_GAP_TRAILING -0.01 +#define SCORE_GAP_LEADING -0.005 +#define SCORE_GAP_TRAILING -0.005 #define SCORE_GAP_INNER -0.01 #define SCORE_MATCH_CONSECUTIVE 1.0 #define SCORE_MATCH_SLASH 1.5 @@ -129,8 +129,10 @@ double calculate_score(const char *needle, const char *haystack, size_t *positio } #if 0 + printf("\"%s\" =~ \"%s\"\n", needle, haystack); mat_print(&D[0][0], n, m); mat_print(&M[0][0], n, m); + printf("\n"); #endif /* backtrace to find the positions of optimal matching */