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 <cb@256bit.org>
diff --git a/src/tag.c b/src/tag.c
index f61f116..ed8d0a8 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -1481,6 +1481,7 @@
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 d3cd053..96ed109 100644
--- a/src/testdir/test_tagfunc.vim
+++ b/src/testdir/test_tagfunc.vim
@@ -412,5 +412,24 @@
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 33ad8e8..3b90185 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1326,
+/**/
1325,
/**/
1324,