aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/buffer_updates_spec.lua
diff options
context:
space:
mode:
authorglepnir <glephunter@gmail.com>2025-06-17 21:31:14 +0800
committerGitHub <noreply@github.com>2025-06-17 06:31:14 -0700
commit006361fc6b98a989f85f0709493f9864bdb10dfa (patch)
tree557ca1885185b07ad13feda589e0a3372ca7efab /test/functional/lua/buffer_updates_spec.lua
parent1bf9a07b3e77dbb6cefeefd9febdc3db8d52a313 (diff)
downloadrneovim-006361fc6b98a989f85f0709493f9864bdb10dfa.tar.gz
rneovim-006361fc6b98a989f85f0709493f9864bdb10dfa.tar.bz2
rneovim-006361fc6b98a989f85f0709493f9864bdb10dfa.zip
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.
Diffstat (limited to 'test/functional/lua/buffer_updates_spec.lua')
-rw-r--r--test/functional/lua/buffer_updates_spec.lua29
1 files changed, 29 insertions, 0 deletions
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<Tab>')
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()