diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-10-26 19:19:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-26 19:19:03 -0700 |
commit | 479c01412242c11eab8bdbe62048b1351731bea2 (patch) | |
tree | 3479a65a63296bfb9f928f8368d94ea80a43792d /src | |
parent | 6d8fe9b3f40d0d3f4ddeed56f592dfd2be810f7f (diff) | |
parent | 0cf694e83e27008205b2e550a9c407a4e664750b (diff) | |
download | rneovim-479c01412242c11eab8bdbe62048b1351731bea2.tar.gz rneovim-479c01412242c11eab8bdbe62048b1351731bea2.tar.bz2 rneovim-479c01412242c11eab8bdbe62048b1351731bea2.zip |
Merge #11298 from janlazo/vim-8.1.2220
vim-patch:8.1.2220
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/quickfix.c | 11 | ||||
-rw-r--r-- | src/nvim/testdir/test_quickfix.vim | 92 |
2 files changed, 99 insertions, 4 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 52dd3c1c98..8f891751d6 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -4152,10 +4152,15 @@ void ex_cfile(exarg_T *eap) case CMD_laddfile: au_name = (char_u *)"laddfile"; break; default: break; } - if (au_name != NULL) - apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, NULL, FALSE, curbuf); - if (*eap->arg != NUL) + if (au_name != NULL + && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, NULL, false, curbuf)) { + if (aborting()) { + return; + } + } + if (*eap->arg != NUL) { set_string_option_direct((char_u *)"ef", -1, eap->arg, OPT_FREE, 0); + } char_u *enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc; diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 74f9e5b41d..6f58b0084c 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -2515,7 +2515,7 @@ func Test_file_from_copen() cclose augroup! QF_Test -endfunction +endfunc func Test_resize_from_copen() augroup QF_Test @@ -2534,6 +2534,94 @@ func Test_resize_from_copen() endtry 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 + " Tests for the quickfix buffer b:changedtick variable func Xchangedtick_tests(cchar) call s:setup_commands(a:cchar) @@ -3699,3 +3787,5 @@ func Test_viscol() set efm& call delete('Xfile1') endfunc + +" vim: shiftwidth=2 sts=2 expandtab |