tpope / vim-obsession

obsession.vim: continuously updated session files
http://www.vim.org/scripts/script.php?script_id=4472
1.76k stars 70 forks source link

Restore previous v:this_session value after writing tmp session file #78

Closed adizero closed 1 year ago

adizero commented 1 year ago

Fixes a problem with leftover tmp session files. Issue happens after changing/adding buffers/tabs and toggling Obsession (to pause/unpause session tracking). The folder looks like this after a couple of runs (see below, played only with Neovim 0.8). Issue is caused by the mksession call automatically changing the v:this_session variable after writing the tmp session file. Solution is to restore the v:this_session variable after the mksession call.

$ ll Session.vim*
Session.vim.1661.obsession~
Session.vim.1767.obsession~
Session.vim.23502.obsession~
Session.vim.24782.obsession~
Session.vim.24782.obsession~.24782.obsession~.24782.obsession~
Session.vim.24782.obsession~.24782.obsession~.24782.obsession~.24782.obsession~ Session.vim.28396.obsession~
Session.vim.29727.obsession~
Session.vim.31061.obsession~
Session.vim.3134.obsession~
Session.vim.3134.obsession~.3134.obsession~
Session.vim.32691.obsession~
Session.vim.378.obsession~
Session.vim.4539.obsession~

tpope commented 1 year ago

The value is already in g:this_obsession. Let's restore from that.