summaryrefslogtreecommitdiff
path: root/script/provider
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-01-06 14:51:38 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-01-06 14:51:38 +0800
commit995faa1c62849848a01a4cf7d462e443eb03c061 (patch)
tree4dc07c95d8b5a29964dae950c2af9973f9d9e87a /script/provider
parent8b3350de3d3e197a39b50135cbca0989e00fe32a (diff)
downloadlua-language-server-995faa1c62849848a01a4cf7d462e443eb03c061.zip
optimized diagnostic smoothing
Diffstat (limited to 'script/provider')
-rw-r--r--script/provider/diagnostic.lua19
1 files changed, 17 insertions, 2 deletions
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua
index a649ce8b..db967e81 100644
--- a/script/provider/diagnostic.lua
+++ b/script/provider/diagnostic.lua
@@ -61,6 +61,7 @@ local function buildSyntaxError(uri, err)
source = lang.script.DIAG_SYNTAX_CHECK,
message = message,
relatedInformation = relatedInformation,
+ data = 'syntax',
}
end
@@ -155,8 +156,9 @@ function m.syntaxErrors(uri, ast)
local results = {}
pcall(function ()
+ local disables = config.get(uri, 'Lua.diagnostics.disable')
for _, err in ipairs(ast.errs) do
- if not config.get(uri, 'Lua.diagnostics.disable')[err.type:lower():gsub('_', '-')] then
+ if not disables[err.type:lower():gsub('_', '-')] then
results[#results+1] = buildSyntaxError(uri, err)
end
end
@@ -165,6 +167,19 @@ function m.syntaxErrors(uri, ast)
return results
end
+local function copyDiagsWithoutSyntax(diags)
+ if not diags then
+ return nil
+ end
+ local copyed = {}
+ for _, diag in ipairs(diags) do
+ if diag.data ~= 'syntax' then
+ copyed[#copyed+1] = diag
+ end
+ end
+ return copyed
+end
+
---@async
function m.doDiagnostic(uri, isScopeDiag)
if not config.get(uri, 'Lua.diagnostics.enable') then
@@ -208,7 +223,7 @@ function m.doDiagnostic(uri, isScopeDiag)
local syntax = m.syntaxErrors(uri, state)
local diags = {}
- local lastDiag = util.deepCopy(m.cache[uri])
+ local lastDiag = copyDiagsWithoutSyntax(m.cache[uri])
local function pushResult()
tracy.ZoneBeginN 'mergeSyntaxAndDiags'
local _ <close> = tracy.ZoneEnd