aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/diagnostic.lua
diff options
context:
space:
mode:
authorJeremy Fleischman <jeremyfleischman@gmail.com>2024-12-12 02:41:57 -0800
committerGitHub <noreply@github.com>2024-12-12 02:41:57 -0800
commitde794f2d24099b73419ce2cd98424f702908040f (patch)
tree07c9628c385013dac4dcddde95583cf99cbbb74c /runtime/lua/vim/diagnostic.lua
parent130f4344cf1a8fdafcf62b392ead863d1a1379f3 (diff)
downloadrneovim-de794f2d24099b73419ce2cd98424f702908040f.tar.gz
rneovim-de794f2d24099b73419ce2cd98424f702908040f.tar.bz2
rneovim-de794f2d24099b73419ce2cd98424f702908040f.zip
fix(diagnostic): broken variable reference #31557
Diffstat (limited to 'runtime/lua/vim/diagnostic.lua')
-rw-r--r--runtime/lua/vim/diagnostic.lua12
1 files changed, 7 insertions, 5 deletions
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua
index 62997924d9..ded7a8f89d 100644
--- a/runtime/lua/vim/diagnostic.lua
+++ b/runtime/lua/vim/diagnostic.lua
@@ -854,10 +854,11 @@ local function set_list(loclist, opts)
-- numbers beyond the end of the buffer
local diagnostics = get_diagnostics(bufnr, opts --[[@as vim.diagnostic.GetOpts]], false)
local items = M.toqflist(diagnostics)
+ local qf_id = nil
if loclist then
vim.fn.setloclist(winnr, {}, 'u', { title = title, items = items })
else
- local qf_id = get_qf_id_for_title(title)
+ qf_id = get_qf_id_for_title(title)
-- If we already have a diagnostics quickfix, update it rather than creating a new one.
-- This avoids polluting the finite set of quickfix lists, and preserves the currently selected
@@ -868,16 +869,17 @@ local function set_list(loclist, opts)
id = qf_id,
})
end
+
if open then
- if loclist then
- api.nvim_command('lwindow')
- else
+ if qf_id then
-- First navigate to the diagnostics quickfix list.
- local nr = vim.fn.getqflist({ id = _qf_id, nr = 0 }).nr
+ local nr = vim.fn.getqflist({ id = qf_id, nr = 0 }).nr
api.nvim_command(nr .. 'chistory')
-- Now open the quickfix list.
api.nvim_command('botright cwindow')
+ else
+ api.nvim_command('lwindow')
end
end
end