diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/src/vm/global.lua | 1 | ||||
-rw-r--r-- | server/src/vm/value.lua | 12 | ||||
-rw-r--r-- | server/test/crossfile/hover.lua | 56 |
3 files changed, 59 insertions, 10 deletions
diff --git a/server/src/vm/global.lua b/server/src/vm/global.lua index 58893d66..b0f44901 100644 --- a/server/src/vm/global.lua +++ b/server/src/vm/global.lua @@ -12,7 +12,6 @@ return function (lsp) end global = t._G - global:set('_G', true) for k, v in pairs(t) do global:setChild(k, v) global:addInfo('set child', sourceMgr.dummy(), k) diff --git a/server/src/vm/value.lua b/server/src/vm/value.lua index a2e6ba05..4fa4b53b 100644 --- a/server/src/vm/value.lua +++ b/server/src/vm/value.lua @@ -38,7 +38,7 @@ local function create (tp, source, literal) return self end -local function isDeadGlobalChild(value, index) +local function isDeadChild(value, index) for srcId, info in pairs(value._info) do local src = sourceMgr.list[srcId] if src @@ -105,11 +105,9 @@ function mt:rawGet(index) if not child then return nil end - if self:get '_G' then - if isDeadGlobalChild(self, index) then - self._child[index] = nil - return nil - end + if isDeadChild(self, index) then + self._child[index] = nil + return nil end return child end @@ -202,7 +200,7 @@ function mt:rawEach(callback, foundIndex) end foundIndex[index] = true end - if self:get '_G' and isDeadGlobalChild(self, index) then + if isDeadChild(self, index) then self._child[index] = nil goto CONTINUE end diff --git a/server/test/crossfile/hover.lua b/server/test/crossfile/hover.lua index ffa89bc0..cdc4ebca 100644 --- a/server/test/crossfile/hover.lua +++ b/server/test/crossfile/hover.lua @@ -63,10 +63,10 @@ function TEST(data) local sourceUri = ws:uriEncode(fs.path(data[2].path)) lsp:saveText(targetUri, 1, targetScript) - lsp:saveText(sourceUri, 1, sourceScript) ws:addFile(targetUri) - ws:addFile(sourceUri) lsp:compileVM(targetUri) + lsp:saveText(sourceUri, 1, sourceScript) + ws:addFile(sourceUri) lsp:compileVM(sourceUri) local sourceVM = lsp:loadVM(sourceUri) @@ -78,6 +78,9 @@ function TEST(data) if data.hover.description then data.hover.description = data.hover.description:gsub('%$ROOT%$', ws:uriEncode(ROOT):gsub('%%', '%%%%')) end + if hover.label then + hover.label = hover.label:gsub('\r\n', '\n') + end assert(eq(hover, data.hover)) end @@ -166,3 +169,52 @@ TEST { name = 'mt:add', }, } + +TEST { + { + path = 'a.lua', + content = [[ + t = { + [{}] = 1, + } + ]], + }, + { + path = 'b.lua', + content = [[ + <?t?>[{}] = 2 + ]] + }, + hover = { + label = [[ +global t: { + [*table]: number = 1, + [*table]: number = 2, +}]], + name = 't', + }, +} + +TEST { + { + path = 'a.lua', + content = [[ + t = { + [{}] = 1, + } + ]], + }, + { + path = 'a.lua', + content = [[ + <?t?>[{}] = 2 + ]] + }, + hover = { + label = [[ +global t: { + [*table]: number = 2, +}]], + name = 't', + }, +} |