summaryrefslogtreecommitdiff
path: root/script/core/completion.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-05-18 14:56:40 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-05-18 14:56:40 +0800
commitf8917bd6dcb97b1b19c5252952988aaa68c7081a (patch)
treea78c81e68556d78931e4586b042edbc99e327686 /script/core/completion.lua
parent920f252f0ea57615600258b301917e6b3fab0bdc (diff)
downloadlua-language-server-f8917bd6dcb97b1b19c5252952988aaa68c7081a.zip
fix #539
Diffstat (limited to 'script/core/completion.lua')
-rw-r--r--script/core/completion.lua17
1 files changed, 11 insertions, 6 deletions
diff --git a/script/core/completion.lua b/script/core/completion.lua
index ee61029d..e3980eca 100644
--- a/script/core/completion.lua
+++ b/script/core/completion.lua
@@ -1163,13 +1163,18 @@ local function tryIndex(ast, text, offset, results)
checkField(ast, word, offset, offset, parent, oop, results)
end
-local function tryWord(ast, text, offset, results)
+local function tryWord(ast, text, offset, triggerCharacter, results)
local finish = lookBackward.skipSpace(text, offset)
- local word, start = lookBackward.findWord(text, finish)
+ local word, start = lookBackward.findWord(text, offset)
if not word then
- return nil
+ if triggerCharacter == nil then
+ word = ''
+ start = offset
+ else
+ return nil
+ end
end
- local hasSpace = finish ~= offset
+ local hasSpace = triggerCharacter ~= nil and finish ~= offset
if isInString(ast, offset) then
if not hasSpace then
if #results == 0 then
@@ -1918,7 +1923,7 @@ local function clearCache()
cache.results = nil
end
-local function completion(uri, offset)
+local function completion(uri, offset, triggerCharacter)
tracy.ZoneBeginN 'completion cache'
local results = getCache(uri, offset)
tracy.ZoneEnd()
@@ -1940,7 +1945,7 @@ local function completion(uri, offset)
trySpecial(ast, text, offset, results)
tryCallArg(ast, text, offset, results)
tryTable(ast, text, offset, results)
- tryWord(ast, text, offset, results)
+ tryWord(ast, text, offset, triggerCharacter, results)
tryIndex(ast, text, offset, results)
trySymbol(ast, text, offset, results)
end