Skip to content

Commit f929110

Browse files
authored
fix(diff): clear auto commands for inline integration (#2709)
1 parent a5e3c2d commit f929110

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lua/codecompanion/diff/ui.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ local api = vim.api
99
local M = {}
1010

1111
---@class CodeCompanion.DiffUI
12+
---@field aug_group? number The autocommand group ID for the banner
1213
---@field banner? string The banner of keymaps to display above each hunk
1314
---@field banner_ns? number The namespace ID for the banner extmark
1415
---@field bufnr number The buffer number of the diff window
@@ -264,7 +265,10 @@ end
264265
---Clear diff extmarks from buffer
265266
---@return nil
266267
function DiffUI:clear()
267-
-- Clear the banner namespace
268+
if self.aug_group then
269+
pcall(api.nvim_del_augroup_by_id, self.aug_group)
270+
end
271+
268272
if self.banner_ns then
269273
pcall(api.nvim_buf_clear_namespace, self.bufnr, self.banner_ns, 0, -1)
270274
end
@@ -445,6 +449,7 @@ end
445449
local function setup_banner(diff_ui, opts)
446450
local bufnr = diff_ui.bufnr
447451
local group = api.nvim_create_augroup("codecompanion.diff_window_" .. bufnr, { clear = true })
452+
diff_ui.aug_group = group
448453

449454
local function show_banner(args)
450455
args = args or {}

0 commit comments

Comments
 (0)