Skip to content

Commit 99895ea

Browse files
committed
patch 8.0.0574: get only one quickfix list after :caddbuf
Problem: Get only one quickfix list after :caddbuf. Solution: Reset qf_multiline. (Yegappan Lakshmanan)
1 parent 91b6e45 commit 99895ea

File tree

3 files changed

+83
-15
lines changed

3 files changed

+83
-15
lines changed

src/quickfix.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2750,12 +2750,18 @@ qf_free(qf_info_T *qi, int idx)
27502750
vim_free(qi->qf_lists[idx].qf_title);
27512751
qi->qf_lists[idx].qf_title = NULL;
27522752
qi->qf_lists[idx].qf_index = 0;
2753+
qi->qf_lists[idx].qf_start = NULL;
27532754
qi->qf_lists[idx].qf_last = NULL;
2755+
qi->qf_lists[idx].qf_ptr = NULL;
2756+
qi->qf_lists[idx].qf_nonevalid = TRUE;
27542757

27552758
qf_clean_dir_stack(&qi->qf_dir_stack);
27562759
qi->qf_directory = NULL;
27572760
qf_clean_dir_stack(&qi->qf_file_stack);
27582761
qi->qf_currfile = NULL;
2762+
qi->qf_multiline = FALSE;
2763+
qi->qf_multiignore = FALSE;
2764+
qi->qf_multiscan = FALSE;
27592765
}
27602766

27612767
/*
@@ -4923,6 +4929,7 @@ qf_free_stack(win_T *wp, qf_info_T *qi)
49234929
/* If the location list window is open, then create a new empty
49244930
* location list */
49254931
qf_info_T *new_ll = ll_new_list();
4932+
49264933
orig_wp->w_llist_ref = new_ll;
49274934
if (llwin != NULL)
49284935
{

src/testdir/test_quickfix.vim

Lines changed: 74 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
10Xnext
422+
call assert_equal('Xqftestfile2', bufname('%'))
423+
call assert_equal(11, line('.'))
424+
10Xprev
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:')
463494
endfunc
@@ -596,10 +627,7 @@ func Test_locationlist()
596627
lrewind
597628
enew
598629
lopen
599-
lnext
600-
lnext
601-
lnext
602-
lnext
630+
4lnext
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
10611108
endfunc
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+
2cnext
13911438
call assert_equal(winid, win_getid())
1392-
cnext | cnext
1439+
2cnext
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+
2cnext
14001447
call assert_equal(file2_winid, win_getid())
1401-
cnext | cnext
1448+
2cnext
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+
2cnext
14121459
call assert_equal(3, tabpagenr())
1413-
cnext | cnext
1460+
2cnext
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')
19772024
endfunc
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

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
574,
767769
/**/
768770
573,
769771
/**/

0 commit comments

Comments
 (0)