mirror of
https://github.com/neovim/neovim
synced 2025-07-18 10:11:50 +00:00
fix(diagnostic): clamp line numbers in setqflist and setloclist
This commit is contained in:
@ -374,28 +374,6 @@ local function clear_scheduled_display(namespace, bufnr)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@private
|
|
||||||
local function set_list(loclist, opts)
|
|
||||||
opts = opts or {}
|
|
||||||
local open = vim.F.if_nil(opts.open, true)
|
|
||||||
local title = opts.title or "Diagnostics"
|
|
||||||
local winnr = opts.winnr or 0
|
|
||||||
local bufnr
|
|
||||||
if loclist then
|
|
||||||
bufnr = vim.api.nvim_win_get_buf(winnr)
|
|
||||||
end
|
|
||||||
local diagnostics = M.get(bufnr, opts)
|
|
||||||
local items = M.toqflist(diagnostics)
|
|
||||||
if loclist then
|
|
||||||
vim.fn.setloclist(winnr, {}, ' ', { title = title, items = items })
|
|
||||||
else
|
|
||||||
vim.fn.setqflist({}, ' ', { title = title, items = items })
|
|
||||||
end
|
|
||||||
if open then
|
|
||||||
vim.api.nvim_command(loclist and "lopen" or "copen")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
---@private
|
---@private
|
||||||
local function get_diagnostics(bufnr, opts, clamp)
|
local function get_diagnostics(bufnr, opts, clamp)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
@ -449,6 +427,28 @@ local function get_diagnostics(bufnr, opts, clamp)
|
|||||||
return diagnostics
|
return diagnostics
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@private
|
||||||
|
local function set_list(loclist, opts)
|
||||||
|
opts = opts or {}
|
||||||
|
local open = vim.F.if_nil(opts.open, true)
|
||||||
|
local title = opts.title or "Diagnostics"
|
||||||
|
local winnr = opts.winnr or 0
|
||||||
|
local bufnr
|
||||||
|
if loclist then
|
||||||
|
bufnr = vim.api.nvim_win_get_buf(winnr)
|
||||||
|
end
|
||||||
|
local diagnostics = get_diagnostics(bufnr, opts, true)
|
||||||
|
local items = M.toqflist(diagnostics)
|
||||||
|
if loclist then
|
||||||
|
vim.fn.setloclist(winnr, {}, ' ', { title = title, items = items })
|
||||||
|
else
|
||||||
|
vim.fn.setqflist({}, ' ', { title = title, items = items })
|
||||||
|
end
|
||||||
|
if open then
|
||||||
|
vim.api.nvim_command(loclist and "lopen" or "copen")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
---@private
|
---@private
|
||||||
local function next_diagnostic(position, search_forward, bufnr, opts, namespace)
|
local function next_diagnostic(position, search_forward, bufnr, opts, namespace)
|
||||||
position[1] = position[1] - 1
|
position[1] = position[1] - 1
|
||||||
|
Reference in New Issue
Block a user