summaryrefslogtreecommitdiff
path: root/script/provider
diff options
context:
space:
mode:
Diffstat (limited to 'script/provider')
-rw-r--r--script/provider/diagnostic.lua35
-rw-r--r--script/provider/provider.lua5
2 files changed, 30 insertions, 10 deletions
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua
index 9be9f87a..de8c3be1 100644
--- a/script/provider/diagnostic.lua
+++ b/script/provider/diagnostic.lua
@@ -1,12 +1,13 @@
-local await = require 'await'
-local proto = require 'proto.proto'
-local define = require 'proto.define'
-local lang = require 'language'
-local files = require 'files'
-local config = require 'config'
-local core = require 'core.diagnostics'
-local util = require 'utility'
-local ws = require 'workspace'
+local await = require 'await'
+local proto = require 'proto.proto'
+local define = require 'proto.define'
+local lang = require 'language'
+local files = require 'files'
+local config = require 'config'
+local core = require 'core.diagnostics'
+local util = require 'utility'
+local ws = require 'workspace'
+local progress = require "progress"
local m = {}
m._start = false
@@ -254,10 +255,24 @@ function m.diagnosticsAll()
await.sleep(delay)
m.diagnosticsAllClock = os.clock()
local clock = os.clock()
- for uri in files.eachFile() do
+ local bar <close> = progress.create(lang.script.WORKSPACE_DIAGNOSTIC)
+ local cancelled
+ bar:onCancel(function ()
+ log.debug('Cancel workspace diagnostics')
+ cancelled = true
+ end)
+ local uris = files.getAllUris()
+ for i, uri in ipairs(uris) do
+ bar:setMessage(('%d/%d'):format(i, #uris))
+ bar:setPercentage(i / #uris * 100)
m.doDiagnostic(uri)
await.delay()
+ if cancelled then
+ log.debug('Break workspace diagnostics')
+ break
+ end
end
+ bar:remove()
log.debug('全文诊断耗时:', os.clock() - clock)
end, 'files.version', 'diagnosticsAll')
end
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index ef300e02..0b880ff7 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -691,3 +691,8 @@ proto.on('textDocument/foldingRange', function (params)
return results
end)
+
+proto.on('window/workDoneProgress/cancel', function (params)
+ local progress = require 'progress'
+ progress.cancel(params.token)
+end)