fzy
terminal fuzzy finder picker
git clone https://9o.is/git/fzy.git
commit 8e027a6af3b0b33cbbe6326bef63e2a0f36034bb parent 3f66ada7bc512febfa102f8ba7cf0b5c03f483cf Author: John Hawthorn <john.hawthorn@gmail.com> Date: Sun, 3 Aug 2014 23:55:33 -0700 Only M[0][0] should default to 0 Diffstat:
| M | fzytest.c | | | 10 | ++++++++++ |
| M | match.c | | | 2 | +- |
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/fzytest.c b/fzytest.c @@ -87,6 +87,15 @@ int test_positions_3(){ return 0; } +int test_positions_4(){ + size_t positions[2]; + match_positions("as", "examples.txt", positions); + assert(positions[0] == 2); + assert(positions[1] == 7); + + return 0; +} + int test_positions_exact(){ size_t positions[3]; match_positions("foo", "foo", positions); @@ -110,6 +119,7 @@ int main(int argc, char *argv[]){ runtest(test_positions_1); runtest(test_positions_2); runtest(test_positions_3); + runtest(test_positions_4); runtest(test_positions_exact); summary(); diff --git a/match.c b/match.c @@ -103,7 +103,7 @@ double calculate_score(const char *needle, const char *haystack, size_t *positio for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ - score_t score = j ? SCORE_MIN : 0; + score_t score = (j || i) ? SCORE_MIN : 0; int match = tolower(needle[i]) == tolower(haystack[j]); D[i][j] = SCORE_MIN; if(match){