File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3324,3 +3324,5 @@ EXTERN char e_non_null_dict_required_for_argument_nr[]
33243324EXTERN char e_non_null_list_required_for_argument_nr []
33253325 INIT (= N_ ("E1298: Non-NULL List required for argument %d" ));
33263326#endif
3327+ EXTERN char e_window_unexpectedly_close_while_searching_for_tags []
3328+ INIT (= N_ ("E1299: Window unexpectedly closed while searching for tags" ));
Original file line number Diff line number Diff line change @@ -690,6 +690,16 @@ do_tag(
690690 max_num_matches = MAXCOL ; // If less than max_num_matches
691691 // found: all matches found.
692692
693+ // A tag function may do anything, which may cause various
694+ // information to become invalid. At least check for the tagstack
695+ // to still be the same.
696+ if (tagstack != curwin -> w_tagstack )
697+ {
698+ emsg (_ (e_window_unexpectedly_close_while_searching_for_tags ));
699+ FreeWild (new_num_matches , new_matches );
700+ break ;
701+ }
702+
693703 // If there already were some matches for the same name, move them
694704 // to the start. Avoids that the order changes when using
695705 // ":tnext" and jumping to another file.
Original file line number Diff line number Diff line change @@ -401,4 +401,17 @@ func Test_tagfunc_wipes_buffer()
401401 set tagfunc =
402402endfunc
403403
404+ func Test_tagfunc_closes_window ()
405+ split any
406+ func MytagfuncClose (pat, flags, info)
407+ close
408+ return [{' name' : ' mytag' , ' filename' : ' Xtest' , ' cmd' : ' 1' }]
409+ endfunc
410+ set tagfunc = MytagfuncClose
411+ call assert_fails (' tag xyz' , ' E1299:' )
412+
413+ set tagfunc =
414+ endfunc
415+
416+
404417" vim: shiftwidth = 2 sts = 2 expandtab
Original file line number Diff line number Diff line change @@ -703,6 +703,8 @@ static char *(features[]) =
703703
704704static int included_patches [] =
705705{ /* Add new patch number below this line */
706+ /**/
707+ 389 ,
706708/**/
707709 388 ,
708710/**/
You can’t perform that action at this time.
0 commit comments