summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script-beta/files.lua15
-rw-r--r--script-beta/workspace/workspace.lua2
2 files changed, 16 insertions, 1 deletions
diff --git a/script-beta/files.lua b/script-beta/files.lua
index 6f4d1ce9..873d859e 100644
--- a/script-beta/files.lua
+++ b/script-beta/files.lua
@@ -182,6 +182,21 @@ function m.removeAll()
--m.notifyCache = {}
end
+--- 移除所有关闭的文件
+function m.removeAllClosed()
+ m.globalVersion = m.globalVersion + 1
+ await.close('files.version')
+ for uri in pairs(m.fileMap) do
+ if not m.openMap[uri] then
+ m.fileMap[uri] = nil
+ m.astMap[uri] = nil
+ m.linesMap[uri] = nil
+ m.onWatch('remove', uri)
+ end
+ end
+ --m.notifyCache = {}
+end
+
--- 遍历文件
function m.eachFile()
return pairs(m.fileMap)
diff --git a/script-beta/workspace/workspace.lua b/script-beta/workspace/workspace.lua
index 1ea48b0c..8fc2d8d9 100644
--- a/script-beta/workspace/workspace.lua
+++ b/script-beta/workspace/workspace.lua
@@ -283,7 +283,7 @@ function m.getRelativePath(uri)
end
function m.reload()
- files.removeAll()
+ files.removeAllClosed()
rpath.flush()
await.call(m.awaitPreload)
end