Skip to content

Commit

Permalink
fix(diagnostic): clamp line numbers in setqflist and setloclist
Browse files Browse the repository at this point in the history
  • Loading branch information
gpanders committed Nov 19, 2021
1 parent 34bb5fa commit 5b0d8f8
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions runtime/lua/vim/diagnostic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -374,28 +374,6 @@ local function clear_scheduled_display(namespace, bufnr)
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
local function get_diagnostics(bufnr, opts, clamp)
opts = opts or {}
Expand Down Expand Up @@ -449,6 +427,28 @@ local function get_diagnostics(bufnr, opts, clamp)
return diagnostics
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
local function next_diagnostic(position, search_forward, bufnr, opts, namespace)
position[1] = position[1] - 1
Expand Down

0 comments on commit 5b0d8f8

Please sign in to comment.