Mercurial > vim
comparison src/quickfix.c @ 13921:3b6c29f8c1a2 v8.0.1831
patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
commit https://github.com/vim/vim/commit/8b62e31003693fee4b288e7aea49170f032aeef3
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun May 13 15:29:04 2018 +0200
patch 8.0.1831: sometimes the quickfix title is incorrectly prefixed with ':'
Problem: Sometimes the quickfix title is incorrectly prefixed with ':'.
Solution: Prepend the colon in another way. (Yegappan Lakshmanan, closes
#2905)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 13 May 2018 15:30:07 +0200 |
parents | f48fcaa196a9 |
children | 2ed1585c6467 |
comparison
equal
deleted
inserted
replaced
13920:ceb452a8cfd8 | 13921:3b6c29f8c1a2 |
---|---|
1023 fields->use_viscol = FALSE; | 1023 fields->use_viscol = FALSE; |
1024 fields->enr = -1; | 1024 fields->enr = -1; |
1025 fields->type = 0; | 1025 fields->type = 0; |
1026 *tail = NULL; | 1026 *tail = NULL; |
1027 | 1027 |
1028 /* Always ignore case when looking for a matching error. */ | |
1029 regmatch.rm_ic = TRUE; | |
1028 regmatch.regprog = fmt_ptr->prog; | 1030 regmatch.regprog = fmt_ptr->prog; |
1029 r = vim_regexec(®match, linebuf, (colnr_T)0); | 1031 r = vim_regexec(®match, linebuf, (colnr_T)0); |
1030 fmt_ptr->prog = regmatch.regprog; | 1032 fmt_ptr->prog = regmatch.regprog; |
1031 if (r) | 1033 if (r) |
1032 status = qf_parse_match(linebuf, linelen, fmt_ptr, ®match, | 1034 status = qf_parse_match(linebuf, linelen, fmt_ptr, ®match, |
1496 { | 1498 { |
1497 char_u *p = alloc((int)STRLEN(title) + 2); | 1499 char_u *p = alloc((int)STRLEN(title) + 2); |
1498 | 1500 |
1499 qi->qf_lists[qf_idx].qf_title = p; | 1501 qi->qf_lists[qf_idx].qf_title = p; |
1500 if (p != NULL) | 1502 if (p != NULL) |
1501 sprintf((char *)p, ":%s", (char *)title); | 1503 STRCPY(p, title); |
1502 } | 1504 } |
1505 } | |
1506 | |
1507 /* | |
1508 * The title of a quickfix/location list is set, by default, to the command | |
1509 * that created the quickfix list with the ":" prefix. | |
1510 * Create a quickfix list title string by prepending ":" to a user command. | |
1511 * Returns a pointer to a static buffer with the title. | |
1512 */ | |
1513 static char_u * | |
1514 qf_cmdtitle(char_u *cmd) | |
1515 { | |
1516 static char_u qftitle_str[IOSIZE]; | |
1517 | |
1518 vim_snprintf((char *)qftitle_str, IOSIZE, ":%s", (char *)cmd); | |
1519 return qftitle_str; | |
1503 } | 1520 } |
1504 | 1521 |
1505 /* | 1522 /* |
1506 * Prepare for adding a new quickfix list. If the current list is in the | 1523 * Prepare for adding a new quickfix list. If the current list is in the |
1507 * middle of the stack, then all the following lists are freed and then | 1524 * middle of the stack, then all the following lists are freed and then |
4018 | 4035 |
4019 res = qf_init(wp, fname, (eap->cmdidx != CMD_make | 4036 res = qf_init(wp, fname, (eap->cmdidx != CMD_make |
4020 && eap->cmdidx != CMD_lmake) ? p_gefm : p_efm, | 4037 && eap->cmdidx != CMD_lmake) ? p_gefm : p_efm, |
4021 (eap->cmdidx != CMD_grepadd | 4038 (eap->cmdidx != CMD_grepadd |
4022 && eap->cmdidx != CMD_lgrepadd), | 4039 && eap->cmdidx != CMD_lgrepadd), |
4023 *eap->cmdlinep, enc); | 4040 qf_cmdtitle(*eap->cmdlinep), enc); |
4024 if (wp != NULL) | 4041 if (wp != NULL) |
4025 qi = GET_LOC_LIST(wp); | 4042 qi = GET_LOC_LIST(wp); |
4026 if (res >= 0 && qi != NULL) | 4043 if (res >= 0 && qi != NULL) |
4027 qf_list_changed(qi, qi->qf_curlist); | 4044 qf_list_changed(qi, qi->qf_curlist); |
4028 if (au_name != NULL) | 4045 if (au_name != NULL) |
4411 * first error. | 4428 * first error. |
4412 * :caddfile adds to an existing quickfix list. If there is no | 4429 * :caddfile adds to an existing quickfix list. If there is no |
4413 * quickfix list then a new list is created. | 4430 * quickfix list then a new list is created. |
4414 */ | 4431 */ |
4415 res = qf_init(wp, p_ef, p_efm, (eap->cmdidx != CMD_caddfile | 4432 res = qf_init(wp, p_ef, p_efm, (eap->cmdidx != CMD_caddfile |
4416 && eap->cmdidx != CMD_laddfile), *eap->cmdlinep, enc); | 4433 && eap->cmdidx != CMD_laddfile), |
4434 qf_cmdtitle(*eap->cmdlinep), enc); | |
4417 if (wp != NULL) | 4435 if (wp != NULL) |
4418 qi = GET_LOC_LIST(wp); | 4436 qi = GET_LOC_LIST(wp); |
4419 if (res >= 0 && qi != NULL) | 4437 if (res >= 0 && qi != NULL) |
4420 qf_list_changed(qi, qi->qf_curlist); | 4438 qf_list_changed(qi, qi->qf_curlist); |
4421 if (qi != NULL) | 4439 if (qi != NULL) |
4747 else | 4765 else |
4748 tomatch = MAXLNUM; | 4766 tomatch = MAXLNUM; |
4749 | 4767 |
4750 /* Get the search pattern: either white-separated or enclosed in // */ | 4768 /* Get the search pattern: either white-separated or enclosed in // */ |
4751 regmatch.regprog = NULL; | 4769 regmatch.regprog = NULL; |
4752 title = vim_strsave(*eap->cmdlinep); | 4770 title = vim_strsave(qf_cmdtitle(*eap->cmdlinep)); |
4753 p = skip_vimgrep_pat(eap->arg, &s, &flags); | 4771 p = skip_vimgrep_pat(eap->arg, &s, &flags); |
4754 if (p == NULL) | 4772 if (p == NULL) |
4755 { | 4773 { |
4756 EMSG(_(e_invalpat)); | 4774 EMSG(_(e_invalpat)); |
4757 goto theend; | 4775 goto theend; |
4771 if ((eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd | 4789 if ((eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd |
4772 && eap->cmdidx != CMD_vimgrepadd | 4790 && eap->cmdidx != CMD_vimgrepadd |
4773 && eap->cmdidx != CMD_lvimgrepadd) | 4791 && eap->cmdidx != CMD_lvimgrepadd) |
4774 || qi->qf_curlist == qi->qf_listcount) | 4792 || qi->qf_curlist == qi->qf_listcount) |
4775 /* make place for a new list */ | 4793 /* make place for a new list */ |
4776 qf_new_list(qi, title != NULL ? title : *eap->cmdlinep); | 4794 qf_new_list(qi, title != NULL ? title : qf_cmdtitle(*eap->cmdlinep)); |
4777 | 4795 |
4778 /* parse the list of arguments */ | 4796 /* parse the list of arguments */ |
4779 if (get_arglist_exp(p, &fcount, &fnames, TRUE) == FAIL) | 4797 if (get_arglist_exp(p, &fcount, &fnames, TRUE) == FAIL) |
4780 goto theend; | 4798 goto theend; |
4781 if (fcount == 0) | 4799 if (fcount == 0) |
4826 /* Use existing, loaded buffer. */ | 4844 /* Use existing, loaded buffer. */ |
4827 using_dummy = FALSE; | 4845 using_dummy = FALSE; |
4828 | 4846 |
4829 /* Check whether the quickfix list is still valid. When loading a | 4847 /* Check whether the quickfix list is still valid. When loading a |
4830 * buffer above, autocommands might have changed the quickfix list. */ | 4848 * buffer above, autocommands might have changed the quickfix list. */ |
4831 if (!vgr_qflist_valid(wp, qi, save_qfid, *eap->cmdlinep)) | 4849 if (!vgr_qflist_valid(wp, qi, save_qfid, qf_cmdtitle(*eap->cmdlinep))) |
4832 { | 4850 { |
4833 FreeWild(fcount, fnames); | 4851 FreeWild(fcount, fnames); |
4834 goto theend; | 4852 goto theend; |
4835 } | 4853 } |
4836 save_qfid = qi->qf_lists[qi->qf_curlist].qf_id; | 4854 save_qfid = qi->qf_lists[qi->qf_curlist].qf_id; |
6123 if (eap->line1 < 1 || eap->line1 > buf->b_ml.ml_line_count | 6141 if (eap->line1 < 1 || eap->line1 > buf->b_ml.ml_line_count |
6124 || eap->line2 < 1 || eap->line2 > buf->b_ml.ml_line_count) | 6142 || eap->line2 < 1 || eap->line2 > buf->b_ml.ml_line_count) |
6125 EMSG(_(e_invrange)); | 6143 EMSG(_(e_invrange)); |
6126 else | 6144 else |
6127 { | 6145 { |
6128 char_u *qf_title = *eap->cmdlinep; | 6146 char_u *qf_title = qf_cmdtitle(*eap->cmdlinep); |
6129 | 6147 |
6130 if (buf->b_sfname) | 6148 if (buf->b_sfname) |
6131 { | 6149 { |
6132 vim_snprintf((char *)IObuff, IOSIZE, "%s (%s)", | 6150 vim_snprintf((char *)IObuff, IOSIZE, "%s (%s)", |
6133 (char *)qf_title, (char *)buf->b_sfname); | 6151 (char *)qf_title, (char *)buf->b_sfname); |
6201 || (tv->v_type == VAR_LIST && tv->vval.v_list != NULL)) | 6219 || (tv->v_type == VAR_LIST && tv->vval.v_list != NULL)) |
6202 { | 6220 { |
6203 res = qf_init_ext(qi, qi->qf_curlist, NULL, NULL, tv, p_efm, | 6221 res = qf_init_ext(qi, qi->qf_curlist, NULL, NULL, tv, p_efm, |
6204 (eap->cmdidx != CMD_caddexpr | 6222 (eap->cmdidx != CMD_caddexpr |
6205 && eap->cmdidx != CMD_laddexpr), | 6223 && eap->cmdidx != CMD_laddexpr), |
6206 (linenr_T)0, (linenr_T)0, *eap->cmdlinep, | 6224 (linenr_T)0, (linenr_T)0, |
6207 NULL); | 6225 qf_cmdtitle(*eap->cmdlinep), NULL); |
6208 if (res >= 0) | 6226 if (res >= 0) |
6209 qf_list_changed(qi, qi->qf_curlist); | 6227 qf_list_changed(qi, qi->qf_curlist); |
6210 if (au_name != NULL) | 6228 if (au_name != NULL) |
6211 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, | 6229 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, |
6212 curbuf->b_fname, TRUE, curbuf); | 6230 curbuf->b_fname, TRUE, curbuf); |
6474 regmatch.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING); | 6492 regmatch.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING); |
6475 regmatch.rm_ic = FALSE; | 6493 regmatch.rm_ic = FALSE; |
6476 if (regmatch.regprog != NULL) | 6494 if (regmatch.regprog != NULL) |
6477 { | 6495 { |
6478 /* create a new quickfix list */ | 6496 /* create a new quickfix list */ |
6479 qf_new_list(qi, *eap->cmdlinep); | 6497 qf_new_list(qi, qf_cmdtitle(*eap->cmdlinep)); |
6480 | 6498 |
6481 hgr_search_in_rtp(qi, ®match, eap->arg); | 6499 hgr_search_in_rtp(qi, ®match, eap->arg); |
6482 | 6500 |
6483 vim_regfree(regmatch.regprog); | 6501 vim_regfree(regmatch.regprog); |
6484 | 6502 |