summaryrefslogtreecommitdiff
path: root/script/vm
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-09-28 19:09:44 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-09-28 19:09:44 +0800
commite9fee73b62132d7fd5554da6a8237c0adf04d75a (patch)
tree9c450ef9b1cee43629bba5b343b8090f1c32e2e8 /script/vm
parent0599a24ec2e3a91480c3cd3f24c5792ad1a30eca (diff)
downloadlua-language-server-e9fee73b62132d7fd5554da6a8237c0adf04d75a.zip
test delay refresh node cache
#1595
Diffstat (limited to 'script/vm')
-rw-r--r--script/vm/node.lua15
1 files changed, 14 insertions, 1 deletions
diff --git a/script/vm/node.lua b/script/vm/node.lua
index 49207b13..9b10fa9d 100644
--- a/script/vm/node.lua
+++ b/script/vm/node.lua
@@ -3,6 +3,7 @@ local files = require 'files'
local vm = require 'vm.vm'
local ws = require 'workspace.workspace'
local guide = require 'parser.guide'
+local timer = require 'timer'
---@type table<vm.object, vm.node>
vm.nodeCache = {}
@@ -475,10 +476,22 @@ function vm.createNode(a, b)
return node
end
+---@type timer?
+local delayTimer
files.watch(function (ev, uri)
if ev == 'version' then
if ws.isReady(uri) then
- vm.clearNodeCache()
+ if PREVIEW then
+ if delayTimer then
+ delayTimer:restart()
+ end
+ delayTimer = timer.wait(1, function ()
+ delayTimer = nil
+ vm.clearNodeCache()
+ end)
+ else
+ vm.clearNodeCache()
+ end
end
end
end)