summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-03-25 18:18:53 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-03-25 18:18:53 +0800
commitacf3e53057a29a94361b8406a98572d32828e366 (patch)
tree2d8284e4e827d2c19c97d444d0cc539be3d5281a /server
parentbd17ba6c89c27310c893877bd5df8c00d09974e1 (diff)
downloadlua-language-server-acf3e53057a29a94361b8406a98572d32828e366.zip
修正一些bug
Diffstat (limited to 'server')
-rw-r--r--server/src/service.lua28
1 files changed, 25 insertions, 3 deletions
diff --git a/server/src/service.lua b/server/src/service.lua
index 569f363f..92c24664 100644
--- a/server/src/service.lua
+++ b/server/src/service.lua
@@ -145,11 +145,12 @@ function mt:isWaitingCompile()
end
function mt:saveText(uri, version, text)
+ self._lastLoadedVM = nil
local obj = self._file[uri]
if obj then
obj.version = version
+ obj.oldText = obj.text
obj.text = text
- obj.oldText = text
self:needCompile(uri)
else
self._file[uri] = {
@@ -161,6 +162,17 @@ function mt:saveText(uri, version, text)
end
end
+function mt:isDeadText(uri)
+ local obj = self._file[uri]
+ if not obj then
+ return true
+ end
+ if obj.version == -1 then
+ return true
+ end
+ return false
+end
+
function mt:open(uri, version, text)
self:saveText(uri, version, text)
local obj = self._file[uri]
@@ -196,7 +208,7 @@ function mt:readText(uri, path, buf, compiled)
return
end
self._file[uri] = {
- version = -1,
+ version = 0,
text = text,
uri = uri,
}
@@ -231,8 +243,8 @@ end
function mt:ClearAllFiles()
for uri in pairs(self._file) do
- self:clearDiagnostics(uri)
self:removeText(uri)
+ self:clearDiagnostics(uri)
end
end
@@ -359,6 +371,12 @@ function mt:compileVM(uri)
if vm then
CachedVM[vm] = true
end
+ if self:isDeadText(uri) then
+ if vm then
+ vm:remove()
+ end
+ return nil
+ end
if version ~= obj.version then
if vm then
vm:remove()
@@ -419,6 +437,9 @@ function mt:doDiagnostics(uri)
version = obj.vmVersion,
}
local res = self:_callMethod(name, data)
+ if self:isDeadText(uri) then
+ return
+ end
if obj.version ~= data.version then
return
end
@@ -428,6 +449,7 @@ function mt:doDiagnostics(uri)
return
end
if res then
+ log.debug('诊断:', uri, obj.version)
rpc:notify(name, {
uri = uri,
diagnostics = res,