aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Marriott <hello@omarriott.com>2021-06-07 02:41:53 +1000
committerOliver Marriott <hello@omarriott.com>2021-06-13 03:38:59 +1000
commitee4735881d5da41c05507537a05c7c118fe058d9 (patch)
treee67c678f9f6f8324629605112c768ac227dda4cb
parentd3bdde0bad12458128fae817aa348ac1d07b6f35 (diff)
downloadrneovim-ee4735881d5da41c05507537a05c7c118fe058d9.tar.gz
rneovim-ee4735881d5da41c05507537a05c7c118fe058d9.tar.bz2
rneovim-ee4735881d5da41c05507537a05c7c118fe058d9.zip
fix(lsp): guard against negative diagnostic line numbers
-rw-r--r--runtime/lua/vim/lsp/diagnostic.lua8
1 files changed, 4 insertions, 4 deletions
diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua
index 05b68472e7..c6fed54908 100644
--- a/runtime/lua/vim/lsp/diagnostic.lua
+++ b/runtime/lua/vim/lsp/diagnostic.lua
@@ -271,12 +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
- diagnostic.range.start.line = math.min(
+ diagnostic.range.start.line = math.max(math.min(
diagnostic.range.start.line, buf_line_count - 1
- )
- diagnostic.range["end"].line = math.min(
+ ), 0)
+ diagnostic.range["end"].line = math.max(math.min(
diagnostic.range["end"].line, buf_line_count - 1
- )
+ ), 0)
end
end