Patch 8.1.2221

9 views
Skip to first unread message

Bram Moolenaar

unread,
Oct 26, 2019, 11:37:56 AM10/26/19
to vim...@googlegroups.com

Patch 8.1.2221
Problem: Cannot filter :disp output.
Solution: Support filtereing :disp output. (Andi Massimino, closes #5117)
Files: runtime/doc/various.txt, src/register.c,
src/testdir/test_filter_cmd.vim


*** ../vim-8.1.2220/runtime/doc/various.txt 2019-09-28 19:04:06.997029566 +0200
--- runtime/doc/various.txt 2019-10-26 16:57:00.802735238 +0200
***************
*** 574,579 ****
--- 575,582 ----
|:marks| - filter by text in the current file,
or file name for other files
|:oldfiles| - filter by file name
+ |:registers| - filter by register contents
+ (does not work multi-line)
|:set| - filter by variable name

Only normal messages are filtered, error messages are
*** ../vim-8.1.2220/src/register.c 2019-10-24 20:16:56.117110116 +0200
--- src/register.c 2019-10-26 17:29:08.090478448 +0200
***************
*** 2161,2167 ****
int attr;
char_u *arg = eap->arg;
int clen;
! char_u type[2];

if (arg != NULL && *arg == NUL)
arg = NULL;
--- 2161,2167 ----
int attr;
char_u *arg = eap->arg;
int clen;
! int type;

if (arg != NULL && *arg == NUL)
arg = NULL;
***************
*** 2174,2182 ****
name = get_register_name(i);
switch (get_reg_type(name, NULL))
{
! case MLINE: type[0] = 'l'; break;
! case MCHAR: type[0] = 'c'; break;
! default: type[0] = 'b'; break;
}
if (arg != NULL && vim_strchr(arg, name) == NULL
#ifdef ONE_CLIPBOARD
--- 2174,2182 ----
name = get_register_name(i);
switch (get_reg_type(name, NULL))
{
! case MLINE: type = 'l'; break;
! case MCHAR: type = 'c'; break;
! default: type = 'b'; break;
}
if (arg != NULL && vim_strchr(arg, name) == NULL
#ifdef ONE_CLIPBOARD
***************
*** 2213,2251 ****

if (yb->y_array != NULL)
{
! msg_putchar('\n');
! msg_puts(" ");
! msg_putchar(type[0]);
! 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);
! out_flush(); // show one line at a time
}
- ui_breakcheck();
}

// display last inserted text
if ((p = get_last_insert()) != NULL
! && (arg == NULL || vim_strchr(arg, '.') != NULL) && !got_int)
{
msg_puts("\n c \". ");
dis_msg(p, TRUE);
--- 2213,2261 ----

if (yb->y_array != NULL)
{
! int do_show = FALSE;

! for (j = 0; !do_show && j < yb->y_size; ++j)
! do_show = !message_filtered(yb->y_array[j]);
!
! if (do_show || yb->y_size == 0)
{
! 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);
+ out_flush(); // show one line at a time
}
! ui_breakcheck();
}
}

// display last inserted text
if ((p = get_last_insert()) != NULL
! && (arg == NULL || vim_strchr(arg, '.') != NULL) && !got_int
! && !message_filtered(p))
{
msg_puts("\n c \". ");
dis_msg(p, TRUE);
***************
*** 2253,2259 ****

// display last command line
if (last_cmdline != NULL && (arg == NULL || vim_strchr(arg, ':') != NULL)
! && !got_int)
{
msg_puts("\n c \": ");
dis_msg(last_cmdline, FALSE);
--- 2263,2269 ----

// display last command line
if (last_cmdline != NULL && (arg == NULL || vim_strchr(arg, ':') != NULL)
! && !got_int && !message_filtered(last_cmdline))
{
msg_puts("\n c \": ");
dis_msg(last_cmdline, FALSE);
***************
*** 2261,2267 ****

// display current file name
if (curbuf->b_fname != NULL
! && (arg == NULL || vim_strchr(arg, '%') != NULL) && !got_int)
{
msg_puts("\n c \"% ");
dis_msg(curbuf->b_fname, FALSE);
--- 2271,2278 ----

// display current file name
if (curbuf->b_fname != NULL
! && (arg == NULL || vim_strchr(arg, '%') != NULL) && !got_int
! && !message_filtered(curbuf->b_fname))
{
msg_puts("\n c \"% ");
dis_msg(curbuf->b_fname, FALSE);
***************
*** 2273,2279 ****
char_u *fname;
linenr_T dummy;

! if (buflist_name_nr(0, &fname, &dummy) != FAIL)
{
msg_puts("\n c \"# ");
dis_msg(fname, FALSE);
--- 2284,2291 ----
char_u *fname;
linenr_T dummy;

! if (buflist_name_nr(0, &fname, &dummy) != FAIL
! && !message_filtered(fname))
{
msg_puts("\n c \"# ");
dis_msg(fname, FALSE);
***************
*** 2282,2288 ****

// display last search pattern
if (last_search_pat() != NULL
! && (arg == NULL || vim_strchr(arg, '/') != NULL) && !got_int)
{
msg_puts("\n c \"/ ");
dis_msg(last_search_pat(), FALSE);
--- 2294,2301 ----

// display last search pattern
if (last_search_pat() != NULL
! && (arg == NULL || vim_strchr(arg, '/') != NULL) && !got_int
! && !message_filtered(last_search_pat()))
{
msg_puts("\n c \"/ ");
dis_msg(last_search_pat(), FALSE);
***************
*** 2291,2297 ****
#ifdef FEAT_EVAL
// display last used expression
if (expr_line != NULL && (arg == NULL || vim_strchr(arg, '=') != NULL)
! && !got_int)
{
msg_puts("\n c \"= ");
dis_msg(expr_line, FALSE);
--- 2304,2310 ----
#ifdef FEAT_EVAL
// display last used expression
if (expr_line != NULL && (arg == NULL || vim_strchr(arg, '=') != NULL)
! && !got_int && !message_filtered(expr_line))
{
msg_puts("\n c \"= ");
dis_msg(expr_line, FALSE);
*** ../vim-8.1.2220/src/testdir/test_filter_cmd.vim 2019-04-27 22:40:03.927661368 +0200
--- src/testdir/test_filter_cmd.vim 2019-10-26 17:20:27.949025594 +0200
***************
*** 145,147 ****
--- 145,174 ----
bwipe! file.h
bwipe! file.hs
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
*** ../vim-8.1.2220/src/version.c 2019-10-26 16:48:35.404890864 +0200
--- src/version.c 2019-10-26 16:59:46.662051384 +0200
***************
*** 743,744 ****
--- 743,746 ----
{ /* Add new patch number below this line */
+ /**/
+ 2221,
/**/

--
An alien life briefly visits earth. Just before departing it leaves a
message in the dust on the back of a white van. The world is shocked
and wants to know what it means. After months of studies the worlds
best linguistic scientists are able to decipher the message: "Wash me!".

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages