diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-05-18 14:56:40 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-05-18 14:56:40 +0800 |
commit | f8917bd6dcb97b1b19c5252952988aaa68c7081a (patch) | |
tree | a78c81e68556d78931e4586b042edbc99e327686 /script/core/completion.lua | |
parent | 920f252f0ea57615600258b301917e6b3fab0bdc (diff) | |
download | lua-language-server-f8917bd6dcb97b1b19c5252952988aaa68c7081a.zip |
fix #539
Diffstat (limited to 'script/core/completion.lua')
-rw-r--r-- | script/core/completion.lua | 17 |
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 |