From 6c87bbb4e45515e70ac1728cabd1451063bf427d Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 10 Dec 2022 11:17:11 +0000 Subject: [PATCH] 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) --- src/if_py_both.h | 4 ++++ src/testdir/test_python3.vim | 18 ++++++++++++++++++ src/version.c | 2 ++ 3 files changed, 24 insertions(+) diff --git a/src/if_py_both.h b/src/if_py_both.h index 8dd7f09b5..110de234f 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -4081,10 +4081,12 @@ WindowSetattr(WindowObject *self, char *name, PyObject *valObject) #endif savewin = curwin; curwin = self->win; + curbuf = curwin->w_buffer; VimTryStart(); win_setheight((int) height); curwin = savewin; + curbuf = curwin->w_buffer; if (VimTryEnd()) return -1; @@ -4103,10 +4105,12 @@ WindowSetattr(WindowObject *self, char *name, PyObject *valObject) #endif savewin = curwin; curwin = self->win; + curbuf = curwin->w_buffer; VimTryStart(); win_setwidth((int) width); curwin = savewin; + curbuf = curwin->w_buffer; if (VimTryEnd()) return -1; diff --git a/src/testdir/test_python3.vim b/src/testdir/test_python3.vim index 56d20796a..5de94649a 100644 --- a/src/testdir/test_python3.vim +++ b/src/testdir/test_python3.vim @@ -540,6 +540,24 @@ func Test_python3_window() %bw! endfunc +" This was causing trouble because "curbuf" was not matching curwin->w_buffer +func Test_python3_window_set_height() + enew! + call setline(1, ['aaa', 'bbb', 'ccc']) + call cursor(2, 1) + set foldmethod=expr + new + wincmd w + python3 vim.windows[0].height = 5 + call assert_equal(5, winheight(1)) + + call feedkeys('j', 'xt') + call assert_equal(3, getpos('.')[1]) + + bwipe! + bwipe! +endfunc + " Test for the python List object func Test_python3_list() " Try to convert a null List diff --git a/src/version.c b/src/version.c index 0acd21764..bc22ab127 100644 --- a/src/version.c +++ b/src/version.c @@ -695,6 +695,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1044, /**/ 1043, /**/ -- 2.40.0