Skip to content

fix(dashboard): guard augroup deletion on buffer wipeout - #2917

Open
joshmedeski wants to merge 1 commit into
folke:mainfrom
joshmedeski:fix/dashboard-augroup-double-delete
Open

fix(dashboard): guard augroup deletion on buffer wipeout#2917
joshmedeski wants to merge 1 commit into
folke:mainfrom
joshmedeski:fix/dashboard-augroup-double-delete

Conversation

@joshmedeski

Copy link
Copy Markdown

Description

All dashboard instances share a single fixed augroup name ("snacks_dashboard"), so they resolve to the same augroup id. Each dashboard buffer, however, installs its own buffer-local BufWipeout/BufDelete autocmd that unconditionally calls nvim_del_augroup_by_id(self.augroup):

vim.api.nvim_create_autocmd({ "BufWipeout", "BufDelete" }, {
  buffer = self.buf,
  callback = function()
    self.fire("Closed")
    vim.api.nvim_del_augroup_by_id(self.augroup)
  end,
})

When more than one dashboard buffer is alive at once, the first buffer wiped deletes the shared augroup, and the second buffer wiped tries to delete the same (now-deleted) id, throwing:

dashboard.lua:262: Vim:E367: No such group: "--Deleted--"

This happens whenever the dashboard is opened more than once in a session (e.g. startup dashboard + reopening it, or configs that reopen the dashboard when the last buffer is closed) and the buffers are later wiped, such as when opening a file from a picker.

This PR wraps the deletion in pcall and clears self.augroup afterwards, matching the pattern already used elsewhere in the codebase (win.lua, image/placement.lua, explorer/init.lua).

Reproduction

local d1 = Snacks.dashboard.open()
local d2 = Snacks.dashboard.open() -- shares d1's augroup id
vim.api.nvim_buf_delete(d1.buf, { force = true }) -- deletes the shared augroup
vim.api.nvim_buf_delete(d2.buf, { force = true }) -- E367 before this fix

Before: the second delete throws E367. After: both deletes succeed.

Related Issue(s)

All dashboard instances share one fixed augroup name ("snacks_dashboard"),
so they resolve to the same augroup id. Each dashboard buffer installs its
own buffer-local BufWipeout/BufDelete autocmd that unconditionally calls
nvim_del_augroup_by_id(self.augroup). With more than one dashboard buffer
alive, the second one wiped deletes an already-deleted augroup and throws
E367: No such group: "--Deleted--".

pcall the deletion and clear self.augroup afterwards, matching the pattern
already used in win.lua, image/placement.lua and explorer/init.lua.
@github-actions github-actions Bot added dashboard size/s Small PR (<10 lines changed) labels Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dashboard size/s Small PR (<10 lines changed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Dashboard - Error when opening files from picker

1 participant