diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-06-23 15:15:26 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-06-23 15:15:26 +0800 |
commit | 6c4a1ae9bdfcf146899993974444436a56ba53fc (patch) | |
tree | 6329ae9eb15bba6c7f0e613156d75909ba87d62d /script/provider | |
parent | 8c56e6ba9d85f3e01fb3658901386ee89de847ab (diff) | |
download | lua-language-server-6c4a1ae9bdfcf146899993974444436a56ba53fc.zip |
`FIX` diagnostics flash when opening a file
Diffstat (limited to 'script/provider')
-rw-r--r-- | script/provider/diagnostic.lua | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua index 4c94c952..8085713e 100644 --- a/script/provider/diagnostic.lua +++ b/script/provider/diagnostic.lua @@ -159,11 +159,6 @@ function m.clear(uri, force) log.info('clearDiagnostics', uri) end --- enable `push` and `send` -function m.clearCache(uri) - m.cache[uri] = false -end - function m.clearCacheExcept(uris) local excepts = {} for _, uri in ipairs(uris) do @@ -330,6 +325,23 @@ function m.doDiagnostic(uri, isScopeDiag) pushResult() end +---@param uri uri +function m.resendDiagnostic(uri) + local full = m.cache[uri] + if not full then + return + end + + local version = files.getVersion(uri) + + proto.notify('textDocument/publishDiagnostics', { + uri = uri, + version = version, + diagnostics = full, + }) + log.debug('publishDiagnostics', uri, #full) +end + ---@async ---@return table|nil result ---@return boolean? unchanged @@ -565,7 +577,7 @@ files.watch(function (ev, uri) ---@async m.refresh(uri) elseif ev == 'open' then if ws.isReady(uri) then - m.clearCache(uri) + m.resendDiagnostic(uri) xpcall(m.doDiagnostic, log.error, uri) end elseif ev == 'close' then |