summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-01-22 16:44:38 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-01-22 16:44:38 +0800
commit6f4cf8d4f2551672e3bc0fe472445485c3acbe3f (patch)
tree7865be2f1f6cc527c2db986295d697d0969075af /server/src
parent5df9959be4a51ab567743b72753f15a24b8f7ef6 (diff)
downloadlua-language-server-6f4cf8d4f2551672e3bc0fe472445485c3acbe3f.zip
删除文件后清空缓存
Diffstat (limited to 'server/src')
-rw-r--r--server/src/method/workspace/didChangeWatchedFiles.lua2
-rw-r--r--server/src/service.lua9
-rw-r--r--server/src/workspace.lua5
3 files changed, 8 insertions, 8 deletions
diff --git a/server/src/method/workspace/didChangeWatchedFiles.lua b/server/src/method/workspace/didChangeWatchedFiles.lua
index 8f0feecd..a5fecac3 100644
--- a/server/src/method/workspace/didChangeWatchedFiles.lua
+++ b/server/src/method/workspace/didChangeWatchedFiles.lua
@@ -14,8 +14,6 @@ return function (lsp, params)
lsp.workspace:addFile(change.uri)
elseif change.type == FileChangeType.Deleted then
lsp.workspace:removeFile(change.uri)
- -- 删除文件后,清除该文件的诊断
- lsp:clearDiagnostics(change.uri)
end
if lsp:getVM(change.uri) then
needReset = true
diff --git a/server/src/service.lua b/server/src/service.lua
index 37cb048e..9a5f5313 100644
--- a/server/src/service.lua
+++ b/server/src/service.lua
@@ -87,6 +87,7 @@ function mt:clearDiagnostics(uri)
uri = uri,
diagnostics = {},
})
+ log.debug('清除诊断:', uri)
end
function mt:read(mode)
@@ -167,11 +168,9 @@ function mt:readText(uri, path)
end
function mt:removeText(uri)
- local obj = self._file[uri]
- if obj then
- return
- end
- obj.version = -1
+ self._file[uri] = nil
+ -- 删除文件后,清除该文件的诊断
+ self:clearDiagnostics(uri)
end
function mt:reCompile()
diff --git a/server/src/workspace.lua b/server/src/workspace.lua
index 283b4951..8c1c6492 100644
--- a/server/src/workspace.lua
+++ b/server/src/workspace.lua
@@ -114,14 +114,17 @@ end
function mt:addFile(uri)
if uri:sub(-4) == '.lua' then
- local name = self:uriDecode(uri):string():lower()
+ local path = self:uriDecode(uri)
+ local name = path:string():lower()
self.files[name] = uri
+ self.lsp:readText(uri, path)
end
end
function mt:removeFile(uri)
local name = self:uriDecode(uri):string():lower()
self.files[name] = nil
+ self.lsp:removeText(uri)
end
function mt:findPath(baseUri, searchers)