@@ -4125,6 +4125,20 @@ qf_id2nr(qf_info_T *qi, int_u qfid)
41254125 return INVALID_QFIDX ;
41264126}
41274127
4128+ /*
4129+ * Jump to the first entry if there is one.
4130+ */
4131+ static void
4132+ qf_jump_first (qf_info_T * qi , int_u save_qfid , int forceit )
4133+ {
4134+ // If autocommands changed the current list, then restore it
4135+ if (qi -> qf_lists [qi -> qf_curlist ].qf_id != save_qfid )
4136+ qi -> qf_curlist = qf_id2nr (qi , save_qfid );
4137+
4138+ if (qi -> qf_lists [qi -> qf_curlist ].qf_count > 0 )
4139+ qf_jump (qi , 0 , 0 , forceit );
4140+ }
4141+
41284142/*
41294143 * Return TRUE when using ":vimgrep" for ":grep".
41304144 */
@@ -4247,12 +4261,8 @@ ex_make(exarg_T *eap)
42474261 apply_autocmds (EVENT_QUICKFIXCMDPOST , au_name ,
42484262 curbuf -> b_fname , TRUE, curbuf );
42494263 if (res > 0 && !eap -> forceit && qflist_valid (wp , save_qfid ))
4250- {
4251- // If autocommands changed the current list, then restore it
4252- if (qi -> qf_lists [qi -> qf_curlist ].qf_id != save_qfid )
4253- qi -> qf_curlist = qf_id2nr (qi , save_qfid );
4254- qf_jump (qi , 0 , 0 , FALSE); /* display first error */
4255- }
4264+ // display the first error
4265+ qf_jump_first (qi , save_qfid , FALSE);
42564266
42574267cleanup :
42584268 mch_remove (fname );
@@ -4650,10 +4660,8 @@ ex_cfile(exarg_T *eap)
46504660 if (res > 0 && (eap -> cmdidx == CMD_cfile || eap -> cmdidx == CMD_lfile )
46514661 && qflist_valid (wp , save_qfid ))
46524662 {
4653- // If autocommands changed the current list, then restore it
4654- if (qi -> qf_lists [qi -> qf_curlist ].qf_id != save_qfid )
4655- qi -> qf_curlist = qf_id2nr (qi , save_qfid );
4656- qf_jump (qi , 0 , 0 , eap -> forceit ); /* display first error */
4663+ // display the first error
4664+ qf_jump_first (qi , save_qfid , eap -> forceit );
46574665 }
46584666}
46594667
@@ -6361,10 +6369,8 @@ ex_cbuffer(exarg_T *eap)
63616369 eap -> cmdidx == CMD_lbuffer )
63626370 && qflist_valid (wp , save_qfid ))
63636371 {
6364- // If autocommands changed the current list, then restore it
6365- if (qi -> qf_lists [qi -> qf_curlist ].qf_id != save_qfid )
6366- qi -> qf_curlist = qf_id2nr (qi , save_qfid );
6367- qf_jump (qi , 0 , 0 , eap -> forceit ); /* display first error */
6372+ // display the first error
6373+ qf_jump_first (qi , save_qfid , eap -> forceit );
63686374 }
63696375 }
63706376 }
@@ -6443,10 +6449,8 @@ ex_cexpr(exarg_T *eap)
64436449 || eap -> cmdidx == CMD_lexpr )
64446450 && qflist_valid (wp , save_qfid ))
64456451 {
6446- // If autocommands changed the current list, then restore it
6447- if (qi -> qf_lists [qi -> qf_curlist ].qf_id != save_qfid )
6448- qi -> qf_curlist = qf_id2nr (qi , save_qfid );
6449- qf_jump (qi , 0 , 0 , eap -> forceit );
6452+ // display the first error
6453+ qf_jump_first (qi , save_qfid , eap -> forceit );
64506454 }
64516455 }
64526456 else
0 commit comments