summaryrefslogtreecommitdiff
path: root/script-beta
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-11-03 12:51:22 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-11-03 12:51:22 +0800
commit33c919da907927ba9215a9fb1fe8805b5405cc5a (patch)
tree2ab12b010599c5e49f778e66f6f1c0cea345d895 /script-beta
parent106150b3063ac8ae9300373c664e0f9b7a3220c9 (diff)
downloadlua-language-server-33c919da907927ba9215a9fb1fe8805b5405cc5a.zip
重载工作目录时不要移除已经打开的文件
Diffstat (limited to 'script-beta')
-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