aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/diagnostic.lua
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2021-12-16 11:20:18 -0700
committerGitHub <noreply@github.com>2021-12-16 11:20:18 -0700
commitb515160cef5c160c271dc11649094803625123dc (patch)
treec3f36c91f19d86031444dfae271b28ab96aa58ea /runtime/lua/vim/diagnostic.lua
parent4240ce8eb38ee9c89ce8694faab37e8db8fca209 (diff)
downloadrneovim-b515160cef5c160c271dc11649094803625123dc.tar.gz
rneovim-b515160cef5c160c271dc11649094803625123dc.tar.bz2
rneovim-b515160cef5c160c271dc11649094803625123dc.zip
fix(diagnostic): assert that diagnostics have line number and column (#16683)
Line number and column are required and much of the diagnostic API assumes that these are both present. When one of the two is missing, cryptic errors pop up in other parts of the diagnostic subsystem. Instead, assert that diagnostics are well formed when they are entered into the cache, which provides a clearer error.
Diffstat (limited to 'runtime/lua/vim/diagnostic.lua')
-rw-r--r--runtime/lua/vim/diagnostic.lua2
1 files changed, 2 insertions, 0 deletions
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua
index 59cb9f8c5b..a33fb2679c 100644
--- a/runtime/lua/vim/diagnostic.lua
+++ b/runtime/lua/vim/diagnostic.lua
@@ -272,6 +272,8 @@ end
---@private
local function set_diagnostic_cache(namespace, bufnr, diagnostics)
for _, diagnostic in ipairs(diagnostics) do
+ assert(diagnostic.lnum, "Diagnostic line number is required")
+ assert(diagnostic.col, "Diagnostic column is required")
diagnostic.severity = diagnostic.severity and to_severity(diagnostic.severity) or M.severity.ERROR
diagnostic.end_lnum = diagnostic.end_lnum or diagnostic.lnum
diagnostic.end_col = diagnostic.end_col or diagnostic.col