summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/await.lua5
-rw-r--r--script/workspace/workspace.lua4
2 files changed, 7 insertions, 2 deletions
diff --git a/script/await.lua b/script/await.lua
index fa2aea13..22745570 100644
--- a/script/await.lua
+++ b/script/await.lua
@@ -108,6 +108,11 @@ function m.hasID(id, co)
return m.idMap[id] and m.idMap[id][co] ~= nil
end
+function m.unique(id, callback)
+ m.close(id)
+ m.setID(id, callback)
+end
+
--- 休眠一段时间
---@param time number
---@async
diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua
index a55e6246..da2f9daf 100644
--- a/script/workspace/workspace.lua
+++ b/script/workspace/workspace.lua
@@ -469,8 +469,6 @@ function m.flushFiles(scp)
for uri in pairs(cachedUris) do
files.delRef(uri)
end
- collectgarbage()
- collectgarbage()
end
---@param scp scope
@@ -491,6 +489,8 @@ end
---@async
---@param scp scope
function m.awaitReload(scp)
+ await.unique('workspace reload:' .. scp:getName())
+ await.sleep(0.1)
scp:set('ready', false)
scp:set('nativeMatcher', nil)
scp:set('libraryMatcher', nil)