diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-11-19 18:30:25 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-11-19 18:30:25 +0800 |
commit | eaa3c93756ab549f0184ebdb2d50c350d904bd70 (patch) | |
tree | b7da4269ec4c56e8d42679a5958984f7d8973b7a /server-beta/src/provider/diagnostic.lua | |
parent | e0eef52ac0a819a1c211231f908072562c78caf0 (diff) | |
download | lua-language-server-eaa3c93756ab549f0184ebdb2d50c350d904bd70.zip |
诊断进行一下过滤,以免影响前端的性能
Diffstat (limited to 'server-beta/src/provider/diagnostic.lua')
-rw-r--r-- | server-beta/src/provider/diagnostic.lua | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/server-beta/src/provider/diagnostic.lua b/server-beta/src/provider/diagnostic.lua index 6583c8d8..df5fd419 100644 --- a/server-beta/src/provider/diagnostic.lua +++ b/server-beta/src/provider/diagnostic.lua @@ -144,10 +144,20 @@ function m.doDiagnostic(uri, syntaxOnly) local syntax = m.syntaxErrors(uri, ast) local diagnostics = m.diagnostics(uri, syntaxOnly) + local newDiag = merge(syntax, diagnostics) + local lastDiag = files.getDiagnostic(uri) + if #newDiag == 0 then + if not lastDiag then + return + end + files.setDiagnostic(uri, nil) + else + files.setDiagnostic(uri, newDiag) + end proto.notify('textDocument/publishDiagnostics', { uri = uri, - diagnostics = merge(syntax, diagnostics), + diagnostics = newDiag, }) end |