diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-01-27 19:04:40 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-01-27 19:04:40 +0800 |
commit | 954826cb2dcbdb25fde09d6fd38760a69d06475a (patch) | |
tree | b3be6f2908d8a467a06df169d804656f68a5fed0 /script | |
parent | 4f1fa51222b75cef5a638945129429f380be0f85 (diff) | |
download | lua-language-server-954826cb2dcbdb25fde09d6fd38760a69d06475a.zip |
fix completion of globals
Diffstat (limited to 'script')
-rw-r--r-- | script/core/completion.lua | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/script/core/completion.lua b/script/core/completion.lua index 07f36926..b5ff6c65 100644 --- a/script/core/completion.lua +++ b/script/core/completion.lua @@ -522,7 +522,7 @@ local function checkFieldOfRefs(refs, ast, word, start, offset, parent, oop, res if isSameSource(ast, src, start) then goto CONTINUE end - if locals and locals[name] then + if isGlobal and locals and locals[name] then goto CONTINUE end if not matchKey(word, name, count >= 100) then @@ -553,22 +553,22 @@ local function checkFieldOfRefs(refs, ast, word, start, offset, parent, oop, res end end -local function checkField(ast, word, start, offset, parent, oop, results) - local refs - if guide.isGlobal(parent) then - refs = vm.getDefFields(parent, 0) - else - refs = vm.getFields(parent, 0) - end - checkFieldOfRefs(refs, ast, word, start, offset, parent, oop, results) -end - local function checkGlobal(ast, word, start, offset, parent, oop, results) local locals = guide.getVisibleLocals(ast.ast, offset) local refs = vm.getGlobalSets '*' checkFieldOfRefs(refs, ast, word, start, offset, parent, oop, results, locals, 'global') end +local function checkField(ast, word, start, offset, parent, oop, results) + if parent.tag == '_ENV' or parent.special == '_G' then + local refs = vm.getGlobalSets '*' + checkFieldOfRefs(refs, ast, word, start, offset, parent, oop, results) + else + local refs = vm.getFields(parent, 0) + checkFieldOfRefs(refs, ast, word, start, offset, parent, oop, results) + end +end + local function checkTableField(ast, word, start, results) local source = guide.eachSourceContain(ast.ast, start, function (source) if source.start == start |