vim-patch:8.1.0165: :clist output can be very long

Problem:    :clist output can be very long.
Solution:   Support filtering :clist entries. (Yegappan Lakshmanan)
4cde86c2ef
This commit is contained in:
Jan Edmund Lazo 2019-06-21 22:44:33 -04:00
parent f99e314da0
commit ff244a1309
2 changed files with 37 additions and 2 deletions

View File

@ -2528,9 +2528,9 @@ void qf_list(exarg_T *eap)
qfp = qi->qf_lists[qi->qf_curlist].qf_start;
for (i = 1; !got_int && i <= qi->qf_lists[qi->qf_curlist].qf_count; ) {
if ((qfp->qf_valid || all) && idx1 <= i && i <= idx2) {
msg_putchar('\n');
if (got_int)
if (got_int) {
break;
}
fname = NULL;
if (qfp->qf_module != NULL && *qfp->qf_module != NUL) {
@ -2549,6 +2549,23 @@ void qf_list(exarg_T *eap)
vim_snprintf((char *)IObuff, IOSIZE, "%2d %s", i, (char *)fname);
}
}
// Support for filtering entries using :filter /pat/ clist
int 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
? HL_ATTR(HLF_QFL) : HL_ATTR(HLF_D));
if (qfp->qf_lnum == 0) {
@ -2579,6 +2596,7 @@ void qf_list(exarg_T *eap)
ui_flush(); /* show one line at a time */
}
next_entry:
qfp = qfp->qf_next;
if (qfp == NULL) {
break;

View File

@ -3373,6 +3373,23 @@ func Test_lbuffer_with_bwipe()
augroup END
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
func Test_setloclist_in_aucmd()
" This was using freed memory.
augroup nasty