patch 8.0.1353: QuickFixCmdPost is not used consistently
Problem: QuickFixCmdPost is not used consistently.
Solution: Invoke QuickFixCmdPost consistently after QuickFixCmdPre.
(Yegappan Lakshmanan, closes #2377)
diff --git a/src/quickfix.c b/src/quickfix.c
index e802e5d..0e488f1 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -4055,6 +4055,7 @@
#ifdef FEAT_AUTOCMD
char_u *au_name = NULL;
#endif
+ int res;
if (eap->cmdidx == CMD_lfile || eap->cmdidx == CMD_lgetfile
|| eap->cmdidx == CMD_laddfile)
@@ -4102,28 +4103,18 @@
* :caddfile adds to an existing quickfix list. If there is no
* quickfix list then a new list is created.
*/
- if (qf_init(wp, p_ef, p_efm, (eap->cmdidx != CMD_caddfile
- && eap->cmdidx != CMD_laddfile),
- *eap->cmdlinep, enc) > 0
- && (eap->cmdidx == CMD_cfile
- || eap->cmdidx == CMD_lfile))
- {
+ res = qf_init(wp, p_ef, p_efm, (eap->cmdidx != CMD_caddfile
+ && eap->cmdidx != CMD_laddfile), *eap->cmdlinep, enc);
#ifdef FEAT_AUTOCMD
- if (au_name != NULL)
- apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf);
+ if (au_name != NULL)
+ apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf);
#endif
+ if (res > 0 && (eap->cmdidx == CMD_cfile || eap->cmdidx == CMD_lfile))
+ {
if (wp != NULL)
qi = GET_LOC_LIST(wp);
qf_jump(qi, 0, 0, eap->forceit); /* display first error */
}
-
- else
- {
-#ifdef FEAT_AUTOCMD
- if (au_name != NULL)
- apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf);
-#endif
- }
}
/*
@@ -5450,6 +5441,7 @@
#ifdef FEAT_AUTOCMD
char_u *au_name = NULL;
#endif
+ int res;
if (eap->cmdidx == CMD_lbuffer || eap->cmdidx == CMD_lgetbuffer
|| eap->cmdidx == CMD_laddbuffer)
@@ -5509,20 +5501,19 @@
qf_title = IObuff;
}
- if (qf_init_ext(qi, qi->qf_curlist, NULL, buf, NULL, p_efm,
+ res = qf_init_ext(qi, qi->qf_curlist, NULL, buf, NULL, p_efm,
(eap->cmdidx != CMD_caddbuffer
&& eap->cmdidx != CMD_laddbuffer),
eap->line1, eap->line2,
- qf_title, NULL) > 0)
- {
+ qf_title, NULL);
#ifdef FEAT_AUTOCMD
- if (au_name != NULL)
- apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
- curbuf->b_fname, TRUE, curbuf);
+ if (au_name != NULL)
+ apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
+ curbuf->b_fname, TRUE, curbuf);
#endif
- if (eap->cmdidx == CMD_cbuffer || eap->cmdidx == CMD_lbuffer)
- qf_jump(qi, 0, 0, eap->forceit); /* display first error */
- }
+ if (res > 0 && (eap->cmdidx == CMD_cbuffer ||
+ eap->cmdidx == CMD_lbuffer))
+ qf_jump(qi, 0, 0, eap->forceit); /* display first error */
}
}
}
@@ -5540,6 +5531,7 @@
#ifdef FEAT_AUTOCMD
char_u *au_name = NULL;
#endif
+ int res;
if (eap->cmdidx == CMD_lexpr || eap->cmdidx == CMD_lgetexpr
|| eap->cmdidx == CMD_laddexpr)
@@ -5578,20 +5570,19 @@
if ((tv->v_type == VAR_STRING && tv->vval.v_string != NULL)
|| (tv->v_type == VAR_LIST && tv->vval.v_list != NULL))
{
- if (qf_init_ext(qi, qi->qf_curlist, NULL, NULL, tv, p_efm,
+ res = qf_init_ext(qi, qi->qf_curlist, NULL, NULL, tv, p_efm,
(eap->cmdidx != CMD_caddexpr
&& eap->cmdidx != CMD_laddexpr),
(linenr_T)0, (linenr_T)0, *eap->cmdlinep,
- NULL) > 0)
- {
+ NULL);
#ifdef FEAT_AUTOCMD
- if (au_name != NULL)
- apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
- curbuf->b_fname, TRUE, curbuf);
+ if (au_name != NULL)
+ apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
+ curbuf->b_fname, TRUE, curbuf);
#endif
- if (eap->cmdidx == CMD_cexpr || eap->cmdidx == CMD_lexpr)
- qf_jump(qi, 0, 0, eap->forceit); /* display first error */
- }
+ if (res > 0 && (eap->cmdidx == CMD_cexpr ||
+ eap->cmdidx == CMD_lexpr))
+ qf_jump(qi, 0, 0, eap->forceit); /* display first error */
}
else
EMSG(_("E777: String or List expected"));