diff options
author | AlexCai2019 <89138532+AlexCai2019@users.noreply.github.com> | 2022-05-08 01:43:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-08 01:43:28 +0800 |
commit | 0fd83c4ca9f82a02becab6c304a8a7de75098507 (patch) | |
tree | be9790d9d4823fe728c5b36e94093fe5f42b7725 /script/provider/diagnostic.lua | |
parent | 89203efad8c9b5513e05ca4d5696107924865b10 (diff) | |
parent | 67b4c574849d1667e0ecb39c51aeed8e30b43056 (diff) | |
download | lua-language-server-0fd83c4ca9f82a02becab6c304a8a7de75098507.zip |
Merge branch 'sumneko:master' into master
Diffstat (limited to 'script/provider/diagnostic.lua')
-rw-r--r-- | script/provider/diagnostic.lua | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua index b359c21c..15b08d49 100644 --- a/script/provider/diagnostic.lua +++ b/script/provider/diagnostic.lua @@ -128,12 +128,17 @@ local function mergeDiags(a, b, c) merge(b) merge(c) + if #t == 0 then + return nil + end + 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 +149,7 @@ function m.clear(uri) log.info('clearDiagnostics', uri) end +-- enable `push` and `send` function m.clearCache(uri) m.cache[uri] = false end @@ -251,14 +257,7 @@ function m.doDiagnostic(uri, isScopeDiag) version = version, diagnostics = full, }) - if #full > 0 then - log.debug('publishDiagnostics', uri, #full) - end - end - - -- always re-sent diagnostics of current file - if not isScopeDiag then - m.cache[uri] = nil + log.debug('publishDiagnostics', uri, #full) end pushResult() @@ -435,6 +434,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 |