aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/diagnostic.lua
diff options
context:
space:
mode:
authorEvgeni Chasnovski <evgeni.chasnovski@gmail.com>2023-09-06 20:54:18 +0300
committerGitHub <noreply@github.com>2023-09-06 12:54:18 -0500
commitd27214331815324ea5762b5aa22996b9019085c6 (patch)
treec8e6e9c287ff88e89013161073a72f34fa00a7b7 /runtime/lua/vim/diagnostic.lua
parent2ef7b6a433c61837bcef0fca297a665551835423 (diff)
downloadrneovim-d27214331815324ea5762b5aa22996b9019085c6.tar.gz
rneovim-d27214331815324ea5762b5aa22996b9019085c6.tar.bz2
rneovim-d27214331815324ea5762b5aa22996b9019085c6.zip
fix(diagnostic): always return copies of diagnostic items (#25010)
Diffstat (limited to 'runtime/lua/vim/diagnostic.lua')
-rw-r--r--runtime/lua/vim/diagnostic.lua4
1 files changed, 3 insertions, 1 deletions
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua
index 96d1cb7629..a1f3020c88 100644
--- a/runtime/lua/vim/diagnostic.lua
+++ b/runtime/lua/vim/diagnostic.lua
@@ -386,6 +386,7 @@ local function get_diagnostics(bufnr, opts, clamp)
local function add(b, d)
if not opts.lnum or d.lnum == opts.lnum then
+ d = vim.deepcopy(d)
if clamp and api.nvim_buf_is_loaded(b) then
local line_count = buf_line_count[b] - 1
if
@@ -396,7 +397,6 @@ local function get_diagnostics(bufnr, opts, clamp)
or d.col < 0
or d.end_col < 0
then
- d = vim.deepcopy(d)
d.lnum = math.max(math.min(d.lnum, line_count), 0)
d.end_lnum = math.max(math.min(d.end_lnum, line_count), 0)
d.col = math.max(d.col, 0)
@@ -750,6 +750,8 @@ end
--- Get current diagnostics.
---
+--- Modifying diagnostics in the returned table has no effect. To set diagnostics in a buffer, use |vim.diagnostic.set()|.
+---
---@param bufnr integer|nil Buffer number to get diagnostics from. Use 0 for
--- current buffer or nil for all buffers.
---@param opts table|nil A table with the following keys: