Skip to content

Commit

Permalink
fix: prune tab-scoped sessions for closed tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc-stripe committed Sep 22, 2022
1 parent e45b8fe commit a0eaa81
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lua/resession/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,14 @@ M.save_all = function(opts)
if current_session then
save(current_session, vim.tbl_extend("keep", opts, session_configs[current_session]))
else
-- First prune tab-scoped sessions for closed tabs
local invalid_tabpages = vim.tbl_filter(function(tabpage)
return not vim.api.nvim_tabpage_is_valid(tabpage)
end, vim.tbl_keys(tab_sessions))
for _, tabpage in ipairs(invalid_tabpages) do
tab_sessions[tabpage] = nil
end
-- Save all tab-scoped sessions
for tabpage, name in pairs(tab_sessions) do
save(name, vim.tbl_extend("keep", opts, session_configs[name]), tabpage)
end
Expand Down

0 comments on commit a0eaa81

Please sign in to comment.