Implement middle fuzzy matching

Fixes #1422
This commit is contained in:
hrsh7th
2023-02-11 22:52:28 +09:00
parent 53f49c5145
commit aae0c3e4e7
6 changed files with 17 additions and 4 deletions

View File

@@ -78,7 +78,7 @@ end
---Match entry
---@param input string
---@param word string
---@param option { synonyms: string[], disallow_fuzzy_matching: boolean, disallow_partial_matching: boolean, disallow_prefix_unmatching: boolean }
---@param option { synonyms: string[], disallow_fuzzy_matching: boolean, disallow_partial_fuzzy_matching: boolean, disallow_partial_matching: boolean, disallow_prefix_unmatching: boolean }
---@return integer
matcher.match = function(input, word, option)
option = option or {}
@@ -179,8 +179,10 @@ matcher.match = function(input, word, option)
-- Check remaining input as fuzzy
if matches[#matches].input_match_end < #input then
if not option.disallow_fuzzy_matching then
if prefix and matcher.fuzzy(input, word, matches) then
return score, matches
if not option.disallow_partial_fuzzy_matching or prefix then
if matcher.fuzzy(input, word, matches) then
return score, matches
end
end
end
return 0, {}