From dc7ad6a2da3d44d7e3ebb766dd1edd995427b13d Mon Sep 17 00:00:00 2001 From: phanium <91544758+phanen@users.noreply.github.com> Date: Tue, 7 Jul 2026 13:20:04 +0800 Subject: [PATCH] fix(autocmd): skip non-normal buftype for performance --- lua/opencode/ui/autocmds.lua | 2 +- tests/unit/hooks_spec.lua | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/opencode/ui/autocmds.lua b/lua/opencode/ui/autocmds.lua index 133ce972..bcc7ae35 100644 --- a/lua/opencode/ui/autocmds.lua +++ b/lua/opencode/ui/autocmds.lua @@ -43,7 +43,7 @@ function M.setup_autocmds(windows) group = group, pattern = '*', callback = function(args) - if args.file == '' then + if args.file == '' or vim.bo[args.buf].buftype ~= '' then return end require('opencode.ui.renderer.events').invalidate_reference_targets_for_file_change() diff --git a/tests/unit/hooks_spec.lua b/tests/unit/hooks_spec.lua index 88db2edf..caca1720 100644 --- a/tests/unit/hooks_spec.lua +++ b/tests/unit/hooks_spec.lua @@ -267,8 +267,10 @@ describe('reference target local file lifecycle autocmds', function() file_lifecycle_autocmd.event ) - file_lifecycle_autocmd.opts.callback({ file = '/repo/tests/unit/formatter_spec.lua' }) - file_lifecycle_autocmd.opts.callback({ file = '' }) + local file_buf = vim.api.nvim_create_buf(false, false) + vim.bo[file_buf].buftype = '' + file_lifecycle_autocmd.opts.callback({ file = '/repo/tests/unit/formatter_spec.lua', buf = file_buf }) + file_lifecycle_autocmd.opts.callback({ file = '', buf = file_buf }) assert.stub(invalidate_stub).was_called(1) end)