Mercurial > vim
comparison src/testdir/test_quickfix.vim @ 18452:0ac9e720a56e v8.1.2220
patch 8.1.2220: :cfile does not abort like other quickfix commands
Commit: https://github.com/vim/vim/commit/6a0cc916bd3cd6c2fd88b2972c92ade225603229
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Oct 26 16:48:44 2019 +0200
patch 8.1.2220: :cfile does not abort like other quickfix commands
Problem: :cfile does not abort like other quickfix commands.
Solution: Abort when desired. Add tests for aborting. (Yegappan Lakshmanan,
closes #5121)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 26 Oct 2019 17:00:03 +0200 |
parents | 4cc8a1a134fc |
children | dfa87465287e |
comparison
equal
deleted
inserted
replaced
18451:291de929eee2 | 18452:0ac9e720a56e |
---|---|
2699 au! | 2699 au! |
2700 augroup END | 2700 augroup END |
2701 cclose | 2701 cclose |
2702 | 2702 |
2703 augroup! QF_Test | 2703 augroup! QF_Test |
2704 endfunction | 2704 endfunc |
2705 | 2705 |
2706 func Test_resize_from_copen() | 2706 func Test_resize_from_copen() |
2707 augroup QF_Test | 2707 augroup QF_Test |
2708 au! | 2708 au! |
2709 au FileType qf resize 5 | 2709 au FileType qf resize 5 |
4302 call assert_fails('.' .. cmd, 'E16:') | 4302 call assert_fails('.' .. cmd, 'E16:') |
4303 call assert_fails('%' .. cmd, 'E16:') | 4303 call assert_fails('%' .. cmd, 'E16:') |
4304 call assert_fails('$' .. cmd, 'E16:') | 4304 call assert_fails('$' .. cmd, 'E16:') |
4305 endfor | 4305 endfor |
4306 endfunc | 4306 endfunc |
4307 | |
4308 " Test for aborting quickfix commands using QuickFixCmdPre | |
4309 func Xtest_qfcmd_abort(cchar) | |
4310 call s:setup_commands(a:cchar) | |
4311 | |
4312 call g:Xsetlist([], 'f') | |
4313 | |
4314 " cexpr/lexpr | |
4315 let e = '' | |
4316 try | |
4317 Xexpr ["F1:10:Line10", "F2:20:Line20"] | |
4318 catch /.*/ | |
4319 let e = v:exception | |
4320 endtry | |
4321 call assert_equal('AbortCmd', e) | |
4322 call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr) | |
4323 | |
4324 " cfile/lfile | |
4325 call writefile(["F1:10:Line10", "F2:20:Line20"], 'Xfile1') | |
4326 let e = '' | |
4327 try | |
4328 Xfile Xfile1 | |
4329 catch /.*/ | |
4330 let e = v:exception | |
4331 endtry | |
4332 call assert_equal('AbortCmd', e) | |
4333 call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr) | |
4334 call delete('Xfile1') | |
4335 | |
4336 " cgetbuffer/lgetbuffer | |
4337 enew! | |
4338 call append(0, ["F1:10:Line10", "F2:20:Line20"]) | |
4339 let e = '' | |
4340 try | |
4341 Xgetbuffer | |
4342 catch /.*/ | |
4343 let e = v:exception | |
4344 endtry | |
4345 call assert_equal('AbortCmd', e) | |
4346 call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr) | |
4347 enew! | |
4348 | |
4349 " vimgrep/lvimgrep | |
4350 let e = '' | |
4351 try | |
4352 Xvimgrep /func/ test_quickfix.vim | |
4353 catch /.*/ | |
4354 let e = v:exception | |
4355 endtry | |
4356 call assert_equal('AbortCmd', e) | |
4357 call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr) | |
4358 | |
4359 " helpgrep/lhelpgrep | |
4360 let e = '' | |
4361 try | |
4362 Xhelpgrep quickfix | |
4363 catch /.*/ | |
4364 let e = v:exception | |
4365 endtry | |
4366 call assert_equal('AbortCmd', e) | |
4367 call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr) | |
4368 | |
4369 " grep/lgrep | |
4370 if has('unix') | |
4371 let e = '' | |
4372 try | |
4373 silent Xgrep func test_quickfix.vim | |
4374 catch /.*/ | |
4375 let e = v:exception | |
4376 endtry | |
4377 call assert_equal('AbortCmd', e) | |
4378 call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr) | |
4379 endif | |
4380 endfunc | |
4381 | |
4382 func Test_qfcmd_abort() | |
4383 augroup QF_Test | |
4384 au! | |
4385 autocmd QuickFixCmdPre * throw "AbortCmd" | |
4386 augroup END | |
4387 | |
4388 call Xtest_qfcmd_abort('c') | |
4389 call Xtest_qfcmd_abort('l') | |
4390 | |
4391 augroup QF_Test | |
4392 au! | |
4393 augroup END | |
4394 endfunc | |
4395 | |
4396 " vim: shiftwidth=2 sts=2 expandtab |