Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions script/core/diagnostics/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ end
---@param name string
---@param isScopeDiag boolean
---@param response async fun(result: any)
---@param ignoreFileOpenState? boolean
---@return boolean
local function check(uri, name, isScopeDiag, response)
local function check(uri, name, isScopeDiag, response, ignoreFileOpenState)
local disables = config.get(uri, 'Lua.diagnostics.disable')
if util.arrayHas(disables, name) then
return false
Expand All @@ -107,7 +108,7 @@ local function check(uri, name, isScopeDiag, response)
return false
end

if status == 'Opened' and not files.isOpen(uri) then
if not ignoreFileOpenState and status == 'Opened' and not files.isOpen(uri) then
return false
end

Expand Down Expand Up @@ -167,7 +168,8 @@ end
---@param isScopeDiag boolean
---@param response async fun(result: any)
---@param checked? async fun(name: string)
return function (uri, isScopeDiag, response, checked)
---@param ignoreFileOpenState? boolean
return function (uri, isScopeDiag, response, checked, ignoreFileOpenState)
local ast = files.getState(uri)
if not ast then
return nil
Expand All @@ -176,7 +178,7 @@ return function (uri, isScopeDiag, response, checked)
for _, name in ipairs(buildDiagList()) do
await.delay()
local clock = os.clock()
local suc = check(uri, name, isScopeDiag, response)
local suc = check(uri, name, isScopeDiag, response, ignoreFileOpenState)
if suc then
local cost = os.clock() - clock
diagCosts[name] = (diagCosts[name] or 0) + cost
Expand Down
8 changes: 4 additions & 4 deletions script/provider/diagnostic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ local function isValid(uri)
end

---@async
function m.doDiagnostic(uri, isScopeDiag)
function m.doDiagnostic(uri, isScopeDiag, ignoreFileState)
if not isValid(uri) then
return
end
Expand Down Expand Up @@ -348,7 +348,7 @@ function m.doDiagnostic(uri, isScopeDiag)
lastDiag[#lastDiag] = nil
end
end
end)
end, ignoreFileState)

lastDiag = nil
pushResult()
Expand Down Expand Up @@ -575,7 +575,7 @@ function m.awaitDiagnosticsScope(suri, callback)
finished = true
end

function m.diagnosticsScope(uri, force)
function m.diagnosticsScope(uri, force, ignoreFileOpenState)
if not ws.isReady(uri) then
return
end
Expand All @@ -592,7 +592,7 @@ function m.diagnosticsScope(uri, force)
await.call(function () ---@async
await.sleep(0.0)
m.awaitDiagnosticsScope(uri, function (fileUri)
xpcall(m.doDiagnostic, log.error, fileUri, true)
xpcall(m.doDiagnostic, log.error, fileUri, true, ignoreFileOpenState)
end)
end, id)
end
Expand Down
2 changes: 1 addition & 1 deletion script/provider/provider.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ m.register '$/status/click' {
if result == titleDiagnostic then
local diagnostic = require 'provider.diagnostic'
for _, scp in ipairs(workspace.folders) do
diagnostic.diagnosticsScope(scp.uri, true)
diagnostic.diagnosticsScope(scp.uri, true, true)
end
elseif result == 'Restart Server' then
local diag = require 'provider.diagnostic'
Expand Down