From 32dd2af081a40813683ced02a82a129efb604174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 18 Sep 2020 17:07:11 +0800 Subject: =?UTF-8?q?=E9=87=8D=E6=96=B0=E8=AE=BE=E8=AE=A1await=E7=9A=84?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E4=B8=AD=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-beta/provider/diagnostic.lua | 17 +++++------------ script-beta/provider/provider.lua | 2 +- 2 files changed, 6 insertions(+), 13 deletions(-) (limited to 'script-beta/provider') 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) -- cgit v1.2.3