]> granicus.if.org Git - vim/commitdiff
patch 9.0.1044: setting window height using Python may cause errors v9.0.1044
authorBram Moolenaar <Bram@vim.org>
Sat, 10 Dec 2022 11:17:11 +0000 (11:17 +0000)
committerBram Moolenaar <Bram@vim.org>
Sat, 10 Dec 2022 11:17:11 +0000 (11:17 +0000)
Problem:    Setting window height using Python may cause errors.
Solution:   When setting "curwin" also set "curbuf". (closes #11687)

src/if_py_both.h
src/testdir/test_python3.vim
src/version.c

index 8dd7f09b55ef153d0659dc140b1e371ff33ba5e4..110de234fd44f0468af36a4836cc5ecb4cafd3b7 100644 (file)
@@ -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;
 
index 56d20796af64d02832653be550aae88631330074..5de94649ac4d8728b2dd1b9b1a4f33e71ecdb1cd 100644 (file)
@@ -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
index 0acd21764ff8eaf6ba797a459e853e4eb8cb842f..bc22ab127722387c4d2aa8b36f73cab5390dc86c 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1044,
 /**/
     1043,
 /**/