mirror of
https://github.com/vim/vim.git
synced 2025-09-28 04:24:06 -04:00
patch 8.1.2221: cannot filter :disp output
Problem: Cannot filter :disp output. Solution: Support filtereing :disp output. (Andi Massimino, closes #5117)
This commit is contained in:
@@ -575,6 +575,8 @@ N *+X11* Unix only: can restore window title |X11|
|
|||||||
|:marks| - filter by text in the current file,
|
|:marks| - filter by text in the current file,
|
||||||
or file name for other files
|
or file name for other files
|
||||||
|:oldfiles| - filter by file name
|
|:oldfiles| - filter by file name
|
||||||
|
|:registers| - filter by register contents
|
||||||
|
(does not work multi-line)
|
||||||
|:set| - filter by variable name
|
|:set| - filter by variable name
|
||||||
|
|
||||||
Only normal messages are filtered, error messages are
|
Only normal messages are filtered, error messages are
|
||||||
|
@@ -2161,7 +2161,7 @@ ex_display(exarg_T *eap)
|
|||||||
int attr;
|
int attr;
|
||||||
char_u *arg = eap->arg;
|
char_u *arg = eap->arg;
|
||||||
int clen;
|
int clen;
|
||||||
char_u type[2];
|
int type;
|
||||||
|
|
||||||
if (arg != NULL && *arg == NUL)
|
if (arg != NULL && *arg == NUL)
|
||||||
arg = NULL;
|
arg = NULL;
|
||||||
@@ -2174,9 +2174,9 @@ ex_display(exarg_T *eap)
|
|||||||
name = get_register_name(i);
|
name = get_register_name(i);
|
||||||
switch (get_reg_type(name, NULL))
|
switch (get_reg_type(name, NULL))
|
||||||
{
|
{
|
||||||
case MLINE: type[0] = 'l'; break;
|
case MLINE: type = 'l'; break;
|
||||||
case MCHAR: type[0] = 'c'; break;
|
case MCHAR: type = 'c'; break;
|
||||||
default: type[0] = 'b'; break;
|
default: type = 'b'; break;
|
||||||
}
|
}
|
||||||
if (arg != NULL && vim_strchr(arg, name) == NULL
|
if (arg != NULL && vim_strchr(arg, name) == NULL
|
||||||
#ifdef ONE_CLIPBOARD
|
#ifdef ONE_CLIPBOARD
|
||||||
@@ -2213,39 +2213,49 @@ ex_display(exarg_T *eap)
|
|||||||
|
|
||||||
if (yb->y_array != NULL)
|
if (yb->y_array != NULL)
|
||||||
{
|
{
|
||||||
msg_putchar('\n');
|
int do_show = FALSE;
|
||||||
msg_puts(" ");
|
|
||||||
msg_putchar(type[0]);
|
|
||||||
msg_puts(" ");
|
|
||||||
msg_putchar('"');
|
|
||||||
msg_putchar(name);
|
|
||||||
msg_puts(" ");
|
|
||||||
|
|
||||||
n = (int)Columns - 11;
|
for (j = 0; !do_show && j < yb->y_size; ++j)
|
||||||
for (j = 0; j < yb->y_size && n > 1; ++j)
|
do_show = !message_filtered(yb->y_array[j]);
|
||||||
|
|
||||||
|
if (do_show || yb->y_size == 0)
|
||||||
{
|
{
|
||||||
if (j)
|
msg_putchar('\n');
|
||||||
|
msg_puts(" ");
|
||||||
|
msg_putchar(type);
|
||||||
|
msg_puts(" ");
|
||||||
|
msg_putchar('"');
|
||||||
|
msg_putchar(name);
|
||||||
|
msg_puts(" ");
|
||||||
|
|
||||||
|
n = (int)Columns - 11;
|
||||||
|
for (j = 0; j < yb->y_size && n > 1; ++j)
|
||||||
{
|
{
|
||||||
|
if (j)
|
||||||
|
{
|
||||||
|
msg_puts_attr("^J", attr);
|
||||||
|
n -= 2;
|
||||||
|
}
|
||||||
|
for (p = yb->y_array[j]; *p && (n -= ptr2cells(p)) >= 0;
|
||||||
|
++p)
|
||||||
|
{
|
||||||
|
clen = (*mb_ptr2len)(p);
|
||||||
|
msg_outtrans_len(p, clen);
|
||||||
|
p += clen - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (n > 1 && yb->y_type == MLINE)
|
||||||
msg_puts_attr("^J", attr);
|
msg_puts_attr("^J", attr);
|
||||||
n -= 2;
|
out_flush(); // show one line at a time
|
||||||
}
|
|
||||||
for (p = yb->y_array[j]; *p && (n -= ptr2cells(p)) >= 0; ++p)
|
|
||||||
{
|
|
||||||
clen = (*mb_ptr2len)(p);
|
|
||||||
msg_outtrans_len(p, clen);
|
|
||||||
p += clen - 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (n > 1 && yb->y_type == MLINE)
|
ui_breakcheck();
|
||||||
msg_puts_attr("^J", attr);
|
|
||||||
out_flush(); // show one line at a time
|
|
||||||
}
|
}
|
||||||
ui_breakcheck();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// display last inserted text
|
// display last inserted text
|
||||||
if ((p = get_last_insert()) != NULL
|
if ((p = get_last_insert()) != NULL
|
||||||
&& (arg == NULL || vim_strchr(arg, '.') != NULL) && !got_int)
|
&& (arg == NULL || vim_strchr(arg, '.') != NULL) && !got_int
|
||||||
|
&& !message_filtered(p))
|
||||||
{
|
{
|
||||||
msg_puts("\n c \". ");
|
msg_puts("\n c \". ");
|
||||||
dis_msg(p, TRUE);
|
dis_msg(p, TRUE);
|
||||||
@@ -2253,7 +2263,7 @@ ex_display(exarg_T *eap)
|
|||||||
|
|
||||||
// display last command line
|
// display last command line
|
||||||
if (last_cmdline != NULL && (arg == NULL || vim_strchr(arg, ':') != NULL)
|
if (last_cmdline != NULL && (arg == NULL || vim_strchr(arg, ':') != NULL)
|
||||||
&& !got_int)
|
&& !got_int && !message_filtered(last_cmdline))
|
||||||
{
|
{
|
||||||
msg_puts("\n c \": ");
|
msg_puts("\n c \": ");
|
||||||
dis_msg(last_cmdline, FALSE);
|
dis_msg(last_cmdline, FALSE);
|
||||||
@@ -2261,7 +2271,8 @@ ex_display(exarg_T *eap)
|
|||||||
|
|
||||||
// display current file name
|
// display current file name
|
||||||
if (curbuf->b_fname != NULL
|
if (curbuf->b_fname != NULL
|
||||||
&& (arg == NULL || vim_strchr(arg, '%') != NULL) && !got_int)
|
&& (arg == NULL || vim_strchr(arg, '%') != NULL) && !got_int
|
||||||
|
&& !message_filtered(curbuf->b_fname))
|
||||||
{
|
{
|
||||||
msg_puts("\n c \"% ");
|
msg_puts("\n c \"% ");
|
||||||
dis_msg(curbuf->b_fname, FALSE);
|
dis_msg(curbuf->b_fname, FALSE);
|
||||||
@@ -2273,7 +2284,8 @@ ex_display(exarg_T *eap)
|
|||||||
char_u *fname;
|
char_u *fname;
|
||||||
linenr_T dummy;
|
linenr_T dummy;
|
||||||
|
|
||||||
if (buflist_name_nr(0, &fname, &dummy) != FAIL)
|
if (buflist_name_nr(0, &fname, &dummy) != FAIL
|
||||||
|
&& !message_filtered(fname))
|
||||||
{
|
{
|
||||||
msg_puts("\n c \"# ");
|
msg_puts("\n c \"# ");
|
||||||
dis_msg(fname, FALSE);
|
dis_msg(fname, FALSE);
|
||||||
@@ -2282,7 +2294,8 @@ ex_display(exarg_T *eap)
|
|||||||
|
|
||||||
// display last search pattern
|
// display last search pattern
|
||||||
if (last_search_pat() != NULL
|
if (last_search_pat() != NULL
|
||||||
&& (arg == NULL || vim_strchr(arg, '/') != NULL) && !got_int)
|
&& (arg == NULL || vim_strchr(arg, '/') != NULL) && !got_int
|
||||||
|
&& !message_filtered(last_search_pat()))
|
||||||
{
|
{
|
||||||
msg_puts("\n c \"/ ");
|
msg_puts("\n c \"/ ");
|
||||||
dis_msg(last_search_pat(), FALSE);
|
dis_msg(last_search_pat(), FALSE);
|
||||||
@@ -2291,7 +2304,7 @@ ex_display(exarg_T *eap)
|
|||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
// display last used expression
|
// display last used expression
|
||||||
if (expr_line != NULL && (arg == NULL || vim_strchr(arg, '=') != NULL)
|
if (expr_line != NULL && (arg == NULL || vim_strchr(arg, '=') != NULL)
|
||||||
&& !got_int)
|
&& !got_int && !message_filtered(expr_line))
|
||||||
{
|
{
|
||||||
msg_puts("\n c \"= ");
|
msg_puts("\n c \"= ");
|
||||||
dis_msg(expr_line, FALSE);
|
dis_msg(expr_line, FALSE);
|
||||||
|
@@ -145,3 +145,30 @@ func Test_filter_commands()
|
|||||||
bwipe! file.h
|
bwipe! file.h
|
||||||
bwipe! file.hs
|
bwipe! file.hs
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_filter_display()
|
||||||
|
edit Xdoesnotmatch
|
||||||
|
let @a = '!!willmatch'
|
||||||
|
let @b = '!!doesnotmatch'
|
||||||
|
let @c = "oneline\ntwoline\nwillmatch\n"
|
||||||
|
let @/ = '!!doesnotmatch'
|
||||||
|
call feedkeys(":echo '!!doesnotmatch:'\<CR>", 'ntx')
|
||||||
|
let lines = map(split(execute('filter /willmatch/ display'), "\n"), 'v:val[5:6]')
|
||||||
|
|
||||||
|
call assert_true(index(lines, '"a') >= 0)
|
||||||
|
call assert_false(index(lines, '"b') >= 0)
|
||||||
|
call assert_true(index(lines, '"c') >= 0)
|
||||||
|
call assert_false(index(lines, '"/') >= 0)
|
||||||
|
call assert_false(index(lines, '":') >= 0)
|
||||||
|
call assert_false(index(lines, '"%') >= 0)
|
||||||
|
|
||||||
|
let lines = map(split(execute('filter /doesnotmatch/ display'), "\n"), 'v:val[5:6]')
|
||||||
|
call assert_true(index(lines, '"a') < 0)
|
||||||
|
call assert_false(index(lines, '"b') < 0)
|
||||||
|
call assert_true(index(lines, '"c') < 0)
|
||||||
|
call assert_false(index(lines, '"/') < 0)
|
||||||
|
call assert_false(index(lines, '":') < 0)
|
||||||
|
call assert_false(index(lines, '"%') < 0)
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
@@ -741,6 +741,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 */
|
||||||
|
/**/
|
||||||
|
2221,
|
||||||
/**/
|
/**/
|
||||||
2220,
|
2220,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user