summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-03-15 15:59:22 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-03-15 15:59:22 +0800
commit785d3e5963f793de712a96c88db08c684cb26bfc (patch)
tree168ddc2011887caf835c8408cd3263f37151cc9f /server
parent9aaf4607376e11a35fe04ef86baa3c18a9d90864 (diff)
downloadlua-language-server-785d3e5963f793de712a96c88db08c684cb26bfc.zip
修正全局库变量的一些问题
Diffstat (limited to 'server')
-rw-r--r--server/src/vm/global.lua1
-rw-r--r--server/src/vm/value.lua16
-rw-r--r--server/test/crossfile/completion.lua6
3 files changed, 15 insertions, 8 deletions
diff --git a/server/src/vm/global.lua b/server/src/vm/global.lua
index 99f05e37..58893d66 100644
--- a/server/src/vm/global.lua
+++ b/server/src/vm/global.lua
@@ -15,6 +15,7 @@ return function (lsp)
global:set('_G', true)
for k, v in pairs(t) do
global:setChild(k, v)
+ global:addInfo('set child', sourceMgr.dummy(), k)
end
end
if lsp then
diff --git a/server/src/vm/value.lua b/server/src/vm/value.lua
index 67b4536c..84012b25 100644
--- a/server/src/vm/value.lua
+++ b/server/src/vm/value.lua
@@ -38,13 +38,13 @@ local function create (tp, source, literal)
return self
end
-local function isDeadGlobalChild(value)
- if value._lib then
- return false
- end
- for srcId in pairs(value._info) do
+local function isDeadGlobalChild(value, index)
+ for srcId, info in pairs(value._info) do
local src = sourceMgr.list[srcId]
- if src then
+ if src
+ and (info.type == 'set child' or info.type == 'get child')
+ and info[1] == index
+ then
return false
end
end
@@ -106,7 +106,7 @@ function mt:rawGet(index)
return nil
end
if self:get '_G' then
- if isDeadGlobalChild(child) then
+ if isDeadGlobalChild(self, index) then
self._child[index] = nil
return nil
end
@@ -201,7 +201,7 @@ function mt:rawEach(callback, foundIndex)
end
foundIndex[index] = true
end
- if self:get '_G' and isDeadGlobalChild(value) then
+ if self:get '_G' and isDeadGlobalChild(self, index) then
self._child[index] = nil
goto CONTINUE
end
diff --git a/server/test/crossfile/completion.lua b/server/test/crossfile/completion.lua
index e63c8384..032991ef 100644
--- a/server/test/crossfile/completion.lua
+++ b/server/test/crossfile/completion.lua
@@ -350,6 +350,12 @@ TEST {
{
path = 'a.lua',
content = [[
+ abcd = print
+ ]]
+ },
+ {
+ path = 'a.lua',
+ content = [[
abcdef = 1
]]
},