diff options
author | sumneko <sumneko@hotmail.com> | 2019-04-28 11:47:54 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2019-04-28 11:47:54 +0800 |
commit | e6252422506c45dfb4c583ca2438cc090ea4a282 (patch) | |
tree | 480ad277282a8ec472f439edd351852c9e0ff3b9 /server/src/core/matchKey.lua | |
parent | 0e3fe7fe0c9d660d26a735b0d3d962f4c4289ca8 (diff) | |
download | lua-language-server-e6252422506c45dfb4c583ca2438cc090ea4a282.zip |
过滤交给前端
Diffstat (limited to 'server/src/core/matchKey.lua')
-rw-r--r-- | server/src/core/matchKey.lua | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/server/src/core/matchKey.lua b/server/src/core/matchKey.lua new file mode 100644 index 00000000..b46250cb --- /dev/null +++ b/server/src/core/matchKey.lua @@ -0,0 +1,30 @@ +return function (me, other) + if me == other then + return true + end + if me == '' then + return true + end + if #me > #other then + return false + end + local lMe = me:lower() + local lOther = other:lower() + if lMe == lOther:sub(1, #lMe) then + return true + end + local chars = {} + for i = 1, #lOther do + local c = lOther:sub(i, i) + chars[c] = (chars[c] or 0) + 1 + end + for i = 1, #lMe do + local c = lMe:sub(i, i) + if chars[c] and chars[c] > 0 then + chars[c] = chars[c] - 1 + else + return false + end + end + return true +end |