From 5b0d8f85fdb705b07143fc4019189a9dcfe3c108 Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Fri, 19 Nov 2021 11:49:44 -0700 Subject: fix(diagnostic): clamp line numbers in setqflist and setloclist --- runtime/lua/vim/diagnostic.lua | 44 +++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'runtime') diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index 2a26a36d10..ae0bbb7d05 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -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 {} @@ -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 -- cgit