aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorglepnir <glephunter@gmail.com>2024-12-27 14:23:06 +0800
committerGitHub <noreply@github.com>2024-12-27 14:23:06 +0800
commit46c7faa00b165a1ad1b7cef8245df30d3dc3ef56 (patch)
tree39de7d7bf73bc67684769a8ec4d385bc81abedd0 /src
parent557f2d970044b04a364134ec45060b21b0f0b108 (diff)
downloadrneovim-46c7faa00b165a1ad1b7cef8245df30d3dc3ef56.tar.gz
rneovim-46c7faa00b165a1ad1b7cef8245df30d3dc3ef56.tar.bz2
rneovim-46c7faa00b165a1ad1b7cef8245df30d3dc3ef56.zip
vim-patch:9.1.0963: fuzzy-matching does not prefer full match (#31741)
Problem: fuzzy-matching does not prefer full match (Maxim Kim) Solution: add additional score for a full match (glepnir) fixes: vim/vim#15654 closes: vim/vim#16300 https://github.com/vim/vim/commit/5a04999a7402201cf1b47ff10bc474dd1cdc24f4
Diffstat (limited to 'src')
-rw-r--r--src/nvim/search.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/nvim/search.c b/src/nvim/search.c
index faa14dfaf4..5a53122739 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -2995,6 +2995,7 @@ static int fuzzy_match_compute_score(const char *const str, const int strSz,
assert(numMatches > 0); // suppress clang "result of operation is garbage"
// Initialize score
int score = 100;
+ bool is_exact_match = true;
// Apply leading letter penalty
int penalty = LEADING_LETTER_PENALTY * (int)matches[0];
@@ -3048,6 +3049,14 @@ static int fuzzy_match_compute_score(const char *const str, const int strSz,
// First letter
score += FIRST_LETTER_BONUS;
}
+ // Check exact match condition
+ if (currIdx != (uint32_t)i) {
+ is_exact_match = false;
+ }
+ }
+ // Boost score for exact matches
+ if (is_exact_match && numMatches == strSz) {
+ score += 100;
}
return score;
}