summaryrefslogtreecommitdiff
path: root/script-beta/provider
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-09-18 17:07:11 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-09-18 17:07:11 +0800
commit32dd2af081a40813683ced02a82a129efb604174 (patch)
tree6134c900c7dd93680dd34d855bbae4815e6da4dd /script-beta/provider
parent8dc4b5d3f8145e679ae27b2b7e8a85cc122f7044 (diff)
downloadlua-language-server-32dd2af081a40813683ced02a82a129efb604174.zip
重新设计await的任务中断
Diffstat (limited to 'script-beta/provider')
-rw-r--r--script-beta/provider/diagnostic.lua17
-rw-r--r--script-beta/provider/provider.lua2
2 files changed, 6 insertions, 13 deletions
diff --git a/script-beta/provider/diagnostic.lua b/script-beta/provider/diagnostic.lua
index 7bc8022a..1a6537f8 100644
--- a/script-beta/provider/diagnostic.lua
+++ b/script-beta/provider/diagnostic.lua
@@ -9,7 +9,6 @@ local util = require 'utility'
local m = {}
m._start = false
-m._diagID = 0
m.cache = {}
local function concat(t, sep)
@@ -178,32 +177,26 @@ function m.refresh(uri)
if not m._start then
return
end
- await.create(function ()
+ await.call(function ()
-- 一旦文件的版本发生变化,就放弃这次诊断
- await.setDelayer(function ()
- return files.getVersion(uri)
- end)
await.delay()
if uri then
m.doDiagnostic(uri)
end
m.diagnosticsAll()
- end)
+ end, 'files.version')
end
function m.diagnosticsAll()
- await.create(function ()
- m._diagID = m._diagID + 1
- await.setDelayer(function ()
- return m._diagID
- end)
+ await.close 'diagnosticsAll'
+ await.call(function ()
local clock = os.clock()
for uri in files.eachFile() do
await.delay()
m.doDiagnostic(uri)
end
log.debug('全文诊断耗时:', os.clock() - clock)
- end)
+ end, 'files.version', 'diagnosticsAll')
end
function m.start()
diff --git a/script-beta/provider/provider.lua b/script-beta/provider/provider.lua
index d908e917..07ecae1f 100644
--- a/script-beta/provider/provider.lua
+++ b/script-beta/provider/provider.lua
@@ -100,7 +100,7 @@ proto.on('initialized', function (params)
}
}
})
- await.create(workspace.awaitPreload)
+ await.call(workspace.awaitPreload)
return true
end)