Inactive buffers in inactive tabpages won't be restored after restoring the session
Closed this issue · 3 comments
Steps to reproduce
- Open neovim. Let's call current tab as Tab A
- Open file 1, 2. Now the main window shows file 2.
- Create a new tab, called Tab B.
- Enter Tab B, and open file 3, 4.
- Leave neovim, the session is saved.
- Enter neovim again, now the session should be restored. We should be in Tab B, and file 3 and 4 are fine.
Go to Tab A, only file 2 is loaded.
Session manager
I use olimorris/persisted.nvim as the session manager, and I call ScopeSaveState
before save the session and ScopeLoadState
after load the session.
Some discoveries
I found that vim.g.ScopeState
was correctly set after restoring the session. So I went to have a check on the session file. Then I found that the session file actually didn't load the file 1 at all. Since the session manager is built upon mksession
, I dived into neovim's source codes.
It seems that only listed buffers are saved.
Here it loads the files showed in the windows of a tabpage.
Since scope.nvim
hides other tabs' buffers by setting nobuflisted
, the inactive tabs' buffers aren't listed and they won't be saved, except for ones showed because neovim will save them even they aren't listed.
If I misunderstood anything, please correct me. Thanks!
Thanks for the detailed report.
@v1nh1shungry, I have a PR to fix this.
Thanks @aidigital! I can confirm the issue is resolved in my machine with the PR.