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.
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!
Steps to reproduce
Session manager
I use olimorris/persisted.nvim as the session manager, and I call
ScopeSaveState
before save the session andScopeLoadState
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 uponmksession
, I dived into neovim's source codes.https://github.com/neovim/neovim/blob/c614969570ac13cfc1ff6642fcaf56ebce6d40be/src/nvim/ex_session.c#L650-L668
It seems that only listed buffers are saved.
https://github.com/neovim/neovim/blob/c614969570ac13cfc1ff6642fcaf56ebce6d40be/src/nvim/ex_session.c#L739-L761
Here it loads the files showed in the windows of a tabpage.
Since
scope.nvim
hides other tabs' buffers by settingnobuflisted
, 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!