bug: if the active buffer is filtered out, restoration opens up a default buffer #66
Open
3 tasks done
Labels
bug
Something isn't working
Did you check the docs and existing issues?
Neovim version (nvim -v)
NVIM v0.10.0
Operating system/version
14.5 (23F79)
Describe the bug
If
buf_filter
is used to exclude a buffer, and that buffer happens to be the active buffer in a window during a session save, then when that session is restored you'll be in a default empty buffer (rather than the next-oldest buffer that was saved into the session, which is what I'd expect).I have resession configured to automatically save and restore sessions per directory exactly as specified in the README, except that I'm also using a custom
buf_filter
to exclude certain types of buffers I don't want restored. For the sake of this report I have reproduced the issue using the following simplifiedbuf_filter
when setting up resession:Then I create
a.txt
andb.txt
in a directory, open both,:set ft=test
whileb.txt
is the active buffer (in a single window - no splits or anything) and exit Neovim. When I launch it again,a.txt
is restored (I can see it in:ls
) but Neovim launches into an empty buffer. I think this might be because no"wins"
element gets created in the session JSON in this case (get_win_info
is returning false because the buffer in the window isn't passing the filter).Is this the intended behavior? It does make a certain kind of sense from a standpoint of having resession not do anything "automagically" for you, which I appreciate, but I feel like it would also make sense to have resession fall back to loading one of the buffers that did get saved (probably based on
load_order
) in this case, and only ending up in the default empty buffer if there was no other option.This can be worked around with existing functionality - a
post_load
hook that detects the empty buffer and then doesbp
or something similar, although I don't know if that's the most elegant option.What is the severity of this bug?
minor (annoyance)
Steps To Reproduce
Use the minimal script below to reproduce (
nvim -u repro.lua
).:e a.txt
and:e b.txt
and optionally type some stuff in them.:qa
: andnvim -u bug.lua
again to restore the session. Note which buffer you are in (the last one you had open, as expected).:set ft=test
and:qa
Then
nvim -u bug.lua
again - this time you'll be in a[No File]
buffer, even though:ls
shows that your other buffer was loaded.Expected Behavior
I'd expect to load into the last buffer that was open, unless there are no buffers in the saved session, at which point I'd expect to be loaded into the empty default buffer.
Directory structure
./a.txt
./b.txt
Repro
Did you check the bug with a clean config?
nvim -u repro.lua
using the repro.lua file above.The text was updated successfully, but these errors were encountered: