Improve scoring

This commit is contained in:
hrsh7th
2021-08-08 17:33:33 +09:00
parent 0cc4e1e145
commit efed43377b
2 changed files with 2 additions and 1 deletions

View File

@@ -135,8 +135,8 @@ matcher.match = function(input, word, words)
end end
idx = idx + 1 idx = idx + 1
if s > 0 then if s > 0 then
s = s * (m.strict_match and 1.2 or 1)
score = score + (s * (1 + math.max(0, matcher.WORD_BOUNDALY_ORDER_FACTOR - (m.index - boundary_fixer)) / matcher.WORD_BOUNDALY_ORDER_FACTOR)) score = score + (s * (1 + math.max(0, matcher.WORD_BOUNDALY_ORDER_FACTOR - (m.index - boundary_fixer)) / matcher.WORD_BOUNDALY_ORDER_FACTOR))
score = score + (m.strict_match and 0.1 or 0)
end end
end end

View File

@@ -21,6 +21,7 @@ describe('matcher', function()
assert.is.truthy(matcher.match('conso', 'console') > matcher.match('conso', 'ConstantSourceNode')) assert.is.truthy(matcher.match('conso', 'console') > matcher.match('conso', 'ConstantSourceNode'))
assert.is.truthy(matcher.match('var_', 'var_dump') >= 1) assert.is.truthy(matcher.match('var_', 'var_dump') >= 1)
assert.is.truthy(matcher.match('my_', 'my_awesome_variable') > matcher.match('my_', 'completion_matching_strategy_list')) assert.is.truthy(matcher.match('my_', 'my_awesome_variable') > matcher.match('my_', 'completion_matching_strategy_list'))
assert.is.truthy(matcher.match('luacon', 'lua_context') > matcher.match('luacon', 'LuaContext'))
end) end)
it('debug', function() it('debug', function()