Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lua/quicker/display.lua
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,16 @@ function M.quickfixtextfunc(info)
return
end

-- The list can change between rendering and this call (for example emptied right after
-- :copen). Then the buffer no longer shows these lines, and a newer render schedules its own
-- call, so leave the buffer alone.
local lines = vim.api.nvim_buf_get_lines(qf_list.qfbufnr, start_idx - 1, -1, false)
for i = 1, #locations do
if lines[i] ~= ret[i] then
return
end
end

local ns = vim.api.nvim_create_namespace("quicker_locations")
vim.api.nvim_buf_clear_namespace(qf_list.qfbufnr, ns, start_idx - 1, -1)
local header_ns = vim.api.nvim_create_namespace("quicker_headers")
Expand All @@ -562,7 +572,6 @@ function M.quickfixtextfunc(info)
vim.api.nvim_buf_clear_namespace(qf_list.qfbufnr, filename_ns, start_idx - 1, -1)

local idmap = {}
local lines = vim.api.nvim_buf_get_lines(qf_list.qfbufnr, start_idx - 1, -1, false)
for i, loc in ipairs(locations) do
local end_col = lines[i]:find(EM_QUAD, 1, true) or col_width
local lnum = start_idx + i - 1
Expand Down
18 changes: 18 additions & 0 deletions tests/display_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,24 @@ a.describe("display", function()
test_util.assert_snapshot(0, "display_minimal_1")
end)

a.it("leaves a list alone that changed before its virtual text was added", function()
local bufnr = vim.fn.bufadd(test_util.make_tmp_file("changed.txt", 10))
vim.v.errmsg = ""
vim.fn.setqflist({
{
bufnr = bufnr,
text = "text",
lnum = 1,
valid = 1,
},
})
vim.cmd.copen()
-- Emptied before the scheduled virtual text runs
vim.fn.setqflist({})
sleep(50)
assert.equals("", vim.v.errmsg)
end)

a.it("sets signs for diagnostics", function()
local bufnr = vim.fn.bufadd(test_util.make_tmp_file("sign_test.txt", 10))
vim.fn.setqflist({
Expand Down
Loading