From 0341c687a35381b360f5f2a89f444490b09c5cda Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Wed, 24 Nov 2021 19:57:27 -0700 Subject: [PATCH] fix(diagnostic): don't clamp line numbers in setqflist Reverts 5b0d8f85fdb705b07143fc4019189a9dcfe3c108. Diagnostic producers can send diagnostics for buffers that are not loaded, for which we cannot retrieve the line count to clamp line numbers. This means that some diagnostics in the quickfix list could be line-clamped and others not. The quickfix list can already handle line numbers past the end of the buffer (i.e. it *already* clamps line numbers) so just use the "raw" diagnostic positions sent from the producer. --- runtime/lua/vim/diagnostic.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index 85b430375e..16ff14a2e7 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -441,7 +441,9 @@ local function set_list(loclist, opts) if loclist then bufnr = vim.api.nvim_win_get_buf(winnr) end - local diagnostics = get_diagnostics(bufnr, opts, true) + -- Don't clamp line numbers since the quickfix list can already handle line + -- numbers beyond the end of the buffer + local diagnostics = get_diagnostics(bufnr, opts, false) local items = M.toqflist(diagnostics) if loclist then vim.fn.setloclist(winnr, {}, ' ', { title = title, items = items })