From 006361fc6b98a989f85f0709493f9864bdb10dfa Mon Sep 17 00:00:00 2001 From: glepnir Date: Tue, 17 Jun 2025 21:31:14 +0800 Subject: fix(api): buffer updates in quickfix buffer #31105 Problem: Buffer events (specifically on_bytes callbacks) weren't triggered when the quickfix list was modified, preventing buffer change notifications. Solution: Add code to send both bytes and lines change notifications after quickfix buffer updates to properly trigger all attached callbacks. --- test/functional/lua/buffer_updates_spec.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'test/functional/lua/buffer_updates_spec.lua') diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua index b9c1e9f897..93829bc5d4 100644 --- a/test/functional/lua/buffer_updates_spec.lua +++ b/test/functional/lua/buffer_updates_spec.lua @@ -420,6 +420,35 @@ describe('lua buffer event callbacks: on_lines', function() feed('i') eq({ '\ta' }, exec_lua('return _G.res[#_G.res]')) end) + + it('quickfix buffer send change', function() + command('copen') + exec_lua(function() + vim.api.nvim_buf_attach(vim.api.nvim_get_current_buf(), false, { + on_lines = function(...) + vim.g.qf_on_lines = { ... } + end, + on_bytes = function(...) + vim.g.qf_on_bytes = { ... } + end, + }) + end) + command('caddexpr "foo"') + eq({ 'bytes', 2, 2, 0, 0, 0, 0, 0, 0, 0, 6, 6 }, api.nvim_get_var('qf_on_bytes')) + eq({ 'lines', 2, 3, 0, 1, 1, 1 }, api.nvim_get_var('qf_on_lines')) + + command('caddexpr "bar"') + eq({ 'bytes', 2, 3, 0, 6, 6, 0, 0, 0, 1, 6, 6 }, api.nvim_get_var('qf_on_bytes')) + eq({ 'lines', 2, 4, 1, 2, 4, 0 }, api.nvim_get_var('qf_on_lines')) + + command('caddexpr ["line1", "line2", "line3"]') + eq({ 'bytes', 2, 4, 1, 6, 13, 0, 0, 0, 3, 8, 26 }, api.nvim_get_var('qf_on_bytes')) + eq({ 'lines', 2, 5, 2, 5, 9, 0 }, api.nvim_get_var('qf_on_lines')) + + command('cexpr "replace"') + eq({ 'bytes', 2, 5, 0, 0, 0, 4, 0, 40, 0, 10, 10 }, api.nvim_get_var('qf_on_bytes')) + eq({ 'lines', 2, 6, 0, 5, 1, 42 }, api.nvim_get_var('qf_on_lines')) + end) end) describe('lua: nvim_buf_attach on_bytes', function() -- cgit