diff options
author | John Hawthorn <john.hawthorn@gmail.com> | 2014-07-26 23:41:20 -0700 |
---|---|---|
committer | John Hawthorn <john.hawthorn@gmail.com> | 2014-07-26 23:41:20 -0700 |
commit | c6817949d86fccd18f09f5d5a28b5dafc3065721 (patch) | |
tree | 5e195cbfb616eb4e21fd0a0699c678b27e2d27f3 | |
parent | 04f18f3554287fbf26726e2404c390ca104354d9 (diff) |
Revert "No need anymore for strlen to break ties"
This reverts commit e77435e4c26cc5d2c879452d9310890763df0b96.
-rw-r--r-- | fzy.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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){ |