aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/diagnostic.lua
diff options
context:
space:
mode:
authorGregory Anders <greg@gpanders.com>2021-11-19 11:49:44 -0700
committerGregory Anders <greg@gpanders.com>2021-11-19 11:49:44 -0700
commit5b0d8f85fdb705b07143fc4019189a9dcfe3c108 (patch)
treefc9f4f2d952dd91b7f363e8167720c030cfb1585 /runtime/lua/vim/diagnostic.lua
parent34bb5fa5a942708c32b0e68eca02261d04e51ca6 (diff)
downloadrneovim-5b0d8f85fdb705b07143fc4019189a9dcfe3c108.tar.gz
rneovim-5b0d8f85fdb705b07143fc4019189a9dcfe3c108.tar.bz2
rneovim-5b0d8f85fdb705b07143fc4019189a9dcfe3c108.zip
fix(diagnostic): clamp line numbers in setqflist and setloclist
Diffstat (limited to 'runtime/lua/vim/diagnostic.lua')
-rw-r--r--runtime/lua/vim/diagnostic.lua44
1 files changed, 22 insertions, 22 deletions
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
@@ -375,28 +375,6 @@ local function clear_scheduled_display(namespace, bufnr)
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 {}
@@ -450,6 +428,28 @@ local function get_diagnostics(bufnr, opts, clamp)
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
bufnr = get_bufnr(bufnr)