@@ -24,8 +24,8 @@ func s:setup_commands(cchar)
2424 command ! -nargs =* Xgetbuffer <mods> cgetbuffer <args>
2525 command ! -nargs =* Xaddbuffer <mods> caddbuffer <args>
2626 command ! -nargs =* Xrewind <mods> crewind <args>
27- command ! -nargs =* - bang Xnext <mods> cnext <bang> <args>
28- command ! -nargs =* - bang Xprev <mods> cprev<bang> <args>
27+ command ! - count - nargs =* - bang Xnext <mods><count > cnext <bang> <args>
28+ command ! - count - nargs =* - bang Xprev <mods><count > cprev<bang> <args>
2929 command ! -nargs =* - bang Xfirst <mods> cfirst <bang> <args>
3030 command ! -nargs =* - bang Xlast <mods> clast <bang> <args>
3131 command ! -nargs =* - bang Xnfile <mods> cnfile <bang> <args>
@@ -56,8 +56,8 @@ func s:setup_commands(cchar)
5656 command ! -nargs =* Xgetbuffer <mods> lgetbuffer <args>
5757 command ! -nargs =* Xaddbuffer <mods> laddbuffer <args>
5858 command ! -nargs =* Xrewind <mods> lrewind <args>
59- command ! -nargs =* - bang Xnext <mods> lnext <bang> <args>
60- command ! -nargs =* - bang Xprev <mods> lprev<bang> <args>
59+ command ! - count - nargs =* - bang Xnext <mods><count > lnext <bang> <args>
60+ command ! - count - nargs =* - bang Xprev <mods><count > lprev<bang> <args>
6161 command ! -nargs =* - bang Xfirst <mods> lfirst <bang> <args>
6262 command ! -nargs =* - bang Xlast <mods> llast <bang> <args>
6363 command ! -nargs =* - bang Xnfile <mods> lnfile <bang> <args>
@@ -395,7 +395,9 @@ func Xtest_browse(cchar)
395395 Xgetexpr [' Xqftestfile1:5:Line5' ,
396396 \ ' Xqftestfile1:6:Line6' ,
397397 \ ' Xqftestfile2:10:Line10' ,
398- \ ' Xqftestfile2:11:Line11' ]
398+ \ ' Xqftestfile2:11:Line11' ,
399+ \ ' RegularLine1' ,
400+ \ ' RegularLine2' ]
399401
400402 Xfirst
401403 call assert_fails (' Xprev' , ' E553' )
@@ -407,6 +409,7 @@ func Xtest_browse(cchar)
407409 call assert_equal (' Xqftestfile1' , bufname (' %' ))
408410 call assert_equal (6 , line (' .' ))
409411 Xlast
412+ Xprev
410413 call assert_equal (' Xqftestfile2' , bufname (' %' ))
411414 call assert_equal (11 , line (' .' ))
412415 call assert_fails (' Xnext' , ' E553' )
@@ -415,6 +418,13 @@ func Xtest_browse(cchar)
415418 call assert_equal (' Xqftestfile1' , bufname (' %' ))
416419 call assert_equal (5 , line (' .' ))
417420
421+ 10 Xnext
422+ call assert_equal (' Xqftestfile2' , bufname (' %' ))
423+ call assert_equal (11 , line (' .' ))
424+ 10 Xprev
425+ call assert_equal (' Xqftestfile1' , bufname (' %' ))
426+ call assert_equal (5 , line (' .' ))
427+
418428 Xexpr " "
419429 call assert_fails (' Xnext' , ' E42:' )
420430
@@ -455,9 +465,30 @@ func s:test_xhelpgrep(cchar)
455465 let title_text = ' :lhelpgrep quickfix'
456466 endif
457467 call assert_true (w: quickfix_title = ~ title_text, w: quickfix_title )
468+
469+ " Jumping to a help topic should open the help window
470+ only
471+ Xnext
472+ call assert_true (&buftype == ' help' )
473+ call assert_true (winnr (' $' ) == 2 )
474+ " Jumping to the next match should reuse the help window
475+ Xnext
476+ call assert_true (&buftype == ' help' )
477+ call assert_true (winnr () == 1 )
478+ call assert_true (winnr (' $' ) == 2 )
479+ " Jumping to the next match from the quickfix window should reuse the help
480+ " window
481+ Xopen
482+ Xnext
483+ call assert_true (&buftype == ' help' )
484+ call assert_true (winnr () == 1 )
485+ call assert_true (winnr (' $' ) == 2 )
486+
458487 " This wipes out the buffer, make sure that doesn't cause trouble.
459488 Xclose
460489
490+ new | only
491+
461492 " Search for non existing help string
462493 call assert_fails (' Xhelpgrep a1b2c3' , ' E480:' )
463494endfunc
@@ -596,10 +627,7 @@ func Test_locationlist()
596627 lrewind
597628 enew
598629 lopen
599- lnext
600- lnext
601- lnext
602- lnext
630+ 4 lnext
603631 vert split
604632 wincmd L
605633 lopen
@@ -1057,6 +1085,25 @@ func Test_efm2()
10571085 call assert_equal (1 , l [4 ].valid)
10581086 call assert_equal (' unittests/dbfacadeTest.py' , bufname (l [4 ].bufnr ))
10591087
1088+ " The following sequence of commands used to crash Vim
1089+ set efm = % W% m
1090+ cgetexpr [' msg1' ]
1091+ let l = getqflist ()
1092+ call assert_equal (1 , len (l ), string (l ))
1093+ call assert_equal (' msg1' , l [0 ].text)
1094+ set efm = % C% m
1095+ lexpr ' msg2'
1096+ let l = getloclist (0 )
1097+ call assert_equal (1 , len (l ), string (l ))
1098+ call assert_equal (' msg2' , l [0 ].text)
1099+ lopen
1100+ call setqflist ([], ' r' )
1101+ caddbuf
1102+ let l = getqflist ()
1103+ call assert_equal (1 , len (l ), string (l ))
1104+ call assert_equal (' || msg2' , l [0 ].text)
1105+
1106+ new | only
10601107 let &efm = save_efm
10611108endfunc
10621109
@@ -1387,18 +1434,18 @@ func Test_switchbuf()
13871434 let winid = win_getid ()
13881435 cfirst | cnext
13891436 call assert_equal (winid, win_getid ())
1390- cnext | cnext
1437+ 2 cnext
13911438 call assert_equal (winid, win_getid ())
1392- cnext | cnext
1439+ 2 cnext
13931440 call assert_equal (winid, win_getid ())
13941441 enew
13951442
13961443 set switchbuf = useopen
13971444 cfirst | cnext
13981445 call assert_equal (file1_winid, win_getid ())
1399- cnext | cnext
1446+ 2 cnext
14001447 call assert_equal (file2_winid, win_getid ())
1401- cnext | cnext
1448+ 2 cnext
14021449 call assert_equal (file2_winid, win_getid ())
14031450
14041451 enew | only
@@ -1408,9 +1455,9 @@ func Test_switchbuf()
14081455 tabfirst
14091456 cfirst | cnext
14101457 call assert_equal (2 , tabpagenr ())
1411- cnext | cnext
1458+ 2 cnext
14121459 call assert_equal (3 , tabpagenr ())
1413- cnext | cnext
1460+ 2 cnext
14141461 call assert_equal (3 , tabpagenr ())
14151462 tabfirst | tabonly | enew
14161463
@@ -1975,3 +2022,15 @@ func Test_qf_free()
19752022 call XfreeTests (' c' )
19762023 call XfreeTests (' l' )
19772024endfunc
2025+
2026+ func Test_no_reuse_mem ()
2027+ set efm = E,% W% m ,
2028+ cgetexpr [' C' ]
2029+ set efm = % C% m
2030+ lexpr ' 0'
2031+ lopen
2032+ call setqflist ([], ' r' )
2033+ caddbuf
2034+
2035+ set efm &
2036+ endfunc
0 commit comments