patch 9.1.1326: invalid cursor position after 'tagfunc'
Commit:
https://github.com/vim/vim/commit/9919085491c5ce47091710fce5af13e3379f17fc
Author: Christian Brabandt <[email protected]>
Date: Sun Apr 20 18:21:35 2025 +0200
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 <[email protected]>
diff --git a/src/tag.c b/src/tag.c
index f61f11674..ed8d0a80b 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 d3cd053f5..96ed10947 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 33ad8e87c..3b90185c5 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,
/**/
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1u6Yj1-00ExOV-B1%40256bit.org.