patch 9.1.0963: fuzzy-matching does not prefer full match
Problem: fuzzy-matching does not prefer full match
(Maxim Kim)
Solution: add additional score for a full match
(glepnir)
fixes: #15654
closes: #16300
Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/search.c b/src/search.c
index aeb519c..616331e 100644
--- a/src/search.c
+++ b/src/search.c
@@ -4385,6 +4385,7 @@
int i;
char_u *p = str;
int_u sidx = 0;
+ int is_exact_match = TRUE;
// Initialize score
score = 100;
@@ -4452,7 +4453,14 @@
// First letter
score += FIRST_LETTER_BONUS;
}
+ // Check exact match condition
+ if (currIdx != (int_u)i)
+ is_exact_match = FALSE;
}
+ // Boost score for exact matches
+ if (is_exact_match && numMatches == strSz)
+ score += 100;
+
return score;
}