diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-01-22 10:50:01 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-01-22 10:50:01 +0800 |
commit | 74a186f7c14a4217dbb630bb30d38d468e71dda6 (patch) | |
tree | 5a0817f7ed01d37c8296ed134b53bab371025f35 /server | |
parent | 486ad493425397295e38ae19de9ba7051696d61b (diff) | |
download | lua-language-server-74a186f7c14a4217dbb630bb30d38d468e71dda6.zip |
修正匹配字符串的一个bug
Diffstat (limited to 'server')
-rw-r--r-- | server/src/core/completion.lua | 14 | ||||
-rw-r--r-- | server/test/completion/init.lua | 2 |
2 files changed, 7 insertions, 9 deletions
diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua index 15aa65ec..2cdd2a64 100644 --- a/server/src/core/completion.lua +++ b/server/src/core/completion.lua @@ -47,13 +47,11 @@ local function matchKey(me, other) if lMe == lOther:sub(1, #lMe) then return true end - local used = { - [1] = true, - } - local cur = 2 + local used = {} + local cur = 1 local lookup local researched - for i = 2, #lMe do + for i = 1, #lMe do local c = lMe:sub(i, i) -- 1. 看当前字符是否匹配 if c == lOther:sub(cur, cur) then @@ -80,7 +78,7 @@ local function matchKey(me, other) return false else researched = true - for j = 2, cur - 2 do + for j = 1, cur - 2 do if c == lOther:sub(j, j) then used[j] = true goto NEXT @@ -88,13 +86,13 @@ local function matchKey(me, other) end return false end - -- 5. 找到下一个可用的字,如果超出长度就算成功 + -- 5. 找到下一个可用的字,如果超出长度且把自己所有字都用尽就算成功 ::NEXT:: repeat cur = cur + 1 until not used[cur] if cur > #lOther then - break + return i == #lMe end end return true diff --git a/server/test/completion/init.lua b/server/test/completion/init.lua index 6131ceb8..0a7a0618 100644 --- a/server/test/completion/init.lua +++ b/server/test/completion/init.lua @@ -174,7 +174,7 @@ zac@ } TEST [[ -as@ +ass@ ]] { { |