Mercurial > vim
changeset 31422:c3c8136ecfa0 v9.0.1044
patch 9.0.1044: setting window height using Python may cause errors
Commit: https://github.com/vim/vim/commit/6c87bbb4e45515e70ac1728cabd1451063bf427d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Dec 10 11:17:11 2022 +0000
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 https://github.com/vim/vim/issues/11687)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 10 Dec 2022 12:30:03 +0100 |
parents | 8bfc443b5b00 |
children | 66c85efdf4b0 |
files | src/if_py_both.h src/testdir/test_python3.vim src/version.c |
diffstat | 3 files changed, 24 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -4081,10 +4081,12 @@ WindowSetattr(WindowObject *self, char * #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 * #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;
--- 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