summaryrefslogtreecommitdiff
path: root/script-beta/vm/getGlobals.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-09-13 19:08:57 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-09-13 19:08:57 +0800
commit9c228abd1cccf1b1451c9fee9ffb9962b3f33d82 (patch)
treef89a53b1cd1998abc6337c787a3f8e8d8ee73172 /script-beta/vm/getGlobals.lua
parentab5a3399afffd205d39aff8ca455a95afd1f672a (diff)
downloadlua-language-server-9c228abd1cccf1b1451c9fee9ffb9962b3f33d82.zip
修正一些bug
Diffstat (limited to 'script-beta/vm/getGlobals.lua')
-rw-r--r--script-beta/vm/getGlobals.lua15
1 files changed, 12 insertions, 3 deletions
diff --git a/script-beta/vm/getGlobals.lua b/script-beta/vm/getGlobals.lua
index 69e6dbb7..16dce873 100644
--- a/script-beta/vm/getGlobals.lua
+++ b/script-beta/vm/getGlobals.lua
@@ -2,6 +2,7 @@ local guide = require 'parser.guide'
local vm = require 'vm.vm'
local files = require 'files'
local library = require 'library'
+local util = require 'utility'
local function getGlobalsOfFile(uri)
local globals = {}
@@ -34,9 +35,17 @@ local function getGlobals(name)
for uri in files:eachFile() do
local cache = files.getCache(uri)
cache.globals = cache.globals or getGlobalsOfFile(uri)
- if cache.globals[name] then
- for _, source in ipairs(cache.globals[name]) do
- results[#results+1] = source
+ if name == '*' then
+ for _, sources in util.sortPairs(cache.globals) do
+ for _, source in ipairs(sources) do
+ results[#results+1] = source
+ end
+ end
+ else
+ if cache.globals[name] then
+ for _, source in ipairs(cache.globals[name]) do
+ results[#results+1] = source
+ end
end
end
end