summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hawthorn <john.hawthorn@gmail.com>2014-07-26 23:41:20 -0700
committerJohn Hawthorn <john.hawthorn@gmail.com>2014-07-26 23:41:20 -0700
commitc6817949d86fccd18f09f5d5a28b5dafc3065721 (patch)
tree5e195cbfb616eb4e21fd0a0699c678b27e2d27f3
parent04f18f3554287fbf26726e2404c390ca104354d9 (diff)
Revert "No need anymore for strlen to break ties"
This reverts commit e77435e4c26cc5d2c879452d9310890763df0b96.
-rw-r--r--fzy.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/fzy.c b/fzy.c
index 93c4dba..c38d916 100644
--- 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){