Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
97 lines
4.4 KiB
Lua
97 lines
4.4 KiB
Lua
local spec = require('cmp.utils.spec')
|
|
|
|
local matcher = require('cmp.matcher')
|
|
|
|
describe('matcher', function()
|
|
before_each(spec.before)
|
|
|
|
it('match', function()
|
|
assert.is.truthy(matcher.match('', 'a') >= 1)
|
|
assert.is.truthy(matcher.match('a', 'a') >= 1)
|
|
assert.is.truthy(matcher.match('ab', 'a') == 0)
|
|
assert.is.truthy(matcher.match('ab', 'ab') > matcher.match('ab', 'a_b'))
|
|
assert.is.truthy(matcher.match('ab', 'a_b_c') > matcher.match('ac', 'a_b_c'))
|
|
|
|
assert.is.truthy(matcher.match('bora', 'border-radius') >= 1)
|
|
assert.is.truthy(matcher.match('woroff', 'word_offset') >= 1)
|
|
assert.is.truthy(matcher.match('call', 'call') > matcher.match('call', 'condition_all'))
|
|
assert.is.truthy(matcher.match('Buffer', 'Buffer') > matcher.match('Buffer', 'buffer'))
|
|
assert.is.truthy(matcher.match('luacon', 'lua_context') > matcher.match('luacon', 'LuaContext'))
|
|
assert.is.truthy(matcher.match('fmodify', 'fnamemodify') >= 1)
|
|
assert.is.truthy(matcher.match('candlesingle', 'candle#accept#single') >= 1)
|
|
|
|
assert.is.truthy(matcher.match('vi', 'void#') >= 1)
|
|
assert.is.truthy(matcher.match('vo', 'void#') >= 1)
|
|
assert.is.truthy(matcher.match('var_', 'var_dump') >= 1)
|
|
assert.is.truthy(matcher.match('conso', 'console') > matcher.match('conso', 'ConstantSourceNode'))
|
|
assert.is.truthy(matcher.match('usela', 'useLayoutEffect') > matcher.match('usela', 'useDataLayer'))
|
|
assert.is.truthy(matcher.match('my_', 'my_awesome_variable') > matcher.match('my_', 'completion_matching_strategy_list'))
|
|
assert.is.truthy(matcher.match('2', '[[2021') >= 1)
|
|
|
|
assert.is.truthy(matcher.match(',', 'pri,') == 0)
|
|
assert.is.truthy(matcher.match('/', '/**') >= 1)
|
|
|
|
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)
|
|
|
|
assert.is.truthy(matcher.match('emg', 'error_msg') >= 1)
|
|
assert.is.truthy(matcher.match('sasr', 'saved_splitright') >= 1)
|
|
|
|
-- TODO: #1420 test-case
|
|
-- assert.is.truthy(matcher.match('asset_', '????') >= 0)
|
|
|
|
local score, matches
|
|
score, matches = matcher.match('tail', 'HCDetails', {
|
|
disallow_fuzzy_matching = false,
|
|
disallow_partial_matching = false,
|
|
disallow_prefix_unmatching = false,
|
|
disallow_partial_fuzzy_matching = false,
|
|
})
|
|
assert.is.truthy(score >= 1)
|
|
assert.equals(matches[1].word_match_start, 5)
|
|
|
|
score = matcher.match('tail', 'HCDetails', {
|
|
disallow_fuzzy_matching = false,
|
|
disallow_partial_matching = false,
|
|
disallow_prefix_unmatching = false,
|
|
disallow_partial_fuzzy_matching = true,
|
|
})
|
|
assert.is.truthy(score == 0)
|
|
end)
|
|
|
|
it('disallow_fuzzy_matching', function()
|
|
assert.is.truthy(matcher.match('fmodify', 'fnamemodify', { disallow_fuzzy_matching = true }) == 0)
|
|
assert.is.truthy(matcher.match('fmodify', 'fnamemodify', { disallow_fuzzy_matching = false }) >= 1)
|
|
end)
|
|
|
|
it('disallow_fullfuzzy_matching', function()
|
|
assert.is.truthy(matcher.match('svd', 'saved_splitright', { disallow_fullfuzzy_matching = true }) == 0)
|
|
assert.is.truthy(matcher.match('svd', 'saved_splitright', { disallow_fullfuzzy_matching = false }) >= 1)
|
|
end)
|
|
|
|
it('disallow_partial_matching', function()
|
|
assert.is.truthy(matcher.match('fb', 'foo_bar', { disallow_partial_matching = true }) == 0)
|
|
assert.is.truthy(matcher.match('fb', 'foo_bar', { disallow_partial_matching = false }) >= 1)
|
|
assert.is.truthy(matcher.match('fb', 'fboo_bar', { disallow_partial_matching = true }) >= 1)
|
|
assert.is.truthy(matcher.match('fb', 'fboo_bar', { disallow_partial_matching = false }) >= 1)
|
|
end)
|
|
|
|
it('disallow_prefix_unmatching', function()
|
|
assert.is.truthy(matcher.match('bar', 'foo_bar', { disallow_prefix_unmatching = true }) == 0)
|
|
assert.is.truthy(matcher.match('bar', 'foo_bar', { disallow_prefix_unmatching = false }) >= 1)
|
|
end)
|
|
|
|
it('debug', function()
|
|
matcher.debug = function(...)
|
|
print(vim.inspect({ ... }))
|
|
end
|
|
-- print(vim.inspect({
|
|
-- a = matcher.match('true', 'v:true', { 'true' }),
|
|
-- b = matcher.match('true', 'true'),
|
|
-- }))
|
|
end)
|
|
end)
|