aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-02-10 21:31:44 +0800
committerzeertzjq <zeertzjq@outlook.com>2024-02-10 21:55:54 +0800
commitf3982ad3f3bc866c9369edfbd4125aaa092215a9 (patch)
treeea4abd44bb1e1878766166d210ae807029eb817b
parent5bbb733a1b16b0c9d2303c1464bf66ee434450ac (diff)
downloadrneovim-f3982ad3f3bc866c9369edfbd4125aaa092215a9.tar.gz
rneovim-f3982ad3f3bc866c9369edfbd4125aaa092215a9.tar.bz2
rneovim-f3982ad3f3bc866c9369edfbd4125aaa092215a9.zip
vim-patch:9.1.0093: Still a qsort() comparison function that returns result of subtraction
Problem: Still a qsort() comparison function fuzzy_match_item_compare() that returns result of subtraction (after 9.1.0089). Solution: Use an explicit comparison instead of subtraction. (zeertzjq) closes: vim/vim#14004 https://github.com/vim/vim/commit/77078276bfe695070441a1bbdc02949d31de8922
-rw-r--r--src/nvim/search.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/nvim/search.c b/src/nvim/search.c
index f666b07c72..48e41c290d 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -3197,7 +3197,11 @@ static int fuzzy_match_item_compare(const void *const s1, const void *const s2)
const int idx1 = ((const fuzzyItem_T *)s1)->idx;
const int idx2 = ((const fuzzyItem_T *)s2)->idx;
- return v1 == v2 ? (idx1 - idx2) : v1 > v2 ? -1 : 1;
+ if (v1 == v2) {
+ return idx1 == idx2 ? 0 : idx1 > idx2 ? 1 : -1;
+ } else {
+ return v1 > v2 ? -1 : 1;
+ }
}
/// Fuzzy search the string "str" in a list of "items" and return the matching