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.
This commit is contained in:
Rafael Bodill 2016-12-04 18:22:34 +02:00 committed by Justin M. Keyes
parent 2380747ff2
commit f344e40699

View File

@ -8755,17 +8755,18 @@ makeopens (
if (put_line(fd, "wincmd t") == FAIL) if (put_line(fd, "wincmd t") == FAIL)
return FAIL; return FAIL;
/* // If more than one window, see if sizes can be restored.
* If more than one window, see if sizes can be restored. // First set 'winheight' and 'winwidth' to 1 to avoid the windows being
* First set 'winheight' and 'winwidth' to 1 to avoid the windows being // resized when moving between windows.
* resized when moving between windows. // Do this before restoring the view, so that the topline and the
* Do this before restoring the view, so that the topline and the // cursor can be set. This is done again below.
* cursor can be set. This is done again below. if (put_line(fd, "set winminheight=1 winminwidth=1 winheight=1 winwidth=1")
*/ == FAIL) {
if (put_line(fd, "set winheight=1 winwidth=1") == FAIL)
return 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; return FAIL;
}
/* /*
* Restore the view of the window (options, file, cursor, etc.). * Restore the view of the window (options, file, cursor, etc.).
@ -8829,11 +8830,18 @@ makeopens (
if (put_line(fd, "unlet! s:wipebuf") == FAIL) if (put_line(fd, "unlet! s:wipebuf") == FAIL)
return FAIL; return FAIL;
/* Re-apply 'winheight', 'winwidth' and 'shortmess'. */ // Re-apply options.
if (fprintf(fd, "set winheight=%" PRId64 " winwidth=%" PRId64 " shortmess=%s", if (fprintf(fd, "set winheight=%" PRId64 " winwidth=%" PRId64
(int64_t)p_wh, (int64_t)p_wiw, p_shm) < 0 " winminheight=%" PRId64 " winminwidth=%" PRId64
|| put_eol(fd) == FAIL) " 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; return FAIL;
}
/* /*
* Lastly, execute the x.vim file if it exists. * Lastly, execute the x.vim file if it exists.