From f344e40699e136a5185502ac661e64ec1b5f4184 Mon Sep 17 00:00:00 2001 From: Rafael Bodill Date: Sun, 4 Dec 2016 18:22:34 +0200 Subject: ex_docmd.c: Save/restore winminheight/winminwidth. #5717 Fix session load with winminheight/winminwidth >1. Problem: Vim temporarily sets winheight/winwidth to 1 while loading session. If user has his minimum window size set higher, this causes an error. Solution: Temporarily set winminheight/winminwidth, and restore the original values (in the right order) when finishing session read. The order of the compound 'set' command is important, if it is wrong there will be an error. --- src/nvim/ex_docmd.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 651fb6dddc..79a0b5849f 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -8755,17 +8755,18 @@ makeopens ( if (put_line(fd, "wincmd t") == FAIL) return FAIL; - /* - * If more than one window, see if sizes can be restored. - * First set 'winheight' and 'winwidth' to 1 to avoid the windows being - * resized when moving between windows. - * Do this before restoring the view, so that the topline and the - * cursor can be set. This is done again below. - */ - if (put_line(fd, "set winheight=1 winwidth=1") == FAIL) + // If more than one window, see if sizes can be restored. + // First set 'winheight' and 'winwidth' to 1 to avoid the windows being + // resized when moving between windows. + // Do this before restoring the view, so that the topline and the + // cursor can be set. This is done again below. + if (put_line(fd, "set winminheight=1 winminwidth=1 winheight=1 winwidth=1") + == FAIL) { return FAIL; - if (nr > 1 && ses_winsizes(fd, restore_size, tab_firstwin) == FAIL) + } + if (nr > 1 && ses_winsizes(fd, restore_size, tab_firstwin) == FAIL) { return FAIL; + } /* * Restore the view of the window (options, file, cursor, etc.). @@ -8829,11 +8830,18 @@ makeopens ( if (put_line(fd, "unlet! s:wipebuf") == FAIL) return FAIL; - /* Re-apply 'winheight', 'winwidth' and 'shortmess'. */ - if (fprintf(fd, "set winheight=%" PRId64 " winwidth=%" PRId64 " shortmess=%s", - (int64_t)p_wh, (int64_t)p_wiw, p_shm) < 0 - || put_eol(fd) == FAIL) + // Re-apply options. + if (fprintf(fd, "set winheight=%" PRId64 " winwidth=%" PRId64 + " winminheight=%" PRId64 " winminwidth=%" PRId64 + " shortmess=%s", + (int64_t)p_wh, + (int64_t)p_wiw, + (int64_t)p_wmh, + (int64_t)p_wmw, + p_shm) < 0 + || put_eol(fd) == FAIL) { return FAIL; + } /* * Lastly, execute the x.vim file if it exists. -- cgit