From e552d7734026c34a899c7cf4aeca72e55cb3ce90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 16 Sep 2020 11:10:01 +0800 Subject: =?UTF-8?q?=E6=99=9A=E7=82=B9=E5=86=8D=E6=9F=A5=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=BE=E7=BD=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-beta/provider/diagnostic.lua | 28 ++++++++++++++-------------- script-beta/provider/provider.lua | 2 ++ 2 files changed, 16 insertions(+), 14 deletions(-) (limited to 'script-beta/provider') diff --git a/script-beta/provider/diagnostic.lua b/script-beta/provider/diagnostic.lua index 89f97cda..7bc8022a 100644 --- a/script-beta/provider/diagnostic.lua +++ b/script-beta/provider/diagnostic.lua @@ -9,6 +9,7 @@ local util = require 'utility' local m = {} m._start = false +m._diagID = 0 m.cache = {} local function concat(t, sep) @@ -183,27 +184,26 @@ function m.refresh(uri) return files.getVersion(uri) end) await.delay() - local clock = os.clock() if uri then m.doDiagnostic(uri) end - for destUri in files.eachFile() do - if destUri ~= uri then - await.delay() - m.doDiagnostic(destUri) - end - end - local passed = os.clock() - clock - log.info(('Finish diagnostics, takes [%.3f] sec.'):format(passed)) + m.diagnosticsAll() end) end function m.diagnosticsAll() - local clock = os.clock() - for uri in files.eachFile() do - m.doDiagnostic(uri) - end - log.debug('全文诊断耗时:', os.clock() - clock) + await.create(function () + m._diagID = m._diagID + 1 + await.setDelayer(function () + return m._diagID + end) + local clock = os.clock() + for uri in files.eachFile() do + await.delay() + m.doDiagnostic(uri) + end + log.debug('全文诊断耗时:', os.clock() - clock) + end) end function m.start() diff --git a/script-beta/provider/provider.lua b/script-beta/provider/provider.lua index 3c01161a..5eda50ca 100644 --- a/script-beta/provider/provider.lua +++ b/script-beta/provider/provider.lua @@ -43,6 +43,8 @@ local function updateConfig() library.reload() end if not util.equal(oldConfig.diagnostics, newConfig.diagnostics) then + local diagnostics = require 'provider.diagnostic' + diagnostics.diagnosticsAll() end if not util.equal(oldConfig.plugin, newConfig.plugin) then end -- cgit v1.2.3