summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-03-04 14:38:03 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-03-04 14:38:03 +0800
commit22a1e4400b9dc25f8ef0c1b9fc323e8a07cb508e (patch)
treec48e4fb2e6aceb0f381f28357e5befea0fd9ff9a /script
parentf583a9f73c9e6edc101ea657b0e28fb1726e0747 (diff)
downloadlua-language-server-22a1e4400b9dc25f8ef0c1b9fc323e8a07cb508e.zip
diagnostic opened files first
Diffstat (limited to 'script')
-rw-r--r--script/provider/diagnostic.lua23
1 files changed, 17 insertions, 6 deletions
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua
index 3e587009..ac93dc52 100644
--- a/script/provider/diagnostic.lua
+++ b/script/provider/diagnostic.lua
@@ -13,6 +13,7 @@ local converter = require 'proto.converter'
local loading = require 'workspace.loading'
local scope = require 'workspace.scope'
local time = require 'bee.time'
+local ltable = require 'linked-table'
---@class diagnosticProvider
local m = {}
@@ -360,28 +361,38 @@ local function askForDisable(uri)
end
---@async
-function m.awaitDiagnosticsScope(uri)
- local scp = scope.getScope(uri)
+function m.awaitDiagnosticsScope(suri)
+ local scp = scope.getScope(suri)
while loading.count() > 0 do
await.sleep(1.0)
end
local clock = os.clock()
- local bar <close> = progress.create(scope.getScope(uri), lang.script.WORKSPACE_DIAGNOSTIC, 1)
+ local bar <close> = progress.create(scope.getScope(suri), lang.script.WORKSPACE_DIAGNOSTIC, 1)
local cancelled
bar:onCancel(function ()
log.debug('Cancel workspace diagnostics')
cancelled = true
---@async
await.call(function ()
- askForDisable(uri)
+ askForDisable(suri)
end)
end)
- local uris = files.getAllUris(uri)
+ local uris = files.getAllUris(suri)
+ local sortedUris = ltable()
+ for _, uri in ipairs(uris) do
+ if files.isOpen(uri) then
+ sortedUris:pushHead(uri)
+ else
+ sortedUris:pushTail(uri)
+ end
+ end
log.info(('Diagnostics scope [%s], files count:[%d]'):format(scp:getName(), #uris))
- for i, uri in ipairs(uris) do
+ local i = 0
+ for uri in sortedUris:pairs() do
while loading.count() > 0 do
await.sleep(1.0)
end
+ i = i + 1
bar:setMessage(('%d/%d'):format(i, #uris))
bar:setPercentage(i / #uris * 100)
xpcall(m.doDiagnostic, log.error, uri, true)