summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-11-02 13:41:25 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-11-02 13:41:25 +0800
commit614196b67198e3e0765a25b6b9c1b0a45624855e (patch)
treefe4fcc74f01a0d95451e7fd8d0dc68e0b953dfe9
parent877aebdc2675986fce873272455d3530ce282907 (diff)
downloadlua-language-server-614196b67198e3e0765a25b6b9c1b0a45624855e.zip
diagnostics.workspaceDelay
-rw-r--r--script-beta/await.lua4
-rw-r--r--script-beta/config.lua1
-rw-r--r--script-beta/provider/diagnostic.lua9
3 files changed, 10 insertions, 4 deletions
diff --git a/script-beta/await.lua b/script-beta/await.lua
index a718dbb6..558c273e 100644
--- a/script-beta/await.lua
+++ b/script-beta/await.lua
@@ -100,7 +100,7 @@ function m.sleep(time)
end
local co = coroutine.running()
timer.wait(time, function ()
- if coroutine.status(co) == 'dead' then
+ if coroutine.status(co) ~= 'suspended' then
return
end
return m.checkResult(co, coroutine.resume(co))
@@ -121,7 +121,7 @@ function m.wait(callback, ...)
return
end
waked = true
- if coroutine.status(co) == 'dead' then
+ if coroutine.status(co) ~= 'suspended' then
return
end
return m.checkResult(co, coroutine.resume(co, ...))
diff --git a/script-beta/config.lua b/script-beta/config.lua
index 99f701fd..aeea415b 100644
--- a/script-beta/config.lua
+++ b/script-beta/config.lua
@@ -112,6 +112,7 @@ local ConfigTemplate = {
util.deepCopy(define.DiagnosticDefaultSeverity),
Hash(String, String),
},
+ workspaceDelay = {0, Integer},
},
workspace = {
ignoreDir = {{}, Str2Hash ';'},
diff --git a/script-beta/provider/diagnostic.lua b/script-beta/provider/diagnostic.lua
index 2bca538b..0e80daf5 100644
--- a/script-beta/provider/diagnostic.lua
+++ b/script-beta/provider/diagnostic.lua
@@ -185,8 +185,6 @@ function m.refresh(uri)
return
end
await.call(function ()
- -- 一旦文件的版本发生变化,就放弃这次诊断
- await.delay()
if uri then
m.doDiagnostic(uri)
end
@@ -198,8 +196,13 @@ function m.diagnosticsAll()
if not m._start then
return
end
+ local delay = config.config.diagnostics.workspaceDelay / 1000
+ if delay < 0 then
+ return
+ end
await.close 'diagnosticsAll'
await.call(function ()
+ await.sleep(delay)
local clock = os.clock()
for uri in files.eachFile() do
await.delay()
@@ -219,6 +222,8 @@ files.watch(function (ev, uri)
m.clear(uri)
elseif ev == 'update' then
m.refresh(uri)
+ elseif ev == 'open' then
+ m.doDiagnostic(uri)
end
end)