aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRafael Bodill <justrafi@gmail.com>2016-12-04 18:22:34 +0200
committerJustin M. Keyes <justinkz@gmail.com>2016-12-10 04:05:07 +0100
commitf344e40699e136a5185502ac661e64ec1b5f4184 (patch)
tree723077637c0ae2d9019152a52012ed4e820f18c9 /src
parent2380747ff2ea7bb801b7e92cbe30832fa75cb622 (diff)
downloadrneovim-f344e40699e136a5185502ac661e64ec1b5f4184.tar.gz
rneovim-f344e40699e136a5185502ac661e64ec1b5f4184.tar.bz2
rneovim-f344e40699e136a5185502ac661e64ec1b5f4184.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_docmd.c34
1 files changed, 21 insertions, 13 deletions
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.