Skip to content

Commit 3f347e4

Browse files
committed
patch 8.1.0259: no test for fixed quickfix issue
Problem: No test for fixed quickfix issue. Solution: Add a test. Clean up the code a bit. (Yegappan Lakshmanan)
1 parent af559d2 commit 3f347e4

3 files changed

Lines changed: 29 additions & 9 deletions

File tree

src/quickfix.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,6 @@ qf_list_empty(qf_info_T *qi, int qf_idx)
15061506
return qi->qf_lists[qf_idx].qf_count <= 0;
15071507
}
15081508

1509-
15101509
/*
15111510
* Allocate the fields used for parsing lines and populating a quickfix list.
15121511
*/
@@ -3717,7 +3716,7 @@ qf_view_result(int split)
37173716
if (IS_LL_WINDOW(curwin))
37183717
qi = GET_LOC_LIST(curwin);
37193718

3720-
if (qi == NULL || qi->qf_lists[qi->qf_curlist].qf_count == 0)
3719+
if (qf_list_empty(qi, qi->qf_curlist))
37213720
{
37223721
EMSG(_(e_quickfix));
37233722
return;
@@ -4349,7 +4348,8 @@ qf_jump_first(qf_info_T *qi, int_u save_qfid, int forceit)
43494348
if (qi->qf_lists[qi->qf_curlist].qf_id != save_qfid)
43504349
qi->qf_curlist = qf_id2nr(qi, save_qfid);
43514350

4352-
if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
4351+
// Autocommands might have cleared the list, check for it
4352+
if (!qf_list_empty(qi, qi->qf_curlist))
43534353
qf_jump(qi, 0, 0, forceit);
43544354
}
43554355

@@ -4873,10 +4873,8 @@ ex_cfile(exarg_T *eap)
48734873
// free the list.
48744874
if (res > 0 && (eap->cmdidx == CMD_cfile || eap->cmdidx == CMD_lfile)
48754875
&& qflist_valid(wp, save_qfid))
4876-
{
48774876
// display the first error
48784877
qf_jump_first(qi, save_qfid, eap->forceit);
4879-
}
48804878
}
48814879

48824880
/*
@@ -6581,10 +6579,8 @@ ex_cbuffer(exarg_T *eap)
65816579
if (res > 0 && (eap->cmdidx == CMD_cbuffer ||
65826580
eap->cmdidx == CMD_lbuffer)
65836581
&& qflist_valid(wp, save_qfid))
6584-
{
65856582
// display the first error
65866583
qf_jump_first(qi, save_qfid, eap->forceit);
6587-
}
65886584
}
65896585
}
65906586
}
@@ -6661,10 +6657,8 @@ ex_cexpr(exarg_T *eap)
66616657
if (res > 0 && (eap->cmdidx == CMD_cexpr
66626658
|| eap->cmdidx == CMD_lexpr)
66636659
&& qflist_valid(wp, save_qfid))
6664-
{
66656660
// display the first error
66666661
qf_jump_first(qi, save_qfid, eap->forceit);
6667-
}
66686662
}
66696663
else
66706664
EMSG(_("E777: String or List expected"));

src/testdir/test_quickfix.vim

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3478,6 +3478,30 @@ func Xautocmd_changelist(cchar)
34783478
call assert_equal(5, line('.'))
34793479
autocmd! QuickFixCmdPost
34803480

3481+
" Test for autocommands clearing the quickfix list before jumping to the
3482+
" first error. This should not result in an error
3483+
autocmd QuickFixCmdPost * call g:Xsetlist([], 'r')
3484+
let v:errmsg = ''
3485+
" Test for cfile/lfile
3486+
Xfile Xerr
3487+
call assert_true(v:errmsg !~# 'E42:')
3488+
" Test for cbuffer/lbuffer
3489+
edit Xerr
3490+
Xbuffer
3491+
call assert_true(v:errmsg !~# 'E42:')
3492+
" Test for cexpr/lexpr
3493+
Xexpr 'Xtestfile2:4:Line4'
3494+
call assert_true(v:errmsg !~# 'E42:')
3495+
" Test for grep/lgrep
3496+
" The grepprg may not be set on non-Unix systems
3497+
if has('unix')
3498+
silent Xgrep Line5 Xtestfile2
3499+
call assert_true(v:errmsg !~# 'E42:')
3500+
endif
3501+
" Test for vimgrep/lvimgrep
3502+
call assert_fails('silent Xvimgrep Line5 Xtestfile2', 'E480:')
3503+
autocmd! QuickFixCmdPost
3504+
34813505
call delete('Xerr')
34823506
call delete('Xtestfile1')
34833507
call delete('Xtestfile2')

src/version.c

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

795795
static int included_patches[] =
796796
{ /* Add new patch number below this line */
797+
/**/
798+
259,
797799
/**/
798800
258,
799801
/**/

0 commit comments

Comments
 (0)