To: vim_dev@googlegroups.com Subject: Patch 8.0.1353 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1353 Problem: QuickFixCmdPost is not used consistently. Solution: Invoke QuickFixCmdPost consistently after QuickFixCmdPre. (Yegappan Lakshmanan, closes #2377) Files: src/quickfix.c, src/testdir/test_quickfix.vim *** ../vim-8.0.1352/src/quickfix.c 2017-11-23 22:05:41.156900903 +0100 --- src/quickfix.c 2017-11-28 17:24:02.988551861 +0100 *************** *** 4055,4060 **** --- 4055,4061 ---- #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,4129 **** * :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)) ! { #ifdef FEAT_AUTOCMD ! if (au_name != NULL) ! apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf); #endif 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 - } } /* --- 4103,4120 ---- * :caddfile adds to an existing quickfix list. If there is no * 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); #ifdef FEAT_AUTOCMD ! 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 */ } } /* *************** *** 5450,5455 **** --- 5441,5447 ---- #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,5528 **** qf_title = IObuff; } ! if (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) ! { #ifdef FEAT_AUTOCMD ! 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 */ ! } } } } --- 5501,5519 ---- qf_title = IObuff; } ! 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); #ifdef FEAT_AUTOCMD ! if (au_name != NULL) ! apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, ! curbuf->b_fname, TRUE, curbuf); ! #endif ! if (res > 0 && (eap->cmdidx == CMD_cbuffer || ! eap->cmdidx == CMD_lbuffer)) ! qf_jump(qi, 0, 0, eap->forceit); /* display first error */ } } } *************** *** 5540,5545 **** --- 5531,5537 ---- #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,5597 **** 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, (eap->cmdidx != CMD_caddexpr && eap->cmdidx != CMD_laddexpr), (linenr_T)0, (linenr_T)0, *eap->cmdlinep, ! NULL) > 0) ! { #ifdef FEAT_AUTOCMD ! 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 */ ! } } else EMSG(_("E777: String or List expected")); --- 5570,5588 ---- if ((tv->v_type == VAR_STRING && tv->vval.v_string != NULL) || (tv->v_type == VAR_LIST && tv->vval.v_list != NULL)) { ! 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); #ifdef FEAT_AUTOCMD ! if (au_name != NULL) ! apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, ! curbuf->b_fname, TRUE, curbuf); ! #endif ! 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")); *** ../vim-8.0.1352/src/testdir/test_quickfix.vim 2017-10-27 00:54:59.146125099 +0200 --- src/testdir/test_quickfix.vim 2017-11-28 17:24:02.992551838 +0100 *************** *** 1966,1991 **** cexpr "F1:10:Line 10" caddexpr "F1:20:Line 20" cgetexpr "F1:30:Line 30" ! enew! | call append(0, "F2:10:Line 10") ! cbuffer! ! enew! | call append(0, "F2:20:Line 20") ! cgetbuffer ! enew! | call append(0, "F2:30:Line 30") ! caddbuffer ! let l = ['precexpr', \ 'postcexpr', \ 'precaddexpr', \ 'postcaddexpr', \ 'precgetexpr', \ 'postcgetexpr', ! \ 'precbuffer', \ 'postcbuffer', \ 'precgetbuffer', \ 'postcgetbuffer', \ 'precaddbuffer', ! \ 'postcaddbuffer'] call assert_equal(l, g:acmds) endfunc func Test_Autocmd_Exception() --- 1966,2101 ---- cexpr "F1:10:Line 10" caddexpr "F1:20:Line 20" cgetexpr "F1:30:Line 30" ! cexpr "" ! caddexpr "" ! cgetexpr "" ! silent! cexpr non_existing_func() ! silent! caddexpr non_existing_func() ! silent! cgetexpr non_existing_func() let l = ['precexpr', \ 'postcexpr', \ 'precaddexpr', \ 'postcaddexpr', \ 'precgetexpr', \ 'postcgetexpr', ! \ 'precexpr', ! \ 'postcexpr', ! \ 'precaddexpr', ! \ 'postcaddexpr', ! \ 'precgetexpr', ! \ 'postcgetexpr', ! \ 'precexpr', ! \ 'precaddexpr', ! \ 'precgetexpr'] ! call assert_equal(l, g:acmds) ! ! let g:acmds = [] ! enew! | call append(0, "F2:10:Line 10") ! cbuffer! ! enew! | call append(0, "F2:20:Line 20") ! cgetbuffer ! enew! | call append(0, "F2:30:Line 30") ! caddbuffer ! new ! let bnum = bufnr('%') ! bunload ! exe 'silent! cbuffer! ' . bnum ! exe 'silent! cgetbuffer ' . bnum ! exe 'silent! caddbuffer ' . bnum ! enew! ! let l = ['precbuffer', \ 'postcbuffer', \ 'precgetbuffer', \ 'postcgetbuffer', \ 'precaddbuffer', ! \ 'postcaddbuffer', ! \ 'precbuffer', ! \ 'precgetbuffer', ! \ 'precaddbuffer'] ! call assert_equal(l, g:acmds) ! ! call writefile(['Xtest:1:Line1'], 'Xtest') ! call writefile([], 'Xempty') ! let g:acmds = [] ! cfile Xtest ! caddfile Xtest ! cgetfile Xtest ! cfile Xempty ! caddfile Xempty ! cgetfile Xempty ! silent! cfile do_not_exist ! silent! caddfile do_not_exist ! silent! cgetfile do_not_exist ! let l = ['precfile', ! \ 'postcfile', ! \ 'precaddfile', ! \ 'postcaddfile', ! \ 'precgetfile', ! \ 'postcgetfile', ! \ 'precfile', ! \ 'postcfile', ! \ 'precaddfile', ! \ 'postcaddfile', ! \ 'precgetfile', ! \ 'postcgetfile', ! \ 'precfile', ! \ 'postcfile', ! \ 'precaddfile', ! \ 'postcaddfile', ! \ 'precgetfile', ! \ 'postcgetfile'] call assert_equal(l, g:acmds) + + let g:acmds = [] + helpgrep quickfix + silent! helpgrep non_existing_help_topic + vimgrep test Xtest + vimgrepadd test Xtest + silent! vimgrep non_existing_test Xtest + silent! vimgrepadd non_existing_test Xtest + set makeprg= + silent! make + set makeprg& + let l = ['prehelpgrep', + \ 'posthelpgrep', + \ 'prehelpgrep', + \ 'posthelpgrep', + \ 'previmgrep', + \ 'postvimgrep', + \ 'previmgrepadd', + \ 'postvimgrepadd', + \ 'previmgrep', + \ 'postvimgrep', + \ 'previmgrepadd', + \ 'postvimgrepadd', + \ 'premake', + \ 'postmake'] + call assert_equal(l, g:acmds) + + if has('unix') + " Run this test only on Unix-like systems. The grepprg may not be set on + " non-Unix systems. + " The following lines are used for the grep test. Don't remove. + " Grep_Autocmd_Text: Match 1 + " GrepAdd_Autocmd_Text: Match 2 + let g:acmds = [] + silent grep Grep_Autocmd_Text test_quickfix.vim + silent grepadd GrepAdd_Autocmd_Text test_quickfix.vim + silent grep abc123def Xtest + silent grepadd abc123def Xtest + let l = ['pregrep', + \ 'postgrep', + \ 'pregrepadd', + \ 'postgrepadd', + \ 'pregrep', + \ 'postgrep', + \ 'pregrepadd', + \ 'postgrepadd'] + call assert_equal(l, g:acmds) + endif + + call delete('Xtest') + call delete('Xempty') endfunc func Test_Autocmd_Exception() *** ../vim-8.0.1352/src/version.c 2017-11-28 14:18:51.093377778 +0100 --- src/version.c 2017-11-28 17:25:35.312024490 +0100 *************** *** 773,774 **** --- 773,776 ---- { /* Add new patch number below this line */ + /**/ + 1353, /**/ -- hundred-and-one symptoms of being an internet addict: 45. You buy a Captain Kirk chair with a built-in keyboard and mouse. /// 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 ///