Patch 8.1.2220
Problem: :cfile does not abort like other quickfix commands.
Solution: Abort when desired. Add tests for aborting. (Yegappan Lakshmanan,
closes #5121)
Files: src/quickfix.c, src/testdir/test_quickfix.vim
*** ../vim-8.1.2219/src/quickfix.c 2019-10-18 20:53:30.697741631 +0200
--- src/quickfix.c 2019-10-26 16:44:38.749911033 +0200
***************
*** 5509,5516 ****
int res;
au_name = cfile_get_auname(eap->cmdidx);
! if (au_name != NULL)
! apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, NULL, FALSE, curbuf);
enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc;
#ifdef FEAT_BROWSE
--- 5509,5522 ----
int res;
au_name = cfile_get_auname(eap->cmdidx);
! if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
! NULL, FALSE, curbuf))
! {
! #ifdef FEAT_EVAL
! if (aborting())
! return;
! #endif
! }
enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc;
#ifdef FEAT_BROWSE
*** ../vim-8.1.2219/src/testdir/test_quickfix.vim 2019-10-16 14:51:36.512685665 +0200
--- src/testdir/test_quickfix.vim 2019-10-26 16:44:38.749911033 +0200
***************
*** 2701,2707 ****
cclose
augroup! QF_Test
! endfunction
func Test_resize_from_copen()
augroup QF_Test
--- 2701,2707 ----
cclose
augroup! QF_Test
! endfunc
func Test_resize_from_copen()
augroup QF_Test
***************
*** 4304,4306 ****
--- 4304,4396 ----
call assert_fails('$' .. cmd, 'E16:')
endfor
endfunc
+
+ " Test for aborting quickfix commands using QuickFixCmdPre
+ func Xtest_qfcmd_abort(cchar)
+ call s:setup_commands(a:cchar)
+
+ call g:Xsetlist([], 'f')
+
+ " cexpr/lexpr
+ let e = ''
+ try
+ Xexpr ["F1:10:Line10", "F2:20:Line20"]
+ catch /.*/
+ let e = v:exception
+ endtry
+ call assert_equal('AbortCmd', e)
+ call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr)
+
+ " cfile/lfile
+ call writefile(["F1:10:Line10", "F2:20:Line20"], 'Xfile1')
+ let e = ''
+ try
+ Xfile Xfile1
+ catch /.*/
+ let e = v:exception
+ endtry
+ call assert_equal('AbortCmd', e)
+ call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr)
+ call delete('Xfile1')
+
+ " cgetbuffer/lgetbuffer
+ enew!
+ call append(0, ["F1:10:Line10", "F2:20:Line20"])
+ let e = ''
+ try
+ Xgetbuffer
+ catch /.*/
+ let e = v:exception
+ endtry
+ call assert_equal('AbortCmd', e)
+ call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr)
+ enew!
+
+ " vimgrep/lvimgrep
+ let e = ''
+ try
+ Xvimgrep /func/ test_quickfix.vim
+ catch /.*/
+ let e = v:exception
+ endtry
+ call assert_equal('AbortCmd', e)
+ call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr)
+
+ " helpgrep/lhelpgrep
+ let e = ''
+ try
+ Xhelpgrep quickfix
+ catch /.*/
+ let e = v:exception
+ endtry
+ call assert_equal('AbortCmd', e)
+ call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr)
+
+ " grep/lgrep
+ if has('unix')
+ let e = ''
+ try
+ silent Xgrep func test_quickfix.vim
+ catch /.*/
+ let e = v:exception
+ endtry
+ call assert_equal('AbortCmd', e)
+ call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr)
+ endif
+ endfunc
+
+ func Test_qfcmd_abort()
+ augroup QF_Test
+ au!
+ autocmd QuickFixCmdPre * throw "AbortCmd"
+ augroup END
+
+ call Xtest_qfcmd_abort('c')
+ call Xtest_qfcmd_abort('l')
+
+ augroup QF_Test
+ au!
+ augroup END
+ endfunc
+
+ " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.1.2219/src/version.c 2019-10-26 16:21:34.511468348 +0200
--- src/version.c 2019-10-26 16:47:05.513293159 +0200
***************
*** 743,744 ****
--- 743,746 ----
{ /* Add new patch number below this line */
+ /**/
+ 2220,
/**/
--
Engineers are widely recognized as superior marriage material: intelligent,
dependable, employed, honest, and handy around the house.
(Scott Adams - The Dilbert principle)
/// Bram Moolenaar -- Br...@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 ///