summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
Diffstat (limited to 'script')
-rw-r--r--script/core/completion.lua22
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