To: vim_dev@googlegroups.com Subject: Patch 8.0.1831 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1831 Problem: Sometimes the quickfix title is incorrectly prefixed with ':'. Solution: Prepend the colon in another way. (Yegappan Lakshmanan, closes #2905) Files: src/evalfunc.c, src/quickfix.c, src/testdir/test_quickfix.vim *** ../vim-8.0.1830/src/evalfunc.c 2018-05-08 22:01:02.197553218 +0200 --- src/evalfunc.c 2018-05-13 15:23:25.638907897 +0200 *************** *** 10473,10479 **** } if (l != NULL && action && valid_dict && set_errorlist(wp, l, action, ! (char_u *)(wp == NULL ? "setqflist()" : "setloclist()"), d) == OK) rettv->vval.v_number = 0; } #endif --- 10473,10479 ---- } if (l != NULL && action && valid_dict && set_errorlist(wp, l, action, ! (char_u *)(wp == NULL ? ":setqflist()" : ":setloclist()"), d) == OK) rettv->vval.v_number = 0; } #endif *** ../vim-8.0.1830/src/quickfix.c 2018-05-10 18:55:23.671804871 +0200 --- src/quickfix.c 2018-05-13 15:23:25.638907897 +0200 *************** *** 1025,1030 **** --- 1025,1032 ---- fields->type = 0; *tail = NULL; + /* Always ignore case when looking for a matching error. */ + regmatch.rm_ic = TRUE; regmatch.regprog = fmt_ptr->prog; r = vim_regexec(®match, linebuf, (colnr_T)0); fmt_ptr->prog = regmatch.regprog; *************** *** 1498,1508 **** qi->qf_lists[qf_idx].qf_title = p; if (p != NULL) ! sprintf((char *)p, ":%s", (char *)title); } } /* * Prepare for adding a new quickfix list. If the current list is in the * middle of the stack, then all the following lists are freed and then * the new list is added. --- 1500,1525 ---- qi->qf_lists[qf_idx].qf_title = p; if (p != NULL) ! STRCPY(p, title); } } /* + * The title of a quickfix/location list is set, by default, to the command + * that created the quickfix list with the ":" prefix. + * Create a quickfix list title string by prepending ":" to a user command. + * Returns a pointer to a static buffer with the title. + */ + static char_u * + qf_cmdtitle(char_u *cmd) + { + static char_u qftitle_str[IOSIZE]; + + vim_snprintf((char *)qftitle_str, IOSIZE, ":%s", (char *)cmd); + return qftitle_str; + } + + /* * Prepare for adding a new quickfix list. If the current list is in the * middle of the stack, then all the following lists are freed and then * the new list is added. *************** *** 4020,4026 **** && eap->cmdidx != CMD_lmake) ? p_gefm : p_efm, (eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd), ! *eap->cmdlinep, enc); if (wp != NULL) qi = GET_LOC_LIST(wp); if (res >= 0 && qi != NULL) --- 4037,4043 ---- && eap->cmdidx != CMD_lmake) ? p_gefm : p_efm, (eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd), ! qf_cmdtitle(*eap->cmdlinep), enc); if (wp != NULL) qi = GET_LOC_LIST(wp); if (res >= 0 && qi != NULL) *************** *** 4413,4419 **** * quickfix list then a new list is created. */ res = qf_init(wp, p_ef, p_efm, (eap->cmdidx != CMD_caddfile ! && eap->cmdidx != CMD_laddfile), *eap->cmdlinep, enc); if (wp != NULL) qi = GET_LOC_LIST(wp); if (res >= 0 && qi != NULL) --- 4430,4437 ---- * quickfix list then a new list is created. */ res = qf_init(wp, p_ef, p_efm, (eap->cmdidx != CMD_caddfile ! && eap->cmdidx != CMD_laddfile), ! qf_cmdtitle(*eap->cmdlinep), enc); if (wp != NULL) qi = GET_LOC_LIST(wp); if (res >= 0 && qi != NULL) *************** *** 4749,4755 **** /* Get the search pattern: either white-separated or enclosed in // */ regmatch.regprog = NULL; ! title = vim_strsave(*eap->cmdlinep); p = skip_vimgrep_pat(eap->arg, &s, &flags); if (p == NULL) { --- 4767,4773 ---- /* Get the search pattern: either white-separated or enclosed in // */ regmatch.regprog = NULL; ! title = vim_strsave(qf_cmdtitle(*eap->cmdlinep)); p = skip_vimgrep_pat(eap->arg, &s, &flags); if (p == NULL) { *************** *** 4773,4779 **** && eap->cmdidx != CMD_lvimgrepadd) || qi->qf_curlist == qi->qf_listcount) /* make place for a new list */ ! qf_new_list(qi, title != NULL ? title : *eap->cmdlinep); /* parse the list of arguments */ if (get_arglist_exp(p, &fcount, &fnames, TRUE) == FAIL) --- 4791,4797 ---- && eap->cmdidx != CMD_lvimgrepadd) || qi->qf_curlist == qi->qf_listcount) /* make place for a new list */ ! qf_new_list(qi, title != NULL ? title : qf_cmdtitle(*eap->cmdlinep)); /* parse the list of arguments */ if (get_arglist_exp(p, &fcount, &fnames, TRUE) == FAIL) *************** *** 4828,4834 **** /* Check whether the quickfix list is still valid. When loading a * buffer above, autocommands might have changed the quickfix list. */ ! if (!vgr_qflist_valid(wp, qi, save_qfid, *eap->cmdlinep)) { FreeWild(fcount, fnames); goto theend; --- 4846,4852 ---- /* Check whether the quickfix list is still valid. When loading a * buffer above, autocommands might have changed the quickfix list. */ ! if (!vgr_qflist_valid(wp, qi, save_qfid, qf_cmdtitle(*eap->cmdlinep))) { FreeWild(fcount, fnames); goto theend; *************** *** 6125,6131 **** EMSG(_(e_invrange)); else { ! char_u *qf_title = *eap->cmdlinep; if (buf->b_sfname) { --- 6143,6149 ---- EMSG(_(e_invrange)); else { ! char_u *qf_title = qf_cmdtitle(*eap->cmdlinep); if (buf->b_sfname) { *************** *** 6203,6210 **** 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); if (res >= 0) qf_list_changed(qi, qi->qf_curlist); if (au_name != NULL) --- 6221,6228 ---- 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, ! qf_cmdtitle(*eap->cmdlinep), NULL); if (res >= 0) qf_list_changed(qi, qi->qf_curlist); if (au_name != NULL) *************** *** 6476,6482 **** if (regmatch.regprog != NULL) { /* create a new quickfix list */ ! qf_new_list(qi, *eap->cmdlinep); hgr_search_in_rtp(qi, ®match, eap->arg); --- 6494,6500 ---- if (regmatch.regprog != NULL) { /* create a new quickfix list */ ! qf_new_list(qi, qf_cmdtitle(*eap->cmdlinep)); hgr_search_in_rtp(qi, ®match, eap->arg); *** ../vim-8.0.1830/src/testdir/test_quickfix.vim 2018-05-01 16:26:43.262095812 +0200 --- src/testdir/test_quickfix.vim 2018-05-13 15:23:25.638907897 +0200 *************** *** 3250,3252 **** --- 3250,3345 ---- silent! clist call assert_equal('test_quickfix.vim', bufname('test_quickfix.vim')) endfunc + + " Quickfix title tests + " In the below tests, 'exe "cmd"' is used to invoke the quickfix commands. + " Otherwise due to indentation, the title is set with spaces at the beginning + " of the command. + func Test_qftitle() + call writefile(["F1:1:Line1"], 'Xerr') + + " :cexpr + exe "cexpr readfile('Xerr')" + call assert_equal(":cexpr readfile('Xerr')", getqflist({'title' : 1}).title) + + " :cgetexpr + exe "cgetexpr readfile('Xerr')" + call assert_equal(":cgetexpr readfile('Xerr')", + \ getqflist({'title' : 1}).title) + + " :caddexpr + call setqflist([], 'f') + exe "caddexpr readfile('Xerr')" + call assert_equal(":caddexpr readfile('Xerr')", + \ getqflist({'title' : 1}).title) + + " :cbuffer + new Xerr + exe "cbuffer" + call assert_equal(':cbuffer (Xerr)', getqflist({'title' : 1}).title) + + " :cgetbuffer + edit Xerr + exe "cgetbuffer" + call assert_equal(':cgetbuffer (Xerr)', getqflist({'title' : 1}).title) + + " :caddbuffer + call setqflist([], 'f') + edit Xerr + exe "caddbuffer" + call assert_equal(':caddbuffer (Xerr)', getqflist({'title' : 1}).title) + + " :cfile + exe "cfile Xerr" + call assert_equal(':cfile Xerr', getqflist({'title' : 1}).title) + + " :cgetfile + exe "cgetfile Xerr" + call assert_equal(':cgetfile Xerr', getqflist({'title' : 1}).title) + + " :caddfile + call setqflist([], 'f') + exe "caddfile Xerr" + call assert_equal(':caddfile Xerr', getqflist({'title' : 1}).title) + + " :grep + set grepprg=internal + exe "grep F1 Xerr" + call assert_equal(':grep F1 Xerr', getqflist({'title' : 1}).title) + + " :grepadd + call setqflist([], 'f') + exe "grepadd F1 Xerr" + call assert_equal(':grepadd F1 Xerr', getqflist({'title' : 1}).title) + set grepprg&vim + + " :vimgrep + exe "vimgrep F1 Xerr" + call assert_equal(':vimgrep F1 Xerr', getqflist({'title' : 1}).title) + + " :vimgrepadd + call setqflist([], 'f') + exe "vimgrepadd F1 Xerr" + call assert_equal(':vimgrepadd F1 Xerr', getqflist({'title' : 1}).title) + + call setqflist(['F1:10:L10'], ' ') + call assert_equal(':setqflist()', getqflist({'title' : 1}).title) + + call setqflist([], 'f') + call setqflist(['F1:10:L10'], 'a') + call assert_equal(':setqflist()', getqflist({'title' : 1}).title) + + call setqflist([], 'f') + call setqflist(['F1:10:L10'], 'r') + call assert_equal(':setqflist()', getqflist({'title' : 1}).title) + + close + call delete('Xerr') + + call setqflist([], ' ', {'title' : 'Errors'}) + copen + call assert_equal('Errors', w:quickfix_title) + call setqflist([], 'r', {'items' : [{'filename' : 'a.c', 'lnum' : 10}]}) + call assert_equal('Errors', w:quickfix_title) + cclose + endfunc *** ../vim-8.0.1830/src/version.c 2018-05-13 15:15:39.162500689 +0200 --- src/version.c 2018-05-13 15:26:08.797743392 +0200 *************** *** 763,764 **** --- 763,766 ---- { /* Add new patch number below this line */ + /**/ + 1831, /**/ -- ROBIN: (warily) And if you get a question wrong? ARTHUR: You are cast into the Gorge of Eternal Peril. ROBIN: Oh ... wacho! "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///