Skip to content

Commit 6c87bbb

Browse files
committed
patch 9.0.1044: setting window height using Python may cause errors
Problem: Setting window height using Python may cause errors. Solution: When setting "curwin" also set "curbuf". (closes #11687)
1 parent c51a376 commit 6c87bbb

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

src/if_py_both.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4081,10 +4081,12 @@ WindowSetattr(WindowObject *self, char *name, PyObject *valObject)
40814081
#endif
40824082
savewin = curwin;
40834083
curwin = self->win;
4084+
curbuf = curwin->w_buffer;
40844085

40854086
VimTryStart();
40864087
win_setheight((int) height);
40874088
curwin = savewin;
4089+
curbuf = curwin->w_buffer;
40884090
if (VimTryEnd())
40894091
return -1;
40904092

@@ -4103,10 +4105,12 @@ WindowSetattr(WindowObject *self, char *name, PyObject *valObject)
41034105
#endif
41044106
savewin = curwin;
41054107
curwin = self->win;
4108+
curbuf = curwin->w_buffer;
41064109

41074110
VimTryStart();
41084111
win_setwidth((int) width);
41094112
curwin = savewin;
4113+
curbuf = curwin->w_buffer;
41104114
if (VimTryEnd())
41114115
return -1;
41124116

src/testdir/test_python3.vim

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,24 @@ func Test_python3_window()
540540
%bw!
541541
endfunc
542542

543+
" This was causing trouble because "curbuf" was not matching curwin->w_buffer
544+
func Test_python3_window_set_height()
545+
enew!
546+
call setline(1, ['aaa', 'bbb', 'ccc'])
547+
call cursor(2, 1)
548+
set foldmethod=expr
549+
new
550+
wincmd w
551+
python3 vim.windows[0].height = 5
552+
call assert_equal(5, winheight(1))
553+
554+
call feedkeys('j', 'xt')
555+
call assert_equal(3, getpos('.')[1])
556+
557+
bwipe!
558+
bwipe!
559+
endfunc
560+
543561
" Test for the python List object
544562
func Test_python3_list()
545563
" Try to convert a null List

src/version.c

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

696696
static int included_patches[] =
697697
{ /* Add new patch number below this line */
698+
/**/
699+
1044,
698700
/**/
699701
1043,
700702
/**/

0 commit comments

Comments
 (0)