]> granicus.if.org Git - vim/commitdiff
patch 8.1.1221: filtering does not work when listing marks v8.1.1221
authorBram Moolenaar <Bram@vim.org>
Sat, 27 Apr 2019 20:40:08 +0000 (22:40 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 27 Apr 2019 20:40:08 +0000 (22:40 +0200)
Problem:    Filtering does not work when listing marks.
Solution:   Implement filtering marks. (Marcin Szamotulski, closes #3895)

runtime/doc/various.txt
src/mark.c
src/testdir/test_filter_cmd.vim
src/version.c

index 923ac240f1019590001f9caa7e3b78c64566aac9..8b4f988ee9ec1583c1a6dd1e312846fe7afdcb54 100644 (file)
@@ -571,17 +571,19 @@ N  *+X11*         Unix only: can restore window title |X11|
                        the output, not necessarily the whole line. Only some
                        commands support filtering, try it out to check if it
                        works. Some of the commands that support filtering:
-                          |:#|          - filter whole line
-                          |:command|    - filter by command name
-                          |:files|      - filter by file name
-                          |:highlight|  - filter by highlight group
-                          |:jumps|      - filter by file name
-                          |:let|        - filter by variable name
-                          |:list|       - filter whole line
-                          |:llist|      - filter by file name or module name
-                          |:oldfiles|   - filter by file name
-                          |:clist|      - filter by file name or module name
-                          |:set|        - filter by variable name
+                          |:#|          - filter whole line
+                          |:clist|      - filter by file name or module name
+                          |:command|    - filter by command name
+                          |:files|      - filter by file name
+                          |:highlight|  - filter by highlight group
+                          |:jumps|      - filter by file name
+                          |:let|        - filter by variable name
+                          |:list|       - filter whole line
+                          |:llist|      - filter by file name or module name
+                          |:marks|      - filter by text in the current file,
+                                          or file name for other files
+                          |:oldfiles|   - filter by file name
+                          |:set|        - filter by variable name
 
                        Only normal messages are filtered, error messages are
                        not.
index 6a7ab00d8bf8eb5764984e9ed9bc458c80af194d..1b34c20895faf7b8c40428e19088b6ab4fecc2c7 100644 (file)
@@ -744,11 +744,12 @@ show_one_mark(
     int                c,
     char_u     *arg,
     pos_T      *p,
-    char_u     *name,
+    char_u     *name_arg,
     int                current)        /* in current file */
 {
     static int did_title = FALSE;
     int                mustfree = FALSE;
+    char_u     *name = name_arg;
 
     if (c == -1)                           /* finish up */
     {
@@ -762,35 +763,38 @@ show_one_mark(
                semsg(_("E283: No marks matching \"%s\""), arg);
        }
     }
-    /* don't output anything if 'q' typed at --more-- prompt */
+    // don't output anything if 'q' typed at --more-- prompt
     else if (!got_int
            && (arg == NULL || vim_strchr(arg, c) != NULL)
            && p->lnum != 0)
     {
-       if (!did_title)
+       if (name == NULL && current)
        {
-           /* Highlight title */
-           msg_puts_title(_("\nmark line  col file/text"));
-           did_title = TRUE;
+           name = mark_line(p, 15);
+           mustfree = TRUE;
        }
-       msg_putchar('\n');
-       if (!got_int)
+       if (!message_filtered(name))
        {
-           sprintf((char *)IObuff, " %c %6ld %4d ", c, p->lnum, p->col);
-           msg_outtrans(IObuff);
-           if (name == NULL && current)
+           if (!did_title)
            {
-               name = mark_line(p, 15);
-               mustfree = TRUE;
+               // Highlight title
+               msg_puts_title(_("\nmark line  col file/text"));
+               did_title = TRUE;
            }
-           if (name != NULL)
+           msg_putchar('\n');
+           if (!got_int)
            {
-               msg_outtrans_attr(name, current ? HL_ATTR(HLF_D) : 0);
-               if (mustfree)
-                   vim_free(name);
+               sprintf((char *)IObuff, " %c %6ld %4d ", c, p->lnum, p->col);
+               msg_outtrans(IObuff);
+               if (name != NULL)
+               {
+                   msg_outtrans_attr(name, current ? HL_ATTR(HLF_D) : 0);
+               }
            }
+           out_flush();                    // show one line at a time
        }
-       out_flush();                /* show one line at a time */
+       if (mustfree)
+           vim_free(name);
     }
 }
 
index 6f40a902e12d4368dfc0cba06bc177b5048a87f7..0c45db049b5bfcc9ff9ce4465fffb0389e60ce23 100644 (file)
@@ -126,7 +126,22 @@ func Test_filter_commands()
   let res = split(execute("filter /\.c$/ jumps"), "\n")[1:]
   call assert_equal(["   2     1    0 file.c", ">"], res)
 
-  bwipe file.c
-  bwipe file.h
-  bwipe file.hs
+  " Test filtering :marks command
+  b file.c
+  mark A
+  b file.h
+  mark B
+  let res = split(execute("filter /\.c$/ marks"), "\n")[1:]
+  call assert_equal([" A      1    0 file.c"], res)
+
+  call setline(1, ['one', 'two', 'three'])
+  1mark a
+  2mark b
+  3mark c
+  let res = split(execute("filter /two/ marks abc"), "\n")[1:]
+  call assert_equal([" b      2    0 two"], res)
+
+  bwipe! file.c
+  bwipe! file.h
+  bwipe! file.hs
 endfunc
index 9fe5d2daf0a0b35f7dacb1f714f96e81ed77228f..c65c541ac4ca1a785b3523f9e24d6d2a5c27d3a3 100644 (file)
@@ -767,6 +767,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1221,
 /**/
     1220,
 /**/