summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-02-08 16:42:13 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-02-08 16:42:13 +0800
commit6e55eab7a33a9698d1896e157a037fc43ea22825 (patch)
treee5d41aeddffc1d674c5e0a111407708025e1711a
parent81976b2896c34aa599515b922b98d3a57d2a6fc9 (diff)
downloadlua-language-server-6e55eab7a33a9698d1896e157a037fc43ea22825.zip
stash
-rw-r--r--script/core/matchkey.lua19
1 files changed, 12 insertions, 7 deletions
diff --git a/script/core/matchkey.lua b/script/core/matchkey.lua
index b504fb1d..83977496 100644
--- a/script/core/matchkey.lua
+++ b/script/core/matchkey.lua
@@ -1,20 +1,25 @@
+---@param input string
+---@param other string
+---@param fast boolean
+---@return boolean isMatch
+---@return number deviation
return function (input, other, fast)
if input == other then
- return true
+ return true, 0
end
if input == '' then
- return true
+ return true, 0
end
if #input > #other then
- return false
+ return false, 0
end
local lMe = input:lower()
local lOther = other:lower()
if lMe == lOther:sub(1, #lMe) then
- return true
+ return true, 0
end
if fast and input:sub(1, 1) ~= other:sub(1, 1) then
- return false
+ return false, 0
end
local chars = {}
for i = 1, #lOther do
@@ -26,8 +31,8 @@ return function (input, other, fast)
if chars[c] and chars[c] > 0 then
chars[c] = chars[c] - 1
else
- return false
+ return false, 0
end
end
- return true
+ return true, 1
end