Skip to content

fix: skip virtual text for a list that changed after rendering - #78

Open
charliie-dev wants to merge 1 commit into
stevearc:masterfrom
charliie-dev:fix/stale-virt-text
Open

charliie-dev wants to merge 1 commit into
stevearc:masterfrom
charliie-dev:fix/stale-virt-text

Conversation

@charliie-dev

Copy link
Copy Markdown

Summary

set_virt_text runs from vim.schedule and only checks the line count before placing extmarks. If a one-item list is emptied before it runs, the empty line left in the quickfix buffer passes that check, and the extmark goes to a column the line doesn't have:

vim.fn.setqflist({ { filename = "README.md", lnum = 1, text = "x" } })
vim.cmd.copen()
vim.fn.setqflist({})
-- vim.schedule callback: .../quicker/display.lua:570: Invalid 'col': out of range
 quickfixtextfunc(info)
   render lines (ret) and their virtual text (locations)
   vim.schedule(set_virt_text)

 set_virt_text()
   if line count < end_idx: retry later
+  if the lines no longer match what was rendered: return
   clear namespaces
   place extmarks at each line's EM_QUAD column

When the lines no longer match, the buffer shows something else now, and whatever re-rendered it schedules its own set_virt_text.

Evidence

  • Before: the new test in display_spec.lua fails:

    Fail || display leaves a list alone that changed before its virtual text was added
    Passed in: 'vim.schedule callback: ./lua/quicker/display.lua:570: Invalid 'col': out of range'
    

    After: it passes, and ./run_tests.sh passes in full (fs 2, opts 2, whitespace 3, context 4, display 5, editor 13).

  • A script that loads only quicker.nvim, with a fresh quickfix buffer per case:

    case before after
    1 item, emptied right after :copen error no error
    1 item, closed and emptied right after :copen error no error
    1 item left open, 1 item emptied after it rendered, 2 items emptied, 1 item replaced no error no error, same visible extmarks as before
  • One earlier full run with this change failed display sets signs for diagnostics once. It passed in every run after that: four with this change and two without.

Merge Danger

Door: two-way

Blast Radius: small

It only returns early when the buffer lines differ from the lines this render produced. If they differ for another reason before the callback runs (for example the list is edited in the same tick), that render's virtual text is skipped until the next render.

The virtual text is added from a scheduled callback that only checked the line count. When a
one-item list was emptied before it ran, the leftover empty line passed that check and placing the
extmark failed with "Invalid 'col': out of range". Leave the buffer alone when its lines no longer
match what was rendered; a newer render schedules its own update.
@github-actions
github-actions Bot requested a review from stevearc November 20, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant