Re-posting here because I do think that this is a bug.
tl;dr: "Vim is started with -S" is not, but it should be treated like "Vim is started with a file name argument" as far as viminfo-% functionality is concerned.
Countless times I would find, in a Vim session that I had started via vim -S Session.vim, some :buffers that I did not expect to see, because I had never opened those buffers in the session I had created via :mksession.
Today I've finally decided to go to the bottom of the matter, and it turns out that the problem was that I included % in viminfo:
set viminfo='50,\"100,:1000,%,n~/.viminfo
" ^
" |
" +-- culprit
Probably I've just copied that from somewhere, in the past, and I can probably just remove it.
However, based on :help viminfo-%, I wonder if it is intentional at all that that % entry in viminfo affects Vim sessions opened with -S. Indeed here's the text from the linked documentation:
When included, save and restore the buffer list. If Vim is started with a file name argument, the buffer list is not restored. If Vim is started without a file name argument, the buffer list is restored from the viminfo file. Quickfix ('buftype'), unlisted ('buflisted'), unnamed and buffers on removable media (viminfo-r) are not saved. When followed by a number, the number specifies the maximum number of buffers that are stored. Without a number all buffers are stored.
The part I've emphasised, I believe, maps to the intuitive behavior that one would expect:
- if I have no clue what to open, please, restore the buffer list,
- but if I do know what to open, please, don't clutter my buffer list.
In line with that, I would expect that opening Vim with -S would count like "I do know what to open", i.e. like "Vim is started with a file name argument", as far as restoring the buffers is concerned.
Does anybody agree?
Originally posted by @Aster89 in #19816
Re-posting here because I do think that this is a bug.
tl;dr: "Vim is started with
-S" is not, but it should be treated like "Vim is started with a file name argument" as far asviminfo-%functionality is concerned.Countless times I would find, in a Vim session that I had started via
vim -S Session.vim, some:buffersthat I did not expect to see, because I had never opened those buffers in the session I had created via:mksession.Today I've finally decided to go to the bottom of the matter, and it turns out that the problem was that I included
%inviminfo:Probably I've just copied that from somewhere, in the past, and I can probably just remove it.
However, based on
:help viminfo-%, I wonder if it is intentional at all that that%entry inviminfoaffects Vim sessions opened with-S. Indeed here's the text from the linked documentation:The part I've emphasised, I believe, maps to the intuitive behavior that one would expect:
In line with that, I would expect that opening Vim with
-Swould count like "I do know what to open", i.e. like "Vim is started with a file name argument", as far as restoring the buffers is concerned.Does anybody agree?
Originally posted by @Aster89 in #19816