diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-16 23:32:59 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-16 23:32:59 +0800 |
commit | 944b7d59f9dbb8f7f41083478018f3e3ae255713 (patch) | |
tree | 6245a2234956278610e42ae923660ff84bd7507c | |
parent | d31ecd5f2b8793667b3e8dad576737440c47a29d (diff) | |
download | lua-language-server-944b7d59f9dbb8f7f41083478018f3e3ae255713.zip |
cleanup
-rw-r--r-- | script/files.lua | 7 | ||||
-rw-r--r-- | script/vm/manager.lua | 7 | ||||
-rw-r--r-- | script/vm/node.lua | 5 |
3 files changed, 7 insertions, 12 deletions
diff --git a/script/files.lua b/script/files.lua index 768a7434..d16474fd 100644 --- a/script/files.lua +++ b/script/files.lua @@ -210,7 +210,7 @@ function m.setText(uri, text, isTrust, callback) file.cache = {} file.cacheActiveTime = math.huge m.globalVersion = m.globalVersion + 1 - m.onWatch('version') + m.onWatch('version', uri) if create then m.onWatch('create', uri) m.onWatch('update', uri) @@ -391,7 +391,6 @@ end --- 移除文件 ---@param uri uri function m.remove(uri) - local originUri = uri local file = m.fileMap[uri] if not file then return @@ -403,8 +402,8 @@ function m.remove(uri) m.fileCount = m.fileCount - 1 m.globalVersion = m.globalVersion + 1 - m.onWatch('version') - m.onWatch('remove', originUri) + m.onWatch('version', uri) + m.onWatch('remove', uri) end --- 获取一个包含所有文件uri的数组 diff --git a/script/vm/manager.lua b/script/vm/manager.lua index c9103ff9..58255fca 100644 --- a/script/vm/manager.lua +++ b/script/vm/manager.lua @@ -7,12 +7,6 @@ local localManager = require 'vm.local-manager' ---@class vm.state local m = {} -for uri in files.eachFile() do - local state = files.getState(uri) - if state then - globalManager.compileAst(state.ast) - end -end files.watch(function (ev, uri) if ev == 'update' then @@ -29,5 +23,4 @@ files.watch(function (ev, uri) end end) - return m diff --git a/script/vm/node.lua b/script/vm/node.lua index 21f95a49..6906da7e 100644 --- a/script/vm/node.lua +++ b/script/vm/node.lua @@ -2,6 +2,7 @@ local files = require 'files' local localMgr = require 'vm.local-manager' ---@class vm local vm = require 'vm.vm' +local ws = require 'workspace.workspace' ---@type table<vm.object, vm.node> vm.nodeCache = {} @@ -271,6 +272,8 @@ end files.watch(function (ev, uri) if ev == 'version' then - vm.clearNodeCache() + if ws.isReady(uri) then + vm.clearNodeCache() + end end end) |