[vim/vim] 'mksession' does not take 'bdelete' into account (#1393)

29 views
Skip to first unread message

fmv1992

unread,
Jan 18, 2017, 9:41:50 AM1/18/17
to vim/vim, Subscribed

There are two examples on vim_use list:

  1. https://groups.google.com/forum/#!topic/vim_use/4Nun47Jsjvc
  2. https://groups.google.com/forum/#!topic/vim_use/qL4--7akXS4

What happens is that mksesion! does not honor bdelete!.

Full working example:

/tmp/abcde » touch a b buffer_to_be_deleted
/tmp/abcde » vim -p a b buffer_to_be_deleted
3 files to edit
--------------------- Inside Vim --------------------- 
bd buffer_to_be_deleted
mksession! /tmp/session.vim
buffers

:buffers
  1 %a   "a"                            line 1
  2  a   "b"                            line 0
--------------------- Outside Vim --------------------- 
/tmp/abcde »
/tmp/abcde » ls
a  b  buffer_to_be_deleted
/tmp/abcde » vim -S /tmp/session.vim
--------------------- Inside Vim --------------------- 
buffers

:buffers
  2 %a   "a"                            line 1
  3      "b"                            line 1
  4  a   "buffer_to_be_deleted"         line 0
--------------------- Outside Vim --------------------- 

I would not expect the line
4 a "buffer_to_be_deleted" line 0
to be there.

This happens with sessionoptions including 'buffers' and without.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub

Bram Moolenaar

unread,
Jan 20, 2017, 3:57:45 PM1/20/17
to vim/vim, Subscribed

This happens because buffer_to_be_deleted is in the argument list. When the session is loaded and the argument list is re-created the buffer is also added.
We could add the buffer in hidden state to avoid the problem.

Blake Watkins

unread,
Apr 1, 2017, 10:01:27 PM4/1/17
to vim/vim, Subscribed

You can clear the arglist (:argd *) before executing mksession. If you want to restore the arguments to the arglist, you could write a little script that saves the array of args (use 'argv()' in vimscript), perform the arglist clear, then set args to the saved array.

Reply all
Reply to author
Forward
0 new messages