diff options
Diffstat (limited to 'script/provider/diagnostic.lua')
-rw-r--r-- | script/provider/diagnostic.lua | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua index 583173f0..0fac3e17 100644 --- a/script/provider/diagnostic.lua +++ b/script/provider/diagnostic.lua @@ -391,23 +391,22 @@ function m.pullDiagnostic(uri, isScopeDiag) return full end +---@param event string ---@param uri uri -function m.refresh(uri) +function m.refreshScopeDiag(event, uri) if not ws.isReady(uri) then return end - - await.close('diag:' .. uri) - ---@async - await.call(function () - await.setID('diag:' .. uri) - await.sleep(0.1) - xpcall(m.doDiagnostic, log.error, uri) - end) - local scp = scope.getScope(uri) local scopeID = 'diagnosticsScope:' .. scp:getName() await.close(scopeID) + + local eventConfig = config.get(uri, 'Lua.diagnostics.workspaceEvent') + + if eventConfig ~= event then + return + end + ---@async await.call(function () local delay = config.get(uri, 'Lua.diagnostics.workspaceDelay') / 1000 @@ -419,6 +418,21 @@ function m.refresh(uri) end) end +---@param uri uri +function m.refresh(uri) + if not ws.isReady(uri) then + return + end + + await.close('diag:' .. uri) + ---@async + await.call(function () + await.setID('diag:' .. uri) + await.sleep(0.1) + xpcall(m.doDiagnostic, log.error, uri) + end) +end + ---@async local function askForDisable(uri) if m.dontAskedForDisable then @@ -613,6 +627,7 @@ files.watch(function (ev, uri) ---@async m.refresh(uri) elseif ev == 'update' then m.refresh(uri) + m.refreshScopeDiag('OnChange', uri) elseif ev == 'open' then if ws.isReady(uri) then m.resendDiagnostic(uri) @@ -623,6 +638,8 @@ files.watch(function (ev, uri) ---@async or ws.isIgnored(uri) then m.clear(uri) end + elseif ev == 'save' then + m.refreshScopeDiag('OnSave', uri) end end) |