fzy
terminal fuzzy finder picker
git clone https://9o.is/git/fzy.git
commit 641ded03dc6d74bcd28e2c9d968ddd25ca5f81ce parent eb21b8ee3bc1061fe67cbdc5eaa890bc380e274a Author: John Hawthorn <john.hawthorn@gmail.com> Date: Sat, 26 Jul 2014 23:41:20 -0700 Revert "No need anymore for strlen to break ties" This reverts commit 6959e7cd2225c545058d64ec47a6a876c8e41693. Diffstat:
| M | fzy.c | | | 8 | +++++++- |
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/fzy.c b/fzy.c @@ -63,7 +63,13 @@ static int cmpchoice(const void *p1, const void *p2) { double score1 = choices_score[idx1]; double score2 = choices_score[idx2]; - return score1 - score2; + if(score1 == score2) + /* break ties by length of result */ + return strlen(choices[idx1]) - strlen(choices[idx2]); + else if(score1 < score2) + return 1; + else + return -1; } void run_search(char *needle){