@@ -474,6 +474,10 @@ matching.disallow_fuzzy_matching~
|
||||
`boolean`
|
||||
Whether to allow fuzzy matching.
|
||||
|
||||
*cmp-config.matching.disallow_partial_fuzzy_matching*
|
||||
matching.disallow_partial_fuzzy_matching~
|
||||
`boolean`
|
||||
Whether to allow fuzzy matching without prefix matching.
|
||||
*cmp-config.matching.disallow_partial_matching*
|
||||
matching.disallow_partial_matching~
|
||||
`boolean`
|
||||
|
||||
@@ -50,6 +50,7 @@ return function()
|
||||
|
||||
matching = {
|
||||
disallow_fuzzy_matching = false,
|
||||
disallow_partial_fuzzy_matching = true,
|
||||
disallow_partial_matching = false,
|
||||
disallow_prefix_unmatching = false,
|
||||
},
|
||||
|
||||
@@ -365,11 +365,13 @@ entry.match = function(self, input, matching_config)
|
||||
input,
|
||||
self.resolved_completion_item and '1' or '0',
|
||||
matching_config.disallow_fuzzy_matching and '1' or '0',
|
||||
matching_config.disallow_partial_fuzzy_matching and '1' or '0',
|
||||
matching_config.disallow_partial_matching and '1' or '0',
|
||||
matching_config.disallow_prefix_unmatching and '1' or '0',
|
||||
}, function()
|
||||
local option = {
|
||||
disallow_fuzzy_matching = matching_config.disallow_fuzzy_matching,
|
||||
disallow_partial_fuzzy_matching = matching_config.disallow_partial_fuzzy_matching,
|
||||
disallow_partial_matching = matching_config.disallow_partial_matching,
|
||||
disallow_prefix_unmatching = matching_config.disallow_prefix_unmatching,
|
||||
synonyms = {
|
||||
|
||||
@@ -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,10 +179,12 @@ 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
|
||||
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, {}
|
||||
end
|
||||
|
||||
|
||||
@@ -33,6 +33,9 @@ describe('matcher', function()
|
||||
|
||||
assert.is.truthy(matcher.match('true', 'v:true', { synonyms = { 'true' } }) == matcher.match('true', 'true'))
|
||||
assert.is.truthy(matcher.match('g', 'get', { synonyms = { 'get' } }) > matcher.match('g', 'dein#get', { 'dein#get' }))
|
||||
|
||||
assert.is.truthy(matcher.match('Unit', 'net.UnixListener', { disallow_partial_fuzzy_matching = true }) == 0)
|
||||
assert.is.truthy(matcher.match('Unit', 'net.UnixListener', { disallow_partial_fuzzy_matching = false }) >= 1)
|
||||
end)
|
||||
|
||||
it('disallow_fuzzy_matching', function()
|
||||
|
||||
@@ -125,6 +125,7 @@ cmp.ItemField = {
|
||||
|
||||
---@class cmp.MatchingConfig
|
||||
---@field public disallow_fuzzy_matching boolean
|
||||
---@field public disallow_partial_fuzzy_matching boolean
|
||||
---@field public disallow_partial_matching boolean
|
||||
---@field public disallow_prefix_unmatching boolean
|
||||
|
||||
|
||||
Reference in New Issue
Block a user