summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-01-25 11:13:38 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-01-25 11:13:38 +0800
commitc0c5135762beb102e693d2c58ccc031846f920c7 (patch)
treefede461e62d35cd26f1ce4e1a3d7a47edf2e4981
parentf956fc7f9ee8e2c4595b3fa843ebfaa41f97469e (diff)
downloadlua-language-server-c0c5135762beb102e693d2c58ccc031846f920c7.zip
全局变量缓存在工作目录中
-rw-r--r--server/src/core/vm.lua16
1 files changed, 9 insertions, 7 deletions
diff --git a/server/src/core/vm.lua b/server/src/core/vm.lua
index b2e8ff7d..b747ccf3 100644
--- a/server/src/core/vm.lua
+++ b/server/src/core/vm.lua
@@ -3,7 +3,6 @@ local library = require 'core.library'
local createValue = require 'core.value'
local DefaultSource = { start = 0, finish = 0 }
-local GlobalValue
local LibraryValue = {}
local LibraryChild = {}
@@ -1435,17 +1434,20 @@ function mt:doActions(actions)
end
function mt:getGlobalValue()
- if GlobalValue then
- return GlobalValue
+ if self.lsp and self.lsp.globalValue then
+ return self.lsp.globalValue
end
- GlobalValue = self:createValue('table')
- GlobalValue.GLOBAL = true
+ local globalValue = self:createValue('table')
+ globalValue.GLOBAL = true
for name, lib in pairs(library.global) do
- local field = GlobalValue:createField(name)
+ local field = globalValue:createField(name)
local value = self:getLibValue(lib, 'global')
self:setValue(field, value)
end
- return GlobalValue
+ if self.lsp then
+ self.lsp.globalValue = globalValue
+ end
+ return globalValue
end
function mt:createEnvironment()