diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-06-18 02:43:51 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-06-18 02:43:51 +0800 |
commit | 256d5de895fd5f74467f2eefe35c96131c1adf15 (patch) | |
tree | a01acb5df4571dab39568e13bcf2c3539af282df /script | |
parent | 3494b7f1d0e93060cf0826f4f6c1b81d0d5e37a5 (diff) | |
download | lua-language-server-256d5de895fd5f74467f2eefe35c96131c1adf15.zip |
clear diags before restarting
Diffstat (limited to 'script')
-rw-r--r-- | script/provider/diagnostic.lua | 16 | ||||
-rw-r--r-- | script/provider/provider.lua | 2 |
2 files changed, 13 insertions, 5 deletions
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua index 5957e3eb..23dad33d 100644 --- a/script/provider/diagnostic.lua +++ b/script/provider/diagnostic.lua @@ -139,9 +139,9 @@ local function mergeDiags(a, b, c) end -- enable `push`, disable `clear` -function m.clear(uri) +function m.clear(uri, force) await.close('diag:' .. uri) - if m.cache[uri] == nil then + if m.cache[uri] == nil and not force then return end m.cache[uri] = nil @@ -169,9 +169,15 @@ function m.clearCacheExcept(uris) end end -function m.clearAll() - for luri in pairs(m.cache) do - m.clear(luri) +function m.clearAll(force) + if force then + for luri in files.eachFile() do + m.clear(luri, force) + end + else + for luri in pairs(m.cache) do + m.clear(luri) + end end end diff --git a/script/provider/provider.lua b/script/provider/provider.lua index e2531abf..205be08c 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -1019,6 +1019,8 @@ m.register '$/status/click' { diagnostic.diagnosticsScope(scp.uri, true) end elseif result == 'Restart Server' then + local diag = require 'provider.diagnostic' + diag.clearAll(true) os.exit(0, true) end end |