summaryrefslogtreecommitdiff
path: root/script-beta/core
diff options
context:
space:
mode:
Diffstat (limited to 'script-beta/core')
-rw-r--r--script-beta/core/completion.lua20
1 files changed, 13 insertions, 7 deletions
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua
index 2635f2bf..4f4f99c7 100644
--- a/script-beta/core/completion.lua
+++ b/script-beta/core/completion.lua
@@ -406,9 +406,9 @@ local function checkFieldThen(name, src, word, start, offset, parent, oop, resul
}
end
-local function checkField(ast, word, start, offset, parent, oop, results)
+local function checkFieldOfRefs(refs, ast, word, start, offset, parent, oop, results)
local fields = {}
- for _, src in ipairs(vm.getFields(parent, 'deep')) do
+ for _, src in ipairs(refs) do
if src.type == 'library' then
if src.name:sub(1, 1) == '@' then
goto CONTINUE
@@ -445,6 +445,16 @@ local function checkField(ast, word, start, offset, parent, oop, results)
end
end
+local function checkField(ast, word, start, offset, parent, oop, results)
+ local refs = vm.getFields(parent, 'deep')
+ checkFieldOfRefs(refs, ast, word, start, offset, parent, oop, results)
+end
+
+local function checkGlobal(ast, word, start, offset, parent, oop, results)
+ local refs = vm.getGlobals('*', 'fast')
+ checkFieldOfRefs(refs, ast, word, start, offset, parent, oop, results)
+end
+
local function checkTableField(ast, word, start, results)
local source = guide.eachSourceContain(ast.ast, start, function (source)
if source.start == start
@@ -835,7 +845,7 @@ local function tryWord(ast, text, offset, results)
checkLocal(ast, word, start, results)
checkTableField(ast, word, start, results)
local env = guide.getENV(ast.ast, start)
- checkField(ast, word, start, offset, env, false, results)
+ checkGlobal(ast, word, start, offset, env, false, results)
end
end
end
@@ -1205,10 +1215,6 @@ local function completion(uri, offset)
local results = {}
clearStack()
vm.setSearchLevel(3)
- guide.searchMax = 1000
- local _ <close> = util.defer(function ()
- guide.searchMax = nil
- end)
if ast then
if getComment(ast, offset) then
tryLuaDoc(ast, text, offset, results)