From d984a8d130c2063dcd33ae52f98c22fe3567cd18 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Fri, 7 Jan 2022 17:27:47 +0000 Subject: vim-patch:8.2.4026: ml_get error with specific win_execute() command Problem: ml_get error with specific win_execute() command. (Sean Dewar) Solution: Check cursor and Visual area are OK. https://github.com/vim/vim/commit/e664a327014f4aa8baf8549a34a4caab2f3116a3 --- src/nvim/eval/funcs.c | 7 +++++++ src/nvim/testdir/test_execute_func.vim | 15 +++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'src') diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 3cfc00fea2..b16041b832 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -2193,6 +2193,13 @@ static void f_win_execute(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (win_valid(wp) && !equalpos(curpos, wp->w_cursor)) { wp->w_redr_status = true; } + + // In case the command moved the cursor or changed the Visual area, + // check it is valid. + check_cursor(); + if (VIsual_active) { + check_pos(curbuf, &VIsual); + } } } diff --git a/src/nvim/testdir/test_execute_func.vim b/src/nvim/testdir/test_execute_func.vim index bb601e19ac..16cc20e9a7 100644 --- a/src/nvim/testdir/test_execute_func.vim +++ b/src/nvim/testdir/test_execute_func.vim @@ -152,8 +152,23 @@ func Test_win_execute_visual_redraw() call setline(1, ['a', 'b', 'c']) new wincmd p + " start Visual in current window, redraw in other window with fewer lines call feedkeys("G\", 'txn') call win_execute(winnr('#')->win_getid(), 'redraw') + call feedkeys("\", 'txn') + bwipe! + bwipe! + + enew + new + call setline(1, ['a', 'b', 'c']) + let winid = win_getid() + wincmd p + " start Visual in current window, extend it in other window with more lines + call feedkeys("\", 'txn') + call win_execute(winid, 'call feedkeys("G\", ''txn'')') + redraw + bwipe! bwipe! endfunc -- cgit