vim-patch:8.1.0790: code for creating tabpages in session is too complex

Problem:    Code for creating tabpages in session is too complex.
Solution:   Simplify the code. (Jason Franklin)
57a6bf0567
This commit is contained in:
Jan Edmund Lazo
2020-12-17 23:29:27 -05:00
parent c60f7c2064
commit f0a8ccff8f

View File

@@ -613,21 +613,13 @@ static int makeopens(FILE *fd, char_u *dirnow)
if ((ssop_flags & SSOP_TABPAGES)) { if ((ssop_flags & SSOP_TABPAGES)) {
// Similar to ses_win_rec() below, populate the tab pages first so // Similar to ses_win_rec() below, populate the tab pages first so
// later local options won't be copied to the new tabs. // later local options won't be copied to the new tabs.
for (tabnr = 1;; tabnr++) { FOR_ALL_TABS(tp) {
const tabpage_T *const tp = find_tabpage(tabnr); if (tp->tp_next != NULL && put_line(fd, "tabnew") == FAIL) {
if (tp == NULL) { // done all tab pages
break;
}
if (tabnr > 1 && put_line(fd, "tabnew") == FAIL) {
return FAIL; return FAIL;
} }
} }
const int num_tabs = tabnr - 1; if (first_tabpage->tp_next != NULL && put_line(fd, "tabrewind") == FAIL) {
if (num_tabs > 1
&& (fprintf(fd, "tabnext -%d", num_tabs - 1) < 0
|| put_eol(fd) == FAIL)) {
return FAIL; return FAIL;
} }
} }