mirror of
https://github.com/neovim/neovim.git
synced 2025-10-17 15:21:47 +00:00
vim-patch:8.2.1921: fuzzy matching does not recognize path separators
Problem: Fuzzy matching does not recognize path separators.
Solution: Add a bonus for slash and backslash. (Yegappan Lakshmanan,
closes vim/vim#7225)
dcdd42a8cc
This commit is contained in:
@@ -4823,8 +4823,10 @@ typedef struct {
|
||||
/// bonus for adjacent matches; this is higher than SEPARATOR_BONUS so that
|
||||
/// matching a whole word is preferred.
|
||||
#define SEQUENTIAL_BONUS 40
|
||||
/// bonus if match occurs after a separator
|
||||
#define SEPARATOR_BONUS 30
|
||||
/// bonus if match occurs after a path separator
|
||||
#define PATH_SEPARATOR_BONUS 30
|
||||
/// bonus if match occurs after a word separator
|
||||
#define WORD_SEPARATOR_BONUS 25
|
||||
/// bonus if match is uppercase and prev is lower
|
||||
#define CAMEL_BONUS 30
|
||||
/// bonus if the first letter is matched
|
||||
@@ -4895,10 +4897,11 @@ static int fuzzy_match_compute_score(const char_u *const str, const int strSz,
|
||||
score += CAMEL_BONUS;
|
||||
}
|
||||
|
||||
// Separator
|
||||
const bool neighborSeparator = neighbor == '_' || neighbor == ' ';
|
||||
if (neighborSeparator) {
|
||||
score += SEPARATOR_BONUS;
|
||||
// Bonus if the match follows a separator character
|
||||
if (neighbor == '/' || neighbor == '\\') {
|
||||
score += PATH_SEPARATOR_BONUS;
|
||||
} else if (neighbor == ' ' || neighbor == '_') {
|
||||
score += WORD_SEPARATOR_BONUS;
|
||||
}
|
||||
} else {
|
||||
// First letter
|
||||
|
Reference in New Issue
Block a user