summaryrefslogtreecommitdiff
path: root/script/provider
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-02-02 16:59:55 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-02-02 16:59:55 +0800
commitf5ae885f62c8bf5a3b6086177b5a703406459916 (patch)
treee36ff1eba467da2fee9c462fba97c2737c74741f /script/provider
parentcd5b93f0308ca9e3f494344a626730efdc10f219 (diff)
downloadlua-language-server-f5ae885f62c8bf5a3b6086177b5a703406459916.zip
stash
Diffstat (limited to 'script/provider')
-rw-r--r--script/provider/provider.lua16
1 files changed, 11 insertions, 5 deletions
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index a7a15b84..a7927715 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -157,11 +157,17 @@ end)
proto.on('workspace/didChangeWatchedFiles', function (params)
for _, change in ipairs(params.changes) do
local uri = change.uri
- -- TODO 创建文件与删除文件直接重新扫描(文件改名、文件夹删除等情况太复杂了)
- if change.type == define.FileChangeType.Created
- or change.type == define.FileChangeType.Deleted then
- workspace.reload()
- break
+ if change.type == define.FileChangeType.Created then
+ log.debug('FileChangeType.Created', uri)
+ workspace.awaitLoadFile(uri)
+ elseif change.type == define.FileChangeType.Deleted then
+ log.debug('FileChangeType.Deleted', uri)
+ files.remove(uri)
+ local childs = files.getChildFiles(uri)
+ for _, curi in ipairs(childs) do
+ log.debug('FileChangeType.Deleted.Child', curi)
+ files.remove(curi)
+ end
elseif change.type == define.FileChangeType.Changed then
-- 如果文件处于关闭状态,则立即更新;否则等待didChange协议来更新
if files.isLua(uri) and not files.isOpen(uri) then