aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/diagnostic.lua
diff options
context:
space:
mode:
authorGregory Anders <greg@gpanders.com>2021-11-19 11:20:04 -0700
committerGregory Anders <greg@gpanders.com>2021-11-19 11:37:45 -0700
commit2abc799ffd8b3b250f0ffce2f74a930ad3d19cf3 (patch)
treee616ba224337f64db823e6b9210c2fdbbac1a5bb /runtime/lua/vim/lsp/diagnostic.lua
parent9ec4417afc072533ed2c6924323e9d885c52f6fe (diff)
downloadrneovim-2abc799ffd8b3b250f0ffce2f74a930ad3d19cf3.tar.gz
rneovim-2abc799ffd8b3b250f0ffce2f74a930ad3d19cf3.tar.bz2
rneovim-2abc799ffd8b3b250f0ffce2f74a930ad3d19cf3.zip
fix(diagnostic): deepcopy diagnostics before clamping line numbers
The current 'clamp_line_numbers' implementation modifies diagnostics in place, which can have adverse downstream side effects. Before clamping line numbers, make a copy of the diagnostic. This commit also merges the 'clamp_line_numbers' method into a new 'get_diagnostics' local function which also implements the more general "get" method. The public 'vim.diagnostic.get()' API now just uses this function (without clamping). This has the added benefit that other internal API functions that need to use get() no longer have to go through vim.validate. Finally, reorganize the source code a bit by grouping all of the data structures together near the top of the file.
Diffstat (limited to 'runtime/lua/vim/lsp/diagnostic.lua')
-rw-r--r--runtime/lua/vim/lsp/diagnostic.lua2
1 files changed, 0 insertions, 2 deletions
diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua
index 1e6f83c1ba..76a4dc30b7 100644
--- a/runtime/lua/vim/lsp/diagnostic.lua
+++ b/runtime/lua/vim/lsp/diagnostic.lua
@@ -717,5 +717,3 @@ end
-- }}}
return M
-
--- vim: fdm=marker