comparison src/quickfix.c @ 12954:49e136457c66 v8.0.1353

patch 8.0.1353: QuickFixCmdPost is not used consistently commit https://github.com/vim/vim/commit/1ed2276fd50f34e824eeae93d5a5ebfdf118be26 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Nov 28 18:03:44 2017 +0100 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)
author Christian Brabandt <cb@256bit.org>
date Tue, 28 Nov 2017 18:15:05 +0100
parents 888441e8fbb0
children e47e70300f30
comparison
equal deleted inserted replaced
12953:f80cd88a645d 12954:49e136457c66
4053 win_T *wp = NULL; 4053 win_T *wp = NULL;
4054 qf_info_T *qi = &ql_info; 4054 qf_info_T *qi = &ql_info;
4055 #ifdef FEAT_AUTOCMD 4055 #ifdef FEAT_AUTOCMD
4056 char_u *au_name = NULL; 4056 char_u *au_name = NULL;
4057 #endif 4057 #endif
4058 int res;
4058 4059
4059 if (eap->cmdidx == CMD_lfile || eap->cmdidx == CMD_lgetfile 4060 if (eap->cmdidx == CMD_lfile || eap->cmdidx == CMD_lgetfile
4060 || eap->cmdidx == CMD_laddfile) 4061 || eap->cmdidx == CMD_laddfile)
4061 wp = curwin; 4062 wp = curwin;
4062 4063
4100 * :cgetfile creates a new quickfix list but doesn't jump to the 4101 * :cgetfile creates a new quickfix list but doesn't jump to the
4101 * first error. 4102 * first error.
4102 * :caddfile adds to an existing quickfix list. If there is no 4103 * :caddfile adds to an existing quickfix list. If there is no
4103 * quickfix list then a new list is created. 4104 * quickfix list then a new list is created.
4104 */ 4105 */
4105 if (qf_init(wp, p_ef, p_efm, (eap->cmdidx != CMD_caddfile 4106 res = qf_init(wp, p_ef, p_efm, (eap->cmdidx != CMD_caddfile
4106 && eap->cmdidx != CMD_laddfile), 4107 && eap->cmdidx != CMD_laddfile), *eap->cmdlinep, enc);
4107 *eap->cmdlinep, enc) > 0
4108 && (eap->cmdidx == CMD_cfile
4109 || eap->cmdidx == CMD_lfile))
4110 {
4111 #ifdef FEAT_AUTOCMD 4108 #ifdef FEAT_AUTOCMD
4112 if (au_name != NULL) 4109 if (au_name != NULL)
4113 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf); 4110 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf);
4114 #endif 4111 #endif
4112 if (res > 0 && (eap->cmdidx == CMD_cfile || eap->cmdidx == CMD_lfile))
4113 {
4115 if (wp != NULL) 4114 if (wp != NULL)
4116 qi = GET_LOC_LIST(wp); 4115 qi = GET_LOC_LIST(wp);
4117 qf_jump(qi, 0, 0, eap->forceit); /* display first error */ 4116 qf_jump(qi, 0, 0, eap->forceit); /* display first error */
4118 }
4119
4120 else
4121 {
4122 #ifdef FEAT_AUTOCMD
4123 if (au_name != NULL)
4124 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf);
4125 #endif
4126 } 4117 }
4127 } 4118 }
4128 4119
4129 /* 4120 /*
4130 * ":vimgrep {pattern} file(s)" 4121 * ":vimgrep {pattern} file(s)"
5448 buf_T *buf = NULL; 5439 buf_T *buf = NULL;
5449 qf_info_T *qi = &ql_info; 5440 qf_info_T *qi = &ql_info;
5450 #ifdef FEAT_AUTOCMD 5441 #ifdef FEAT_AUTOCMD
5451 char_u *au_name = NULL; 5442 char_u *au_name = NULL;
5452 #endif 5443 #endif
5444 int res;
5453 5445
5454 if (eap->cmdidx == CMD_lbuffer || eap->cmdidx == CMD_lgetbuffer 5446 if (eap->cmdidx == CMD_lbuffer || eap->cmdidx == CMD_lgetbuffer
5455 || eap->cmdidx == CMD_laddbuffer) 5447 || eap->cmdidx == CMD_laddbuffer)
5456 { 5448 {
5457 qi = ll_get_or_alloc_list(curwin); 5449 qi = ll_get_or_alloc_list(curwin);
5507 vim_snprintf((char *)IObuff, IOSIZE, "%s (%s)", 5499 vim_snprintf((char *)IObuff, IOSIZE, "%s (%s)",
5508 (char *)qf_title, (char *)buf->b_sfname); 5500 (char *)qf_title, (char *)buf->b_sfname);
5509 qf_title = IObuff; 5501 qf_title = IObuff;
5510 } 5502 }
5511 5503
5512 if (qf_init_ext(qi, qi->qf_curlist, NULL, buf, NULL, p_efm, 5504 res = qf_init_ext(qi, qi->qf_curlist, NULL, buf, NULL, p_efm,
5513 (eap->cmdidx != CMD_caddbuffer 5505 (eap->cmdidx != CMD_caddbuffer
5514 && eap->cmdidx != CMD_laddbuffer), 5506 && eap->cmdidx != CMD_laddbuffer),
5515 eap->line1, eap->line2, 5507 eap->line1, eap->line2,
5516 qf_title, NULL) > 0) 5508 qf_title, NULL);
5517 {
5518 #ifdef FEAT_AUTOCMD 5509 #ifdef FEAT_AUTOCMD
5519 if (au_name != NULL) 5510 if (au_name != NULL)
5520 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, 5511 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
5521 curbuf->b_fname, TRUE, curbuf); 5512 curbuf->b_fname, TRUE, curbuf);
5522 #endif 5513 #endif
5523 if (eap->cmdidx == CMD_cbuffer || eap->cmdidx == CMD_lbuffer) 5514 if (res > 0 && (eap->cmdidx == CMD_cbuffer ||
5524 qf_jump(qi, 0, 0, eap->forceit); /* display first error */ 5515 eap->cmdidx == CMD_lbuffer))
5525 } 5516 qf_jump(qi, 0, 0, eap->forceit); /* display first error */
5526 } 5517 }
5527 } 5518 }
5528 } 5519 }
5529 5520
5530 #if defined(FEAT_EVAL) || defined(PROTO) 5521 #if defined(FEAT_EVAL) || defined(PROTO)
5538 typval_T *tv; 5529 typval_T *tv;
5539 qf_info_T *qi = &ql_info; 5530 qf_info_T *qi = &ql_info;
5540 #ifdef FEAT_AUTOCMD 5531 #ifdef FEAT_AUTOCMD
5541 char_u *au_name = NULL; 5532 char_u *au_name = NULL;
5542 #endif 5533 #endif
5534 int res;
5543 5535
5544 if (eap->cmdidx == CMD_lexpr || eap->cmdidx == CMD_lgetexpr 5536 if (eap->cmdidx == CMD_lexpr || eap->cmdidx == CMD_lgetexpr
5545 || eap->cmdidx == CMD_laddexpr) 5537 || eap->cmdidx == CMD_laddexpr)
5546 { 5538 {
5547 qi = ll_get_or_alloc_list(curwin); 5539 qi = ll_get_or_alloc_list(curwin);
5576 if (tv != NULL) 5568 if (tv != NULL)
5577 { 5569 {
5578 if ((tv->v_type == VAR_STRING && tv->vval.v_string != NULL) 5570 if ((tv->v_type == VAR_STRING && tv->vval.v_string != NULL)
5579 || (tv->v_type == VAR_LIST && tv->vval.v_list != NULL)) 5571 || (tv->v_type == VAR_LIST && tv->vval.v_list != NULL))
5580 { 5572 {
5581 if (qf_init_ext(qi, qi->qf_curlist, NULL, NULL, tv, p_efm, 5573 res = qf_init_ext(qi, qi->qf_curlist, NULL, NULL, tv, p_efm,
5582 (eap->cmdidx != CMD_caddexpr 5574 (eap->cmdidx != CMD_caddexpr
5583 && eap->cmdidx != CMD_laddexpr), 5575 && eap->cmdidx != CMD_laddexpr),
5584 (linenr_T)0, (linenr_T)0, *eap->cmdlinep, 5576 (linenr_T)0, (linenr_T)0, *eap->cmdlinep,
5585 NULL) > 0) 5577 NULL);
5586 {
5587 #ifdef FEAT_AUTOCMD 5578 #ifdef FEAT_AUTOCMD
5588 if (au_name != NULL) 5579 if (au_name != NULL)
5589 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, 5580 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
5590 curbuf->b_fname, TRUE, curbuf); 5581 curbuf->b_fname, TRUE, curbuf);
5591 #endif 5582 #endif
5592 if (eap->cmdidx == CMD_cexpr || eap->cmdidx == CMD_lexpr) 5583 if (res > 0 && (eap->cmdidx == CMD_cexpr ||
5593 qf_jump(qi, 0, 0, eap->forceit); /* display first error */ 5584 eap->cmdidx == CMD_lexpr))
5594 } 5585 qf_jump(qi, 0, 0, eap->forceit); /* display first error */
5595 } 5586 }
5596 else 5587 else
5597 EMSG(_("E777: String or List expected")); 5588 EMSG(_("E777: String or List expected"));
5598 free_tv(tv); 5589 free_tv(tv);
5599 } 5590 }