mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.1.0165: :clist output can be very long
Problem: :clist output can be very long. Solution: Support filtering :clist entries. (Yegappan Lakshmanan)
This commit is contained in:
parent
fd35811ca5
commit
4cde86c2ef
@ -3051,6 +3051,7 @@ qf_list(exarg_T *eap)
|
|||||||
int qfFileAttr;
|
int qfFileAttr;
|
||||||
int qfSepAttr;
|
int qfSepAttr;
|
||||||
int qfLineAttr;
|
int qfLineAttr;
|
||||||
|
int filter_entry;
|
||||||
int all = eap->forceit; /* if not :cl!, only show
|
int all = eap->forceit; /* if not :cl!, only show
|
||||||
recognised errors */
|
recognised errors */
|
||||||
qf_info_T *qi = &ql_info;
|
qf_info_T *qi = &ql_info;
|
||||||
@ -3120,7 +3121,6 @@ qf_list(exarg_T *eap)
|
|||||||
{
|
{
|
||||||
if ((qfp->qf_valid || all) && idx1 <= i && i <= idx2)
|
if ((qfp->qf_valid || all) && idx1 <= i && i <= idx2)
|
||||||
{
|
{
|
||||||
msg_putchar('\n');
|
|
||||||
if (got_int)
|
if (got_int)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -3141,6 +3141,20 @@ qf_list(exarg_T *eap)
|
|||||||
vim_snprintf((char *)IObuff, IOSIZE, "%2d %s",
|
vim_snprintf((char *)IObuff, IOSIZE, "%2d %s",
|
||||||
i, (char *)fname);
|
i, (char *)fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Support for filtering entries using :filter /pat/ clist
|
||||||
|
filter_entry = 1;
|
||||||
|
if (qfp->qf_module != NULL && *qfp->qf_module != NUL)
|
||||||
|
filter_entry &= message_filtered(qfp->qf_module);
|
||||||
|
if (fname != NULL)
|
||||||
|
filter_entry &= message_filtered(fname);
|
||||||
|
if (qfp->qf_pattern != NULL)
|
||||||
|
filter_entry &= message_filtered(qfp->qf_pattern);
|
||||||
|
filter_entry &= message_filtered(qfp->qf_text);
|
||||||
|
if (filter_entry)
|
||||||
|
goto next_entry;
|
||||||
|
|
||||||
|
msg_putchar('\n');
|
||||||
msg_outtrans_attr(IObuff, i == qi->qf_lists[qi->qf_curlist].qf_index
|
msg_outtrans_attr(IObuff, i == qi->qf_lists[qi->qf_curlist].qf_index
|
||||||
? HL_ATTR(HLF_QFL) : qfFileAttr);
|
? HL_ATTR(HLF_QFL) : qfFileAttr);
|
||||||
|
|
||||||
@ -3175,6 +3189,7 @@ qf_list(exarg_T *eap)
|
|||||||
out_flush(); /* show one line at a time */
|
out_flush(); /* show one line at a time */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
next_entry:
|
||||||
qfp = qfp->qf_next;
|
qfp = qfp->qf_next;
|
||||||
if (qfp == NULL)
|
if (qfp == NULL)
|
||||||
break;
|
break;
|
||||||
@ -4186,6 +4201,7 @@ ex_make(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
if (res >= 0)
|
if (res >= 0)
|
||||||
qf_list_changed(qi, qi->qf_curlist);
|
qf_list_changed(qi, qi->qf_curlist);
|
||||||
|
|
||||||
// Remember the current quickfix list identifier, so that we can
|
// Remember the current quickfix list identifier, so that we can
|
||||||
// check for autocommands changing the current quickfix list.
|
// check for autocommands changing the current quickfix list.
|
||||||
save_qfid = qi->qf_lists[qi->qf_curlist].qf_id;
|
save_qfid = qi->qf_lists[qi->qf_curlist].qf_id;
|
||||||
|
@ -3487,3 +3487,20 @@ func Test_autocmd_changelist()
|
|||||||
call Xautocmd_changelist('c')
|
call Xautocmd_changelist('c')
|
||||||
call Xautocmd_changelist('l')
|
call Xautocmd_changelist('l')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Tests for the ':filter /pat/ clist' command
|
||||||
|
func Test_filter_clist()
|
||||||
|
cexpr ['Xfile1:10:10:Line 10', 'Xfile2:15:15:Line 15']
|
||||||
|
call assert_equal([' 2 Xfile2:15 col 15: Line 15'],
|
||||||
|
\ split(execute('filter /Line 15/ clist'), "\n"))
|
||||||
|
call assert_equal([' 1 Xfile1:10 col 10: Line 10'],
|
||||||
|
\ split(execute('filter /Xfile1/ clist'), "\n"))
|
||||||
|
call assert_equal([], split(execute('filter /abc/ clist'), "\n"))
|
||||||
|
|
||||||
|
call setqflist([{'module' : 'abc', 'pattern' : 'pat1'},
|
||||||
|
\ {'module' : 'pqr', 'pattern' : 'pat2'}], ' ')
|
||||||
|
call assert_equal([' 2 pqr:pat2: '],
|
||||||
|
\ split(execute('filter /pqr/ clist'), "\n"))
|
||||||
|
call assert_equal([' 1 abc:pat1: '],
|
||||||
|
\ split(execute('filter /pat1/ clist'), "\n"))
|
||||||
|
endfunc
|
||||||
|
@ -789,6 +789,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
165,
|
||||||
/**/
|
/**/
|
||||||
164,
|
164,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user