From a4bff71503fcf5d5a1bff8dc3ce209050afea86c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 15 Mar 2019 14:07:14 +0800 Subject: =?UTF-8?q?=5FG=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/method/initialize.lua | 2 +- server/src/vm/global.lua | 7 ++++++- server/src/vm/value.lua | 4 ++++ server/test/definition/set.lua | 5 +++++ server/test/diagnostics/init.lua | 4 ++-- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/server/src/method/initialize.lua b/server/src/method/initialize.lua index ba183c5e..e236617c 100644 --- a/server/src/method/initialize.lua +++ b/server/src/method/initialize.lua @@ -22,7 +22,7 @@ return function (lsp) -- 支持“重命名” renameProvider = true, -- 支持“大纲” - documentSymbolProvider = true, + --documentSymbolProvider = true, -- 支持“签名帮助” signatureHelpProvider = { triggerCharacters = { '(', ',' }, diff --git a/server/src/vm/global.lua b/server/src/vm/global.lua index bb506ce9..b1b32505 100644 --- a/server/src/vm/global.lua +++ b/server/src/vm/global.lua @@ -13,9 +13,14 @@ return function (lsp) global:rawSet(name, value) end end + + local _G = global:getChild '_G' + global:eachChild(function (k, v) + _G:setChild(k, v) + end) end if lsp then lsp.globalValue = global end - return global + return global:rawGet('_G') end diff --git a/server/src/vm/value.lua b/server/src/vm/value.lua index 44e9d1e4..60f0c663 100644 --- a/server/src/vm/value.lua +++ b/server/src/vm/value.lua @@ -151,6 +151,10 @@ function mt:getChild(index, source, mark) return method:getChild(index, source, mark) end +function mt:bindChild(other) + self._child = other._child +end + function mt:setMetaTable(metatable) self._meta = metatable end diff --git a/server/test/definition/set.lua b/server/test/definition/set.lua index 82dc4828..eb899fc9 100644 --- a/server/test/definition/set.lua +++ b/server/test/definition/set.lua @@ -38,3 +38,8 @@ else end print() ]] + +TEST [[ +_G. = 1 +print() +]] diff --git a/server/test/diagnostics/init.lua b/server/test/diagnostics/init.lua index 8c2f4dba..4af8f975 100644 --- a/server/test/diagnostics/init.lua +++ b/server/test/diagnostics/init.lua @@ -119,12 +119,12 @@ local _ENV ]] TEST [[ -print(_G) +print() :sub(1, 1) ]] TEST [[ -print(_G) +print() ('string') ]] -- cgit v1.2.3