@@ -1412,6 +1412,33 @@ qf_guess_filepath(char_u *filename)
14121412
14131413}
14141414
1415+ /*
1416+ * When loading a file from the quickfix, the auto commands may modify it.
1417+ * This may invalidate the current quickfix entry. This function checks
1418+ * whether a entry is still present in the quickfix.
1419+ * Similar to location list.
1420+ */
1421+ static int
1422+ is_qf_entry_present (qf_info_T * qi , qfline_T * qf_ptr )
1423+ {
1424+ qf_list_T * qfl ;
1425+ qfline_T * qfp ;
1426+ int i ;
1427+
1428+ qfl = & qi -> qf_lists [qi -> qf_curlist ];
1429+
1430+ /* Search for the entry in the current list */
1431+ for (i = 0 , qfp = qfl -> qf_start ; i < qfl -> qf_count ;
1432+ ++ i , qfp = qfp -> qf_next )
1433+ if (qfp == qf_ptr )
1434+ break ;
1435+
1436+ if (i == qfl -> qf_count ) /* Entry is not found */
1437+ return FALSE;
1438+
1439+ return TRUE;
1440+ }
1441+
14151442/*
14161443 * jump to a quickfix line
14171444 * if dir == FORWARD go "errornr" valid entries forward
@@ -1794,18 +1821,34 @@ qf_jump(
17941821 }
17951822 else
17961823 {
1824+ int old_qf_curlist = qi -> qf_curlist ;
1825+ int is_abort = FALSE;
1826+
17971827 ok = buflist_getfile (qf_ptr -> qf_fnum ,
17981828 (linenr_T )1 , GETF_SETMARK | GETF_SWITCH , forceit );
17991829 if (qi != & ql_info && !win_valid (oldwin ))
18001830 {
18011831 EMSG (_ ("E924: Current window was closed" ));
1832+ is_abort = TRUE;
1833+ opened_window = FALSE;
1834+ }
1835+ else if (old_qf_curlist != qi -> qf_curlist
1836+ || !is_qf_entry_present (qi , qf_ptr ))
1837+ {
1838+ if (qi == & ql_info )
1839+ EMSG (_ ("E925: Current quickfix was changed" ));
1840+ else
1841+ EMSG (_ ("E926: Current location list was changed" ));
1842+ is_abort = TRUE;
1843+ }
1844+
1845+ if (is_abort )
1846+ {
18021847 ok = FALSE;
18031848 qi = NULL ;
18041849 qf_ptr = NULL ;
1805- opened_window = FALSE;
18061850 }
18071851 }
1808-
18091852 }
18101853
18111854 if (ok == OK )
0 commit comments