summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-02-09 13:39:42 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-02-09 13:39:42 +0800
commitd45931530be1a75d22ff675cd6e53535d9842d70 (patch)
treee9eeb71c6ace74057388de4ac979f1c4127f8f52
parent7321df77c443853370cbb10acd619a0073c55a13 (diff)
downloadlua-language-server-d45931530be1a75d22ff675cd6e53535d9842d70.zip
fix completion
`triggerCharacter` is `nil` when typing letters and numbers
-rw-r--r--script/core/completion/completion.lua8
-rw-r--r--test/completion/common.lua5
-rw-r--r--test/completion/init.lua7
3 files changed, 14 insertions, 6 deletions
diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua
index 800c11a1..680b9a23 100644
--- a/script/core/completion/completion.lua
+++ b/script/core/completion/completion.lua
@@ -1254,11 +1254,9 @@ local function tryWord(state, position, triggerCharacter, results)
checkFunctionArgByDocParam(state, word, startPos, results)
else
local afterLocal = isAfterLocal(state, startPos)
- if triggerCharacter ~= nil then
- local stop = checkKeyWord(state, startPos, position, word, hasSpace, afterLocal, results)
- if stop then
- return
- end
+ local stop = checkKeyWord(state, startPos, position, word, hasSpace, afterLocal, results)
+ if stop then
+ return
end
if not hasSpace then
if afterLocal then
diff --git a/test/completion/common.lua b/test/completion/common.lua
index bfb987c6..818d0ac5 100644
--- a/test/completion/common.lua
+++ b/test/completion/common.lua
@@ -3074,3 +3074,8 @@ AAA = 1
<??>
]]
(EXISTS)
+
+TEST [[
+if<??>
+]]
+(EXISTS)
diff --git a/test/completion/init.lua b/test/completion/init.lua
index 3d0c4df6..4ae185ca 100644
--- a/test/completion/init.lua
+++ b/test/completion/init.lua
@@ -73,11 +73,16 @@ function TEST(script)
local inputPos = catched['?'][1][2]
if ContinueTyping then
local triggerCharacter = script:sub(inputPos - 1, inputPos - 1)
+ if triggerCharacter == '\n'
+ or triggerCharacter:find '%w_' then
+ triggerCharacter = nil
+ end
core.completion('', inputPos, triggerCharacter)
end
local offset = guide.positionToOffset(state, inputPos)
local triggerCharacter = script:sub(offset, offset)
- if triggerCharacter == '\n' then
+ if triggerCharacter == '\n'
+ or triggerCharacter:find '%w_' then
triggerCharacter = nil
end
local result = core.completion('', inputPos, triggerCharacter)