]> granicus.if.org Git - vim/commitdiff
patch 8.0.0482: the setbufvar() function may mess up the window layout v8.0.0482
authorBram Moolenaar <Bram@vim.org>
Sat, 18 Mar 2017 21:35:30 +0000 (22:35 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 18 Mar 2017 21:35:30 +0000 (22:35 +0100)
Problem:    The setbufvar() function may mess up the window layout. (Kay Z.)
Solution:   Do not check the window to be valid if it is NULL.

src/testdir/test_functions.vim
src/version.c
src/window.c

index e2a4e8c7dffee798e1021facf8b328803c151884..228e7ab4349d564d5b592d64415c630a4e49d1ff 100644 (file)
@@ -725,3 +725,34 @@ func Test_balloon_show()
     call balloon_show('hi!')
   endif
 endfunc
+
+func Test_setbufvar_options()
+  " This tests that aucmd_prepbuf() and aucmd_restbuf() properly restore the
+  " window layout.
+  call assert_equal(1, winnr('$'))
+  split dummy_preview
+  resize 2
+  set winfixheight winfixwidth
+  let prev_id = win_getid()
+
+  wincmd j
+  let wh = winheight('.')
+  let dummy_buf = bufnr('dummy_buf1', v:true)
+  call setbufvar(dummy_buf, '&buftype', 'nofile')
+  execute 'belowright vertical split #' . dummy_buf
+  call assert_equal(wh, winheight('.'))
+  let dum1_id = win_getid()
+
+  wincmd h
+  let wh = winheight('.')
+  let dummy_buf = bufnr('dummy_buf2', v:true)
+  call setbufvar(dummy_buf, '&buftype', 'nofile')
+  execute 'belowright vertical split #' . dummy_buf
+  call assert_equal(wh, winheight('.'))
+
+  bwipe!
+  call win_gotoid(prev_id)
+  bwipe!
+  call win_gotoid(dum1_id)
+  bwipe!
+endfunc
index 007a1e67371e382e2578b3189a6141da58a04a7d..828450d17189b0386e23b415a76a3e387c2ef947 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    482,
 /**/
     481,
 /**/
index 43c9ed2c07688431f8238209cbfa2983f38af4b1..06f97de2723ece06d2159752ba3f8e29a0de6de8 100644 (file)
@@ -6563,7 +6563,7 @@ check_snapshot_rec(frame_T *sn, frame_T *fr)
                && check_snapshot_rec(sn->fr_next, fr->fr_next) == FAIL)
            || (sn->fr_child != NULL
                && check_snapshot_rec(sn->fr_child, fr->fr_child) == FAIL)
-           || !win_valid(sn->fr_win))
+           || (sn->fr_win != NULL && !win_valid(sn->fr_win)))
        return FAIL;
     return OK;
 }