Skip to content

Commit 4cde86c

Browse files
committed
patch 8.1.0165: :clist output can be very long
Problem: :clist output can be very long. Solution: Support filtering :clist entries. (Yegappan Lakshmanan)
1 parent fd35811 commit 4cde86c

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

src/quickfix.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3051,6 +3051,7 @@ qf_list(exarg_T *eap)
30513051
int qfFileAttr;
30523052
int qfSepAttr;
30533053
int qfLineAttr;
3054+
int filter_entry;
30543055
int all = eap->forceit; /* if not :cl!, only show
30553056
recognised errors */
30563057
qf_info_T *qi = &ql_info;
@@ -3120,7 +3121,6 @@ qf_list(exarg_T *eap)
31203121
{
31213122
if ((qfp->qf_valid || all) && idx1 <= i && i <= idx2)
31223123
{
3123-
msg_putchar('\n');
31243124
if (got_int)
31253125
break;
31263126

@@ -3141,6 +3141,20 @@ qf_list(exarg_T *eap)
31413141
vim_snprintf((char *)IObuff, IOSIZE, "%2d %s",
31423142
i, (char *)fname);
31433143
}
3144+
3145+
// Support for filtering entries using :filter /pat/ clist
3146+
filter_entry = 1;
3147+
if (qfp->qf_module != NULL && *qfp->qf_module != NUL)
3148+
filter_entry &= message_filtered(qfp->qf_module);
3149+
if (fname != NULL)
3150+
filter_entry &= message_filtered(fname);
3151+
if (qfp->qf_pattern != NULL)
3152+
filter_entry &= message_filtered(qfp->qf_pattern);
3153+
filter_entry &= message_filtered(qfp->qf_text);
3154+
if (filter_entry)
3155+
goto next_entry;
3156+
3157+
msg_putchar('\n');
31443158
msg_outtrans_attr(IObuff, i == qi->qf_lists[qi->qf_curlist].qf_index
31453159
? HL_ATTR(HLF_QFL) : qfFileAttr);
31463160

@@ -3175,6 +3189,7 @@ qf_list(exarg_T *eap)
31753189
out_flush(); /* show one line at a time */
31763190
}
31773191

3192+
next_entry:
31783193
qfp = qfp->qf_next;
31793194
if (qfp == NULL)
31803195
break;
@@ -4186,6 +4201,7 @@ ex_make(exarg_T *eap)
41864201
}
41874202
if (res >= 0)
41884203
qf_list_changed(qi, qi->qf_curlist);
4204+
41894205
// Remember the current quickfix list identifier, so that we can
41904206
// check for autocommands changing the current quickfix list.
41914207
save_qfid = qi->qf_lists[qi->qf_curlist].qf_id;

src/testdir/test_quickfix.vim

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3487,3 +3487,20 @@ func Test_autocmd_changelist()
34873487
call Xautocmd_changelist('c')
34883488
call Xautocmd_changelist('l')
34893489
endfunc
3490+
3491+
" Tests for the ':filter /pat/ clist' command
3492+
func Test_filter_clist()
3493+
cexpr ['Xfile1:10:10:Line 10', 'Xfile2:15:15:Line 15']
3494+
call assert_equal([' 2 Xfile2:15 col 15: Line 15'],
3495+
\ split(execute('filter /Line 15/ clist'), "\n"))
3496+
call assert_equal([' 1 Xfile1:10 col 10: Line 10'],
3497+
\ split(execute('filter /Xfile1/ clist'), "\n"))
3498+
call assert_equal([], split(execute('filter /abc/ clist'), "\n"))
3499+
3500+
call setqflist([{'module' : 'abc', 'pattern' : 'pat1'},
3501+
\ {'module' : 'pqr', 'pattern' : 'pat2'}], ' ')
3502+
call assert_equal([' 2 pqr:pat2: '],
3503+
\ split(execute('filter /pqr/ clist'), "\n"))
3504+
call assert_equal([' 1 abc:pat1: '],
3505+
\ split(execute('filter /pat1/ clist'), "\n"))
3506+
endfunc

src/version.c

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

790790
static int included_patches[] =
791791
{ /* Add new patch number below this line */
792+
/**/
793+
165,
792794
/**/
793795
164,
794796
/**/

0 commit comments

Comments
 (0)