Merge pull request #14737 from rktjmp/lsp-guard-against-negative-lines

[RDY] fix(lsp): guard against negative diagnostic line numbers
This commit is contained in:
Michael Lingelbach
2021-06-14 15:01:58 -07:00
committed by GitHub

View File

@@ -271,12 +271,12 @@ local function set_diagnostic_cache(diagnostics, bufnr, client_id)
end end
-- Account for servers that place diagnostics on terminating newline -- Account for servers that place diagnostics on terminating newline
if buf_line_count > 0 then if buf_line_count > 0 then
diagnostic.range.start.line = math.min( diagnostic.range.start.line = math.max(math.min(
diagnostic.range.start.line, buf_line_count - 1 diagnostic.range.start.line, buf_line_count - 1
) ), 0)
diagnostic.range["end"].line = math.min( diagnostic.range["end"].line = math.max(math.min(
diagnostic.range["end"].line, buf_line_count - 1 diagnostic.range["end"].line, buf_line_count - 1
) ), 0)
end end
end end