Skip to content

Commit

Permalink
fix: ensure task list state is cleared when buffer is unloaded (#398)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc committed Jan 24, 2025
1 parent 9e37348 commit d14f821
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lua/overseer/task_list/sidebar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,20 @@ end
---@private
function Sidebar:init()
vim.api.nvim_create_autocmd({ "BufHidden", "WinLeave" }, {
desc = "Close preview window when task list closes",
desc = "[Overseer] Close preview window when task list closes",
buffer = self.bufnr,
command = "pclose",
})
vim.api.nvim_create_autocmd("BufUnload", {
desc = "[Overseer] Clear state when task list buffer is unloaded",
buffer = self.bufnr,
callback = function()
ref = nil
return true
end,
})
vim.api.nvim_create_autocmd("CursorMoved", {
desc = "Update preview window when cursor moves",
desc = "[Overseer] Update preview window when cursor moves",
buffer = self.bufnr,
nested = true,
callback = function()
Expand All @@ -79,7 +87,7 @@ function Sidebar:init()
})
vim.api.nvim_create_autocmd("User", {
pattern = "OverseerListUpdate",
desc = "Update overseer task list when tasks change",
desc = "[Overseer] Update task list when tasks change",
callback = function()
self:render(task_list.list_tasks())
end,
Expand Down

0 comments on commit d14f821

Please sign in to comment.