aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/diagnostic.lua
diff options
context:
space:
mode:
authorTJ DeVries <devries.timothyj@gmail.com>2021-03-22 10:22:23 -0400
committerTJ DeVries <devries.timothyj@gmail.com>2021-03-22 10:22:23 -0400
commit875979ec3f528b01c8acf2cc5eec6c7854a181b9 (patch)
tree6f40eb9de5e499a369d66e5a8ef40ee6d74cdd5e /runtime/lua/vim/lsp/diagnostic.lua
parent880fb0d146ab752206c5261a58b568cc75d74637 (diff)
downloadrneovim-875979ec3f528b01c8acf2cc5eec6c7854a181b9.tar.gz
rneovim-875979ec3f528b01c8acf2cc5eec6c7854a181b9.tar.bz2
rneovim-875979ec3f528b01c8acf2cc5eec6c7854a181b9.zip
lsp: Unopened buffers return 0 for line count, which leads to broken positions
Diffstat (limited to 'runtime/lua/vim/lsp/diagnostic.lua')
-rw-r--r--runtime/lua/vim/lsp/diagnostic.lua6
1 files changed, 4 insertions, 2 deletions
diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua
index a1f24706c0..4e82c46fef 100644
--- a/runtime/lua/vim/lsp/diagnostic.lua
+++ b/runtime/lua/vim/lsp/diagnostic.lua
@@ -270,8 +270,10 @@ local function set_diagnostic_cache(diagnostics, bufnr, client_id)
diagnostic.severity = DiagnosticSeverity.Error
end
-- Account for servers that place diagnostics on terminating newline
- local start = diagnostic.range.start
- start.line = math.min(start.line, buf_line_count - 1)
+ if buf_line_count > 0 then
+ local start = diagnostic.range.start
+ start.line = math.min(start.line, buf_line_count - 1)
+ end
end
diagnostic_cache[bufnr][client_id] = diagnostics