Merge pull request #14769 from mjlbach/feature/fix_diagnostic_end_range

fix(lsp): cap diagnostic end range to buf length
This commit is contained in:
Michael Lingelbach
2021-06-11 01:13:03 -07:00
committed by GitHub

View File

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