Skip to content

Commit 2c90d51

Browse files
committed
patch 8.0.0482: the setbufvar() function may mess up the window layout
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.
1 parent aab93b1 commit 2c90d51

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

src/testdir/test_functions.vim

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,3 +725,34 @@ func Test_balloon_show()
725725
call balloon_show('hi!')
726726
endif
727727
endfunc
728+
729+
func Test_setbufvar_options()
730+
" This tests that aucmd_prepbuf() and aucmd_restbuf() properly restore the
731+
" window layout.
732+
call assert_equal(1, winnr('$'))
733+
split dummy_preview
734+
resize 2
735+
set winfixheight winfixwidth
736+
let prev_id = win_getid()
737+
738+
wincmd j
739+
let wh = winheight('.')
740+
let dummy_buf = bufnr('dummy_buf1', v:true)
741+
call setbufvar(dummy_buf, '&buftype', 'nofile')
742+
execute 'belowright vertical split #' . dummy_buf
743+
call assert_equal(wh, winheight('.'))
744+
let dum1_id = win_getid()
745+
746+
wincmd h
747+
let wh = winheight('.')
748+
let dummy_buf = bufnr('dummy_buf2', v:true)
749+
call setbufvar(dummy_buf, '&buftype', 'nofile')
750+
execute 'belowright vertical split #' . dummy_buf
751+
call assert_equal(wh, winheight('.'))
752+
753+
bwipe!
754+
call win_gotoid(prev_id)
755+
bwipe!
756+
call win_gotoid(dum1_id)
757+
bwipe!
758+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
482,
767769
/**/
768770
481,
769771
/**/

src/window.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6563,7 +6563,7 @@ check_snapshot_rec(frame_T *sn, frame_T *fr)
65636563
&& check_snapshot_rec(sn->fr_next, fr->fr_next) == FAIL)
65646564
|| (sn->fr_child != NULL
65656565
&& check_snapshot_rec(sn->fr_child, fr->fr_child) == FAIL)
6566-
|| !win_valid(sn->fr_win))
6566+
|| (sn->fr_win != NULL && !win_valid(sn->fr_win)))
65676567
return FAIL;
65686568
return OK;
65696569
}

0 commit comments

Comments
 (0)