aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/testdir/test_cmdline.vim30
-rw-r--r--src/nvim/window.c25
2 files changed, 44 insertions, 11 deletions
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim
index 0c31619086..5b23525ab5 100644
--- a/src/nvim/testdir/test_cmdline.vim
+++ b/src/nvim/testdir/test_cmdline.vim
@@ -850,6 +850,36 @@ func Test_cmdwin_cedit()
delfunc CmdWinType
endfunc
+func Test_cmdwin_restore()
+ CheckScreendump
+
+ let lines =<< trim [SCRIPT]
+ call setline(1, range(30))
+ 2split
+ [SCRIPT]
+ call writefile(lines, 'XTest_restore')
+
+ let buf = RunVimInTerminal('-S XTest_restore', {'rows': 12})
+ call term_wait(buf, 100)
+ call term_sendkeys(buf, "q:")
+ call VerifyScreenDump(buf, 'Test_cmdwin_restore_1', {})
+
+ " normal restore
+ call term_sendkeys(buf, ":q\<CR>")
+ call VerifyScreenDump(buf, 'Test_cmdwin_restore_2', {})
+
+ " restore after setting 'lines' with one window
+ call term_sendkeys(buf, ":close\<CR>")
+ call term_sendkeys(buf, "q:")
+ call term_sendkeys(buf, ":set lines=18\<CR>")
+ call term_sendkeys(buf, ":q\<CR>")
+ call VerifyScreenDump(buf, 'Test_cmdwin_restore_3', {})
+
+ " clean up
+ call StopVimInTerminal(buf)
+ call delete('XTest_restore')
+endfunc
+
func Test_buffers_lastused()
" check that buffers are sorted by time when wildmode has lastused
edit bufc " oldest
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 6ecfd9ab64..2dcce2d8cb 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -5013,7 +5013,10 @@ void win_size_save(garray_T *gap)
{
ga_init(gap, (int)sizeof(int), 1);
- ga_grow(gap, win_count() * 2);
+ ga_grow(gap, win_count() * 2 + 1);
+ // first entry is value of 'lines'
+ ((int *)gap->ga_data)[gap->ga_len++] = Rows;
+
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
((int *)gap->ga_data)[gap->ga_len++] =
wp->w_width + wp->w_vsep_width;
@@ -5021,18 +5024,18 @@ void win_size_save(garray_T *gap)
}
}
-/*
- * Restore window sizes, but only if the number of windows is still the same.
- * Does not free the growarray.
- */
+// Restore window sizes, but only if the number of windows is still the same
+// and 'lines' didn't change.
+// Does not free the growarray.
void win_size_restore(garray_T *gap)
+ FUNC_ATTR_NONNULL_ALL
{
- if (win_count() * 2 == gap->ga_len) {
- /* The order matters, because frames contain other frames, but it's
- * difficult to get right. The easy way out is to do it twice. */
- for (int j = 0; j < 2; ++j)
- {
- int i = 0;
+ if (win_count() * 2 + 1 == gap->ga_len
+ && ((int *)gap->ga_data)[0] == Rows) {
+ // The order matters, because frames contain other frames, but it's
+ // difficult to get right. The easy way out is to do it twice.
+ for (int j = 0; j < 2; j++) {
+ int i = 1;
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
int width = ((int *)gap->ga_data)[i++];
int height = ((int *)gap->ga_data)[i++];