forked from aniani/vim
patch 8.1.0829: when 'hidden' is set session creates extra buffers
Problem: When 'hidden' is set session creates extra buffers. Solution: Move :badd commands to the end. (Jason Franklin)
This commit is contained in:
@@ -11280,26 +11280,6 @@ makeopens(
|
|||||||
if (put_line(fd, "set shortmess=aoO") == FAIL)
|
if (put_line(fd, "set shortmess=aoO") == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
/* Now put the other buffers into the buffer list */
|
|
||||||
FOR_ALL_BUFFERS(buf)
|
|
||||||
{
|
|
||||||
if (!(only_save_windows && buf->b_nwindows == 0)
|
|
||||||
&& !(buf->b_help && !(ssop_flags & SSOP_HELP))
|
|
||||||
#ifdef FEAT_TERMINAL
|
|
||||||
/* skip terminal buffers: finished ones are not useful, others
|
|
||||||
* will be resurrected and result in a new buffer */
|
|
||||||
&& !bt_terminal(buf)
|
|
||||||
#endif
|
|
||||||
&& buf->b_fname != NULL
|
|
||||||
&& buf->b_p_bl)
|
|
||||||
{
|
|
||||||
if (fprintf(fd, "badd +%ld ", buf->b_wininfo == NULL ? 1L
|
|
||||||
: buf->b_wininfo->wi_fpos.lnum) < 0
|
|
||||||
|| ses_fname(fd, buf, &ssop_flags, TRUE) == FAIL)
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* the global argument list */
|
/* the global argument list */
|
||||||
if (ses_arglist(fd, "argglobal", &global_alist.al_ga,
|
if (ses_arglist(fd, "argglobal", &global_alist.al_ga,
|
||||||
!(ssop_flags & SSOP_CURDIR), &ssop_flags) == FAIL)
|
!(ssop_flags & SSOP_CURDIR), &ssop_flags) == FAIL)
|
||||||
@@ -11515,6 +11495,29 @@ makeopens(
|
|||||||
if (restore_stal && put_line(fd, "set stal=1") == FAIL)
|
if (restore_stal && put_line(fd, "set stal=1") == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
|
// Now put the remaining buffers into the buffer list.
|
||||||
|
// This is near the end, so that when 'hidden' is set we don't create extra
|
||||||
|
// buffers. If the buffer was already created with another command the
|
||||||
|
// ":badd" will have no effect.
|
||||||
|
FOR_ALL_BUFFERS(buf)
|
||||||
|
{
|
||||||
|
if (!(only_save_windows && buf->b_nwindows == 0)
|
||||||
|
&& !(buf->b_help && !(ssop_flags & SSOP_HELP))
|
||||||
|
#ifdef FEAT_TERMINAL
|
||||||
|
// Skip terminal buffers: finished ones are not useful, others
|
||||||
|
// will be resurrected and result in a new buffer.
|
||||||
|
&& !bt_terminal(buf)
|
||||||
|
#endif
|
||||||
|
&& buf->b_fname != NULL
|
||||||
|
&& buf->b_p_bl)
|
||||||
|
{
|
||||||
|
if (fprintf(fd, "badd +%ld ", buf->b_wininfo == NULL ? 1L
|
||||||
|
: buf->b_wininfo->wi_fpos.lnum) < 0
|
||||||
|
|| ses_fname(fd, buf, &ssop_flags, TRUE) == FAIL)
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Wipe out an empty unnamed buffer we started in.
|
* Wipe out an empty unnamed buffer we started in.
|
||||||
*/
|
*/
|
||||||
|
@@ -225,6 +225,29 @@ func Test_mksession_blank_tabs()
|
|||||||
call delete('Xtest_mks.out')
|
call delete('Xtest_mks.out')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_mksession_buffer_count()
|
||||||
|
set hidden
|
||||||
|
|
||||||
|
" Edit exactly three files in the current session.
|
||||||
|
%bwipe!
|
||||||
|
e Xfoo | tabe Xbar | tabe Xbaz
|
||||||
|
tabdo write
|
||||||
|
mksession! Xtest_mks.out
|
||||||
|
|
||||||
|
" Verify that loading the session does not create additional buffers.
|
||||||
|
%bwipe!
|
||||||
|
source Xtest_mks.out
|
||||||
|
call assert_equal(3, len(getbufinfo()))
|
||||||
|
|
||||||
|
" Clean up.
|
||||||
|
call delete('Xfoo')
|
||||||
|
call delete('Xbar')
|
||||||
|
call delete('Xbaz')
|
||||||
|
call delete('Xtest_mks.out')
|
||||||
|
%bwipe!
|
||||||
|
set hidden&
|
||||||
|
endfunc
|
||||||
|
|
||||||
if has('extra_search')
|
if has('extra_search')
|
||||||
|
|
||||||
func Test_mksession_hlsearch()
|
func Test_mksession_hlsearch()
|
||||||
|
@@ -783,6 +783,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
829,
|
||||||
/**/
|
/**/
|
||||||
828,
|
828,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user