Patch 8.2.2776
Problem: :mksession uses current value of 'splitbelow' and 'splitright'
even though "options" is not in 'sessionoptions'. (Maxim Kim)
Solution: Save and restore the values, instead of setting to the current
value. (closes #8119)
Files: src/session.c, src/testdir/test_mksession.vim
*** ../vim-8.2.2775/src/session.c 2021-04-16 19:58:15.911249735 +0200
--- src/session.c 2021-04-17 18:23:35.007463274 +0200
***************
*** 779,793 ****
if (need_tabnext && put_line(fd, "tabnext") == FAIL)
goto fail;
! // Save current window layout.
! if (put_line(fd, "set splitbelow splitright") == FAIL)
! goto fail;
! if (ses_win_rec(fd, tab_topframe) == FAIL)
! goto fail;
! if (!p_sb && put_line(fd, "set nosplitbelow") == FAIL)
! goto fail;
! if (!p_spr && put_line(fd, "set nosplitright") == FAIL)
! goto fail;
// Check if window sizes can be restored (no windows omitted).
// Remember the window number of the current window after restoring.
--- 779,800 ----
if (need_tabnext && put_line(fd, "tabnext") == FAIL)
goto fail;
! if (tab_topframe->fr_layout != FR_LEAF)
! {
! // Save current window layout.
! if (put_line(fd, "let s:save_splitbelow = &splitbelow") == FAIL
! || put_line(fd, "let s:save_splitright = &splitright")
! == FAIL)
! goto fail;
! if (put_line(fd, "set splitbelow splitright") == FAIL)
! goto fail;
! if (ses_win_rec(fd, tab_topframe) == FAIL)
! goto fail;
! if (put_line(fd, "let &splitbelow = s:save_splitbelow") == FAIL
! || put_line(fd, "let &splitright = s:save_splitright")
! == FAIL)
! goto fail;
! }
// Check if window sizes can be restored (no windows omitted).
// Remember the window number of the current window after restoring.
***************
*** 802,823 ****
cnr = nr;
}
! // Go to the first window.
! if (put_line(fd, "wincmd t") == FAIL)
! goto 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.
! // winminheight and winminwidth need to be set to avoid an error if the
! // user has set winheight or winwidth.
! if (put_line(fd, "set winminheight=0") == FAIL
! || put_line(fd, "set winheight=1") == FAIL
! || put_line(fd, "set winminwidth=0") == FAIL
! || put_line(fd, "set winwidth=1") == FAIL)
! goto fail;
if (nr > 1 && ses_winsizes(fd, restore_size, tab_firstwin) == FAIL)
goto fail;
--- 809,837 ----
cnr = nr;
}
! if (tab_firstwin->w_next != NULL)
! {
! // Go to the first window.
! if (put_line(fd, "wincmd t") == FAIL)
! goto 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.
! // winminheight and winminwidth need to be set to avoid an error if
! // the user has set winheight or winwidth.
! if (put_line(fd, "let s:save_winminheight = &winminheight") == FAIL
! || put_line(fd, "let s:save_winminwidth = &winminwidth")
! == FAIL)
! goto fail;
! if (put_line(fd, "set winminheight=0") == FAIL
! || put_line(fd, "set winheight=1") == FAIL
! || put_line(fd, "set winminwidth=0") == FAIL
! || put_line(fd, "set winwidth=1") == FAIL)
! goto fail;
! }
if (nr > 1 && ses_winsizes(fd, restore_size, tab_firstwin) == FAIL)
goto fail;
***************
*** 919,928 ****
if (fprintf(fd, "set winheight=%ld winwidth=%ld shortmess=%s",
p_wh, p_wiw, p_shm) < 0 || put_eol(fd) == FAIL)
goto fail;
! // Re-apply 'winminheight' and 'winminwidth'.
! if (fprintf(fd, "set winminheight=%ld winminwidth=%ld",
! p_wmh, p_wmw) < 0 || put_eol(fd) == FAIL)
! goto fail;
// Lastly, execute the x.vim file if it exists.
if (put_line(fd, "let s:sx = expand(\"<sfile>:p:r\").\"x.vim\"") == FAIL
--- 933,945 ----
if (fprintf(fd, "set winheight=%ld winwidth=%ld shortmess=%s",
p_wh, p_wiw, p_shm) < 0 || put_eol(fd) == FAIL)
goto fail;
! if (tab_firstwin->w_next != NULL)
! {
! // Restore 'winminheight' and 'winminwidth'.
! if (put_line(fd, "let &winminheight = s:save_winminheight") == FAIL
! || put_line(fd, "let &winminwidth = s:save_winminwidth") == FAIL)
! goto fail;
! }
// Lastly, execute the x.vim file if it exists.
if (put_line(fd, "let s:sx = expand(\"<sfile>:p:r\").\"x.vim\"") == FAIL
*** ../vim-8.2.2775/src/testdir/test_mksession.vim 2021-04-16
19:58:15.915249728 +0200
--- src/testdir/test_mksession.vim 2021-04-17 18:37:59.168910832 +0200
***************
*** 911,916 ****
--- 911,934 ----
set sessionoptions&
endfunc
+ " Test for mksession without options restores winminheight
+ func Test_mksession_winminheight()
+ set sessionoptions-=options
+ split
+ mksession! Xtest_mks.out
+ let found_restore = 0
+ let lines = readfile('Xtest_mks.out')
+ for line in lines
+ if line =~ '= s:save_winmin\(width\|height\)'
+ let found_restore += 1
+ endif
+ endfor
+ call assert_equal(2, found_restore)
+ call delete('Xtest_mks.out')
+ close
+ set sessionoptions&
+ endfunc
+
" Test for mksession with 'compatible' option
func Test_mksession_compatible()
mksession! Xtest_mks1.out
*** ../vim-8.2.2775/src/version.c 2021-04-17 17:59:15.823846287 +0200
--- src/version.c 2021-04-17 18:38:20.676846211 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2776,
/**/
--
FIXME and XXX are two common keywords used to mark broken or incomplete code
not only since XXX as a sex reference would grab everybody's attention but
simply due to the fact that Vim would highlight these words.
-- Hendrik Scholz
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202104171640.13HGe6C0093991%40masaka.moolenaar.net.