summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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){