@@ -11280,26 +11280,6 @@ makeopens(
1128011280 if (put_line (fd , "set shortmess=aoO" ) == FAIL )
1128111281 return FAIL ;
1128211282
11283- /* Now put the other buffers into the buffer list */
11284- FOR_ALL_BUFFERS (buf )
11285- {
11286- if (!(only_save_windows && buf -> b_nwindows == 0 )
11287- && !(buf -> b_help && !(ssop_flags & SSOP_HELP ))
11288- #ifdef FEAT_TERMINAL
11289- /* skip terminal buffers: finished ones are not useful, others
11290- * will be resurrected and result in a new buffer */
11291- && !bt_terminal (buf )
11292- #endif
11293- && buf -> b_fname != NULL
11294- && buf -> b_p_bl )
11295- {
11296- if (fprintf (fd , "badd +%ld " , buf -> b_wininfo == NULL ? 1L
11297- : buf -> b_wininfo -> wi_fpos .lnum ) < 0
11298- || ses_fname (fd , buf , & ssop_flags , TRUE) == FAIL )
11299- return FAIL ;
11300- }
11301- }
11302-
1130311283 /* the global argument list */
1130411284 if (ses_arglist (fd , "argglobal" , & global_alist .al_ga ,
1130511285 !(ssop_flags & SSOP_CURDIR ), & ssop_flags ) == FAIL )
@@ -11515,6 +11495,29 @@ makeopens(
1151511495 if (restore_stal && put_line (fd , "set stal=1" ) == FAIL )
1151611496 return FAIL ;
1151711497
11498+ // Now put the remaining buffers into the buffer list.
11499+ // This is near the end, so that when 'hidden' is set we don't create extra
11500+ // buffers. If the buffer was already created with another command the
11501+ // ":badd" will have no effect.
11502+ FOR_ALL_BUFFERS (buf )
11503+ {
11504+ if (!(only_save_windows && buf -> b_nwindows == 0 )
11505+ && !(buf -> b_help && !(ssop_flags & SSOP_HELP ))
11506+ #ifdef FEAT_TERMINAL
11507+ // Skip terminal buffers: finished ones are not useful, others
11508+ // will be resurrected and result in a new buffer.
11509+ && !bt_terminal (buf )
11510+ #endif
11511+ && buf -> b_fname != NULL
11512+ && buf -> b_p_bl )
11513+ {
11514+ if (fprintf (fd , "badd +%ld " , buf -> b_wininfo == NULL ? 1L
11515+ : buf -> b_wininfo -> wi_fpos .lnum ) < 0
11516+ || ses_fname (fd , buf , & ssop_flags , TRUE) == FAIL )
11517+ return FAIL ;
11518+ }
11519+ }
11520+
1151811521 /*
1151911522 * Wipe out an empty unnamed buffer we started in.
1152011523 */
0 commit comments