Mercurial > vim
comparison src/ex_docmd.c @ 15643:dc2bfda59f95 v8.1.0829
patch 8.1.0829: when 'hidden' is set session creates extra buffers
commit https://github.com/vim/vim/commit/d39e275b57493f9e25e1b62f84810571eee30cf4
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 26 20:07:38 2019 +0100
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 26 Jan 2019 20:15:11 +0100 |
parents | 6f1c7e9a6393 |
children | 61448894376e |
comparison
equal
deleted
inserted
replaced
15642:35cfcded325d | 15643:dc2bfda59f95 |
---|---|
11278 * Now save the current files, current buffer first. | 11278 * Now save the current files, current buffer first. |
11279 */ | 11279 */ |
11280 if (put_line(fd, "set shortmess=aoO") == FAIL) | 11280 if (put_line(fd, "set shortmess=aoO") == FAIL) |
11281 return FAIL; | 11281 return FAIL; |
11282 | 11282 |
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 | |
11303 /* the global argument list */ | 11283 /* the global argument list */ |
11304 if (ses_arglist(fd, "argglobal", &global_alist.al_ga, | 11284 if (ses_arglist(fd, "argglobal", &global_alist.al_ga, |
11305 !(ssop_flags & SSOP_CURDIR), &ssop_flags) == FAIL) | 11285 !(ssop_flags & SSOP_CURDIR), &ssop_flags) == FAIL) |
11306 return FAIL; | 11286 return FAIL; |
11307 | 11287 |
11512 || put_eol(fd) == FAIL) | 11492 || put_eol(fd) == FAIL) |
11513 return FAIL; | 11493 return FAIL; |
11514 } | 11494 } |
11515 if (restore_stal && put_line(fd, "set stal=1") == FAIL) | 11495 if (restore_stal && put_line(fd, "set stal=1") == FAIL) |
11516 return FAIL; | 11496 return FAIL; |
11497 | |
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 } | |
11517 | 11520 |
11518 /* | 11521 /* |
11519 * Wipe out an empty unnamed buffer we started in. | 11522 * Wipe out an empty unnamed buffer we started in. |
11520 */ | 11523 */ |
11521 if (put_line(fd, "if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0") | 11524 if (put_line(fd, "if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0") |