Mercurial > vim
comparison src/testdir/test_quickfix.vim @ 12084:69ce6b3f0834 v8.0.0922
patch 8.0.0922: quickfix list always added after current one
commit https://github.com/vim/vim/commit/55b6926450d75788dada3ff44a35e328224df758
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Aug 13 13:42:01 2017 +0200
patch 8.0.0922: quickfix list always added after current one
Problem: Quickfix list always added after current one.
Solution: Make it possible to add a quickfix list after the last one.
(Yegappan Lakshmanan)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 13 Aug 2017 13:45:04 +0200 |
parents | ebd313aa5a6c |
children | 3d0e042ec13c |
comparison
equal
deleted
inserted
replaced
12083:23073dd342fe | 12084:69ce6b3f0834 |
---|---|
9 func s:setup_commands(cchar) | 9 func s:setup_commands(cchar) |
10 if a:cchar == 'c' | 10 if a:cchar == 'c' |
11 command! -nargs=* -bang Xlist <mods>clist<bang> <args> | 11 command! -nargs=* -bang Xlist <mods>clist<bang> <args> |
12 command! -nargs=* Xgetexpr <mods>cgetexpr <args> | 12 command! -nargs=* Xgetexpr <mods>cgetexpr <args> |
13 command! -nargs=* Xaddexpr <mods>caddexpr <args> | 13 command! -nargs=* Xaddexpr <mods>caddexpr <args> |
14 command! -nargs=* Xolder <mods>colder <args> | 14 command! -nargs=* -count Xolder <mods><count>colder <args> |
15 command! -nargs=* Xnewer <mods>cnewer <args> | 15 command! -nargs=* Xnewer <mods>cnewer <args> |
16 command! -nargs=* Xopen <mods>copen <args> | 16 command! -nargs=* Xopen <mods>copen <args> |
17 command! -nargs=* Xwindow <mods>cwindow <args> | 17 command! -nargs=* Xwindow <mods>cwindow <args> |
18 command! -nargs=* Xbottom <mods>cbottom <args> | 18 command! -nargs=* Xbottom <mods>cbottom <args> |
19 command! -nargs=* Xclose <mods>cclose <args> | 19 command! -nargs=* Xclose <mods>cclose <args> |
41 call setqflist([], 'f') | 41 call setqflist([], 'f') |
42 else | 42 else |
43 command! -nargs=* -bang Xlist <mods>llist<bang> <args> | 43 command! -nargs=* -bang Xlist <mods>llist<bang> <args> |
44 command! -nargs=* Xgetexpr <mods>lgetexpr <args> | 44 command! -nargs=* Xgetexpr <mods>lgetexpr <args> |
45 command! -nargs=* Xaddexpr <mods>laddexpr <args> | 45 command! -nargs=* Xaddexpr <mods>laddexpr <args> |
46 command! -nargs=* Xolder <mods>lolder <args> | 46 command! -nargs=* -count Xolder <mods><count>lolder <args> |
47 command! -nargs=* Xnewer <mods>lnewer <args> | 47 command! -nargs=* Xnewer <mods>lnewer <args> |
48 command! -nargs=* Xopen <mods>lopen <args> | 48 command! -nargs=* Xopen <mods>lopen <args> |
49 command! -nargs=* Xwindow <mods>lwindow <args> | 49 command! -nargs=* Xwindow <mods>lwindow <args> |
50 command! -nargs=* Xbottom <mods>lbottom <args> | 50 command! -nargs=* Xbottom <mods>lbottom <args> |
51 command! -nargs=* Xclose <mods>lclose <args> | 51 command! -nargs=* Xclose <mods>lclose <args> |
1743 | 1743 |
1744 call g:Xsetlist([], ' ', {'title' : 'N3'}) | 1744 call g:Xsetlist([], ' ', {'title' : 'N3'}) |
1745 call assert_equal('N2', g:Xgetlist({'nr':2, 'title':1}).title) | 1745 call assert_equal('N2', g:Xgetlist({'nr':2, 'title':1}).title) |
1746 | 1746 |
1747 " Changing the title of an earlier quickfix list | 1747 " Changing the title of an earlier quickfix list |
1748 call g:Xsetlist([], ' ', {'title' : 'NewTitle', 'nr' : 2}) | 1748 call g:Xsetlist([], 'r', {'title' : 'NewTitle', 'nr' : 2}) |
1749 call assert_equal('NewTitle', g:Xgetlist({'nr':2, 'title':1}).title) | 1749 call assert_equal('NewTitle', g:Xgetlist({'nr':2, 'title':1}).title) |
1750 | 1750 |
1751 " Changing the title of an invalid quickfix list | 1751 " Changing the title of an invalid quickfix list |
1752 call assert_equal(-1, g:Xsetlist([], ' ', | 1752 call assert_equal(-1, g:Xsetlist([], ' ', |
1753 \ {'title' : 'SomeTitle', 'nr' : 99})) | 1753 \ {'title' : 'SomeTitle', 'nr' : 99})) |
1810 " Test for changing the context of previous quickfix lists | 1810 " Test for changing the context of previous quickfix lists |
1811 call g:Xsetlist([], 'f') | 1811 call g:Xsetlist([], 'f') |
1812 Xexpr "One" | 1812 Xexpr "One" |
1813 Xexpr "Two" | 1813 Xexpr "Two" |
1814 Xexpr "Three" | 1814 Xexpr "Three" |
1815 call g:Xsetlist([], ' ', {'context' : [1], 'nr' : 1}) | 1815 call g:Xsetlist([], 'r', {'context' : [1], 'nr' : 1}) |
1816 call g:Xsetlist([], ' ', {'context' : [2], 'nr' : 2}) | 1816 call g:Xsetlist([], 'a', {'context' : [2], 'nr' : 2}) |
1817 " Also, check for setting the context using quickfix list number zero. | 1817 " Also, check for setting the context using quickfix list number zero. |
1818 call g:Xsetlist([], ' ', {'context' : [3], 'nr' : 0}) | 1818 call g:Xsetlist([], 'r', {'context' : [3], 'nr' : 0}) |
1819 call test_garbagecollect_now() | 1819 call test_garbagecollect_now() |
1820 let l = g:Xgetlist({'nr' : 1, 'context' : 1}) | 1820 let l = g:Xgetlist({'nr' : 1, 'context' : 1}) |
1821 call assert_equal([1], l.context) | 1821 call assert_equal([1], l.context) |
1822 let l = g:Xgetlist({'nr' : 2, 'context' : 1}) | 1822 let l = g:Xgetlist({'nr' : 2, 'context' : 1}) |
1823 call assert_equal([2], l.context) | 1823 call assert_equal([2], l.context) |
2431 call assert_equal(3, winnr('$')) | 2431 call assert_equal(3, winnr('$')) |
2432 call assert_true(len(getloclist(1)) != 0) | 2432 call assert_true(len(getloclist(1)) != 0) |
2433 call assert_true(len(getloclist(2)) != 0) | 2433 call assert_true(len(getloclist(2)) != 0) |
2434 new | only | 2434 new | only |
2435 endfunc | 2435 endfunc |
2436 | |
2437 " Tests for adding new quickfix lists using setqflist() | |
2438 func XaddQf_tests(cchar) | |
2439 call s:setup_commands(a:cchar) | |
2440 | |
2441 " Create a new list using ' ' for action | |
2442 call g:Xsetlist([], 'f') | |
2443 call g:Xsetlist([], ' ', {'title' : 'Test1'}) | |
2444 let l = g:Xgetlist({'nr' : '$', 'all' : 1}) | |
2445 call assert_equal(1, l.nr) | |
2446 call assert_equal('Test1', l.title) | |
2447 | |
2448 " Create a new list using ' ' for action and '$' for 'nr' | |
2449 call g:Xsetlist([], 'f') | |
2450 call g:Xsetlist([], ' ', {'title' : 'Test2', 'nr' : '$'}) | |
2451 let l = g:Xgetlist({'nr' : '$', 'all' : 1}) | |
2452 call assert_equal(1, l.nr) | |
2453 call assert_equal('Test2', l.title) | |
2454 | |
2455 " Create a new list using 'a' for action | |
2456 call g:Xsetlist([], 'f') | |
2457 call g:Xsetlist([], 'a', {'title' : 'Test3'}) | |
2458 let l = g:Xgetlist({'nr' : '$', 'all' : 1}) | |
2459 call assert_equal(1, l.nr) | |
2460 call assert_equal('Test3', l.title) | |
2461 | |
2462 " Create a new list using 'a' for action and '$' for 'nr' | |
2463 call g:Xsetlist([], 'f') | |
2464 call g:Xsetlist([], 'a', {'title' : 'Test3', 'nr' : '$'}) | |
2465 call g:Xsetlist([], 'a', {'title' : 'Test4'}) | |
2466 let l = g:Xgetlist({'nr' : '$', 'all' : 1}) | |
2467 call assert_equal(1, l.nr) | |
2468 call assert_equal('Test4', l.title) | |
2469 | |
2470 " Adding a quickfix list should remove all the lists following the current | |
2471 " list. | |
2472 Xexpr "" | Xexpr "" | Xexpr "" | |
2473 silent! 10Xolder | |
2474 call g:Xsetlist([], ' ', {'title' : 'Test5'}) | |
2475 let l = g:Xgetlist({'nr' : '$', 'all' : 1}) | |
2476 call assert_equal(2, l.nr) | |
2477 call assert_equal('Test5', l.title) | |
2478 | |
2479 " Add a quickfix list using '$' as the list number. | |
2480 let lastqf = g:Xgetlist({'nr':'$'}).nr | |
2481 silent! 99Xolder | |
2482 call g:Xsetlist([], ' ', {'nr' : '$', 'title' : 'Test6'}) | |
2483 let l = g:Xgetlist({'nr' : '$', 'all' : 1}) | |
2484 call assert_equal(lastqf + 1, l.nr) | |
2485 call assert_equal('Test6', l.title) | |
2486 | |
2487 " Add a quickfix list using 'nr' set to one more than the quickfix | |
2488 " list size. | |
2489 let lastqf = g:Xgetlist({'nr':'$'}).nr | |
2490 silent! 99Xolder | |
2491 call g:Xsetlist([], ' ', {'nr' : lastqf + 1, 'title' : 'Test7'}) | |
2492 let l = g:Xgetlist({'nr' : '$', 'all' : 1}) | |
2493 call assert_equal(lastqf + 1, l.nr) | |
2494 call assert_equal('Test7', l.title) | |
2495 | |
2496 " Add a quickfix list to a stack with 10 lists using 'nr' set to '$' | |
2497 exe repeat('Xexpr "" |', 9) . 'Xexpr ""' | |
2498 silent! 99Xolder | |
2499 call g:Xsetlist([], ' ', {'nr' : '$', 'title' : 'Test8'}) | |
2500 let l = g:Xgetlist({'nr' : '$', 'all' : 1}) | |
2501 call assert_equal(10, l.nr) | |
2502 call assert_equal('Test8', l.title) | |
2503 | |
2504 " Add a quickfix list using 'nr' set to a value greater than 10 | |
2505 call assert_equal(-1, g:Xsetlist([], ' ', {'nr' : 12, 'title' : 'Test9'})) | |
2506 | |
2507 " Try adding a quickfix list with 'nr' set to a value greater than the | |
2508 " quickfix list size but less than 10. | |
2509 call g:Xsetlist([], 'f') | |
2510 Xexpr "" | Xexpr "" | Xexpr "" | |
2511 silent! 99Xolder | |
2512 call assert_equal(-1, g:Xsetlist([], ' ', {'nr' : 8, 'title' : 'Test10'})) | |
2513 | |
2514 " Add a quickfix list using 'nr' set to a some string or list | |
2515 call assert_equal(-1, g:Xsetlist([], ' ', {'nr' : [1,2], 'title' : 'Test11'})) | |
2516 endfunc | |
2517 | |
2518 func Test_add_qf() | |
2519 call XaddQf_tests('c') | |
2520 call XaddQf_tests('l') | |
2521 endfunc |