aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_docmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r--src/nvim/ex_docmd.c58
1 files changed, 33 insertions, 25 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index f5c16d883a..cda80dad39 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -9191,33 +9191,38 @@ static int ses_winsizes(FILE *fd, int restore_size, win_T *tab_firstwin)
if (restore_size && (ssop_flags & SSOP_WINSIZE)) {
for (wp = tab_firstwin; wp != NULL; wp = wp->w_next) {
- if (!ses_do_win(wp))
+ if (!ses_do_win(wp)) {
continue;
- ++n;
+ }
+ n++;
- /* restore height when not full height */
+ // restore height when not full height
if (wp->w_height + wp->w_status_height < topframe->fr_height
&& (fprintf(fd,
"exe '%dresize ' . ((&lines * %" PRId64
" + %" PRId64 ") / %" PRId64 ")",
- n, (int64_t)wp->w_grid.Rows,
- (int64_t)(Rows / 2), (int64_t)Rows) < 0
- || put_eol(fd) == FAIL))
+ n, (int64_t)wp->w_height,
+ (int64_t)Rows / 2, (int64_t)Rows) < 0
+ || put_eol(fd) == FAIL)) {
return FAIL;
+ }
- /* restore width when not full width */
+ // restore width when not full width
if (wp->w_width < Columns
- && (fprintf(fd, "exe 'vert %dresize ' . ((&columns * %" PRId64
- " + %" PRId64 ") / %" PRId64 ")",
- n, (int64_t)wp->w_width, (int64_t)(Columns / 2),
+ && (fprintf(fd,
+ "exe 'vert %dresize ' . ((&columns * %" PRId64
+ " + %" PRId64 ") / %" PRId64 ")",
+ n, (int64_t)wp->w_width, (int64_t)Columns / 2,
(int64_t)Columns) < 0
- || put_eol(fd) == FAIL))
+ || put_eol(fd) == FAIL)) {
return FAIL;
+ }
}
} else {
- /* Just equalise window sizes */
- if (put_line(fd, "wincmd =") == FAIL)
+ // Just equalise window sizes
+ if (put_line(fd, "wincmd =") == FAIL) {
return FAIL;
+ }
}
return OK;
}
@@ -9365,10 +9370,11 @@ put_view(
* arguments may have been deleted, check if the index is valid. */
if (wp->w_arg_idx != current_arg_idx && wp->w_arg_idx < WARGCOUNT(wp)
&& flagp == &ssop_flags) {
- if (fprintf(fd, "%" PRId64 "argu", (int64_t)(wp->w_arg_idx + 1)) < 0
- || put_eol(fd) == FAIL)
+ if (fprintf(fd, "%" PRId64 "argu", (int64_t)wp->w_arg_idx + 1) < 0
+ || put_eol(fd) == FAIL) {
return FAIL;
- did_next = TRUE;
+ }
+ did_next = true;
}
/* Edit the file. Skip this when ":next" already did it. */
@@ -9385,9 +9391,9 @@ put_view(
// Note, if a buffer for that file already exists, use :badd to
// edit that buffer, to not lose folding information (:edit resets
// folds in other buffers)
- if (fputs("if bufexists('", fd) < 0
+ if (fputs("if bufexists(\"", fd) < 0
|| ses_fname(fd, wp->w_buffer, flagp, false) == FAIL
- || fputs("') | buffer ", fd) < 0
+ || fputs("\") | buffer ", fd) < 0
|| ses_fname(fd, wp->w_buffer, flagp, false) == FAIL
|| fputs(" | else | edit ", fd) < 0
|| ses_fname(fd, wp->w_buffer, flagp, false) == FAIL
@@ -9463,8 +9469,8 @@ put_view(
" * winheight(0) + %" PRId64 ") / %" PRId64 ")",
(int64_t)wp->w_cursor.lnum,
(int64_t)(wp->w_cursor.lnum - wp->w_topline),
- (int64_t)(wp->w_grid.Rows / 2),
- (int64_t)wp->w_grid.Rows) < 0
+ (int64_t)(wp->w_height_inner / 2),
+ (int64_t)wp->w_height_inner) < 0
|| put_eol(fd) == FAIL
|| put_line(fd, "if s:l < 1 | let s:l = 1 | endif") == FAIL
|| put_line(fd, "exe s:l") == FAIL
@@ -9478,21 +9484,23 @@ put_view(
return FAIL;
} else {
if (!wp->w_p_wrap && wp->w_leftcol > 0 && wp->w_width > 0) {
- if (fprintf(fd, "let s:c = %" PRId64 " - ((%" PRId64
- " * winwidth(0) + %" PRId64 ") / %" PRId64 ")",
- (int64_t)(wp->w_virtcol + 1),
+ if (fprintf(fd,
+ "let s:c = %" PRId64 " - ((%" PRId64
+ " * winwidth(0) + %" PRId64 ") / %" PRId64 ")",
+ (int64_t)wp->w_virtcol + 1,
(int64_t)(wp->w_virtcol - wp->w_leftcol),
(int64_t)(wp->w_width / 2),
(int64_t)wp->w_width) < 0
|| put_eol(fd) == FAIL
|| put_line(fd, "if s:c > 0") == FAIL
|| fprintf(fd, " exe 'normal! ' . s:c . '|zs' . %" PRId64 " . '|'",
- (int64_t)(wp->w_virtcol + 1)) < 0
+ (int64_t)wp->w_virtcol + 1) < 0
|| put_eol(fd) == FAIL
|| put_line(fd, "else") == FAIL
|| put_view_curpos(fd, wp, " ") == FAIL
- || put_line(fd, "endif") == FAIL)
+ || put_line(fd, "endif") == FAIL) {
return FAIL;
+ }
} else if (put_view_curpos(fd, wp, "") == FAIL) {
return FAIL;
}