summaryrefslogtreecommitdiff
path: root/script/provider/diagnostic.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-22 21:30:31 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-22 21:30:31 +0800
commit3ef57391d605f1c72a81b9395d506823017c2693 (patch)
tree6815fc64bb2dc15e25f8bd49a88152cbd4659c05 /script/provider/diagnostic.lua
parentddc99653210996bf07e404d0dd295cde54d9096c (diff)
downloadlua-language-server-3ef57391d605f1c72a81b9395d506823017c2693.zip
#946 use a better way
Clear cache when `didOpen`. This avoids clearing the cache according to the situation in the diagnostic business.
Diffstat (limited to 'script/provider/diagnostic.lua')
-rw-r--r--script/provider/diagnostic.lua10
1 files changed, 4 insertions, 6 deletions
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua
index b359c21c..458b3764 100644
--- a/script/provider/diagnostic.lua
+++ b/script/provider/diagnostic.lua
@@ -131,9 +131,10 @@ local function mergeDiags(a, b, c)
return t
end
+-- enable `push`, disable `clear`
function m.clear(uri)
await.close('diag:' .. uri)
- if not m.cache[uri] then
+ if m.cache[uri] == nil then
return
end
m.cache[uri] = nil
@@ -144,6 +145,7 @@ function m.clear(uri)
log.info('clearDiagnostics', uri)
end
+-- enable `push` and `send`
function m.clearCache(uri)
m.cache[uri] = false
end
@@ -256,11 +258,6 @@ function m.doDiagnostic(uri, isScopeDiag)
end
end
- -- always re-sent diagnostics of current file
- if not isScopeDiag then
- m.cache[uri] = nil
- end
-
pushResult()
local lastPushClock = time.time()
@@ -435,6 +432,7 @@ files.watch(function (ev, uri) ---@async
m.refresh(uri)
elseif ev == 'open' then
if ws.isReady(uri) then
+ m.clearCache(uri)
xpcall(m.doDiagnostic, log.error, uri)
end
elseif ev == 'close' then