]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1326: invalid cursor position after 'tagfunc' v9.1.1326
authorChristian Brabandt <cb@256bit.org>
Sun, 20 Apr 2025 16:21:35 +0000 (18:21 +0200)
committerChristian Brabandt <cb@256bit.org>
Sun, 20 Apr 2025 17:35:49 +0000 (19:35 +0200)
Problem:  invalid cursor position after 'tagfunc'
          (gandalf4a)
Solution: call check_cursor() after executing the 'tagfunc'

Signed-off-by: Christian Brabandt <cb@256bit.org>
src/tag.c
src/testdir/test_tagfunc.vim
src/version.c

index f61f116744f0f6dc0277684fe17189fb7e14636c..ed8d0a80b39e2e495676b0bdecc059cb60a5839d 100644 (file)
--- 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)
index d3cd053f53df9c3cac6d82b5f153e55b63318e33..96ed1094701056aa8d3d0db3a030ae6ed015b3a7 100644 (file)
@@ -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
index 33ad8e87c7b1e1864aac51f823e6223fc1b8ccd8..3b90185c58983f3ec119b0acc27b7a1649d0ddba 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1326,
 /**/
     1325,
 /**/