summaryrefslogtreecommitdiff
path: root/src/testdir/test_quickfix.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-10-26 16:48:44 +0200
committerBram Moolenaar <Bram@vim.org>2019-10-26 16:48:44 +0200
commit6a0cc916bd3cd6c2fd88b2972c92ade225603229 (patch)
tree61d7a66bccf78d9a0a62b316060f3e4896291f5f /src/testdir/test_quickfix.vim
parent28ed4dfe1f80905fb399c2cde31ace5ee14d8c67 (diff)
downloadvim-git-6a0cc916bd3cd6c2fd88b2972c92ade225603229.tar.gz
patch 8.1.2220: :cfile does not abort like other quickfix commandsv8.1.2220
Problem: :cfile does not abort like other quickfix commands. Solution: Abort when desired. Add tests for aborting. (Yegappan Lakshmanan, closes #5121)
Diffstat (limited to 'src/testdir/test_quickfix.vim')
-rw-r--r--src/testdir/test_quickfix.vim92
1 files changed, 91 insertions, 1 deletions
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index 84cdb6c91..f3f391cf6 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -2701,7 +2701,7 @@ func Test_file_from_copen()
cclose
augroup! QF_Test
-endfunction
+endfunc
func Test_resize_from_copen()
augroup QF_Test
@@ -4304,3 +4304,93 @@ func Test_quickfix_count()
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