From: Christian Brabandt Date: Sun, 20 Apr 2025 16:21:35 +0000 (+0200) Subject: patch 9.1.1326: invalid cursor position after 'tagfunc' X-Git-Tag: v9.1.1326^0 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9919085491c5ce47091710fce5af13e3379f17fc;p=thirdparty%2Fvim.git patch 9.1.1326: invalid cursor position after 'tagfunc' Problem: invalid cursor position after 'tagfunc' (gandalf4a) Solution: call check_cursor() after executing the 'tagfunc' Signed-off-by: Christian Brabandt --- diff --git a/src/tag.c b/src/tag.c index f61f116744..ed8d0a80b3 100644 --- a/src/tag.c +++ b/src/tag.c @@ -1481,6 +1481,7 @@ find_tagfunc_tags( save_pos = curwin->w_cursor; result = call_callback(&curbuf->b_tfu_cb, 0, &rettv, 3, args); curwin->w_cursor = save_pos; // restore the cursor position + check_cursor(); // make sure cursor position is valid --d->dv_refcount; if (result == FAIL) diff --git a/src/testdir/test_tagfunc.vim b/src/testdir/test_tagfunc.vim index d3cd053f53..96ed109470 100644 --- a/src/testdir/test_tagfunc.vim +++ b/src/testdir/test_tagfunc.vim @@ -412,5 +412,24 @@ func Test_tagfunc_closes_window() set tagfunc= endfunc +func Test_tagfunc_deletes_lines() + defer delete('Xany') + split Xany + call writefile([''], 'Xtest', 'D') + call setline(1, range(10)) + call cursor(10, 1) + func MytagfuncDel(pat, flags, info) + 9,10d + return [{'name' : 'mytag', 'filename' : 'Xtest', 'cmd' : '1'}] + endfunc + set tagfunc=MytagfuncDel + call taglist('.') + call assert_equal([0, 8, 1, 0], getpos('.')) + norm! ofoobar + call assert_equal(['0', '1', '2', '3', '4', '5', '6', '7', 'foobar'], getline(1, '$')) + + bw! + set tagfunc= +endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index 33ad8e87c7..3b90185c58 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1326, /**/ 1325, /**/