]> granicus.if.org Git - vim/commitdiff
patch 8.1.0911: tag line with Ex command cannot have extra fields v8.1.0911
authorBram Moolenaar <Bram@vim.org>
Wed, 13 Feb 2019 20:19:14 +0000 (21:19 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 13 Feb 2019 20:19:14 +0000 (21:19 +0100)
Problem:    Tag line with Ex command cannot have extra fields.
Solution:   Recognize |;" as the end of the command. (closes #2402)

runtime/doc/tagsrch.txt
src/tag.c
src/testdir/test_taglist.vim
src/version.c

index e6589c70b611a21b00af788f347f5b089a306c8c..f9cc1efdc0452a24b3d07c73798cea38fe5fab03 100644 (file)
@@ -571,7 +571,14 @@ only supported by new versions of ctags (such as Exuberant ctags).
 {term}         ;" The two characters semicolon and double quote.  This is
                interpreted by Vi as the start of a comment, which makes the
                following be ignored.  This is for backwards compatibility
-               with Vi, it ignores the following fields.
+               with Vi, it ignores the following fields. Example:
+                       APP     file    /^static int APP;$/;"   v
+               When {tagaddress} is not a line number or search pattern, then
+               {term} must be |;".  Here the bar ends the command (excluding
+               the bar) and ;" is used to have Vi ignore the rest of the
+               line.  Example:
+                       APP     file.c  call cursor(3, 4)|;"    v
+                       
 {field} ..     A list of optional fields.  Each field has the form:
 
                        <Tab>{fieldname}:{value}
index b1915e1e1429fd050740ef8b4bd245d05373bd18..a148fbc0e9f5049f9d751753edd1e7263a108458 100644 (file)
--- a/src/tag.c
+++ b/src/tag.c
@@ -3014,7 +3014,10 @@ parse_match(
        p = tagp->command;
        if (find_extra(&p) == OK)
        {
-           tagp->command_end = p;
+           if (p > tagp->command && p[-1] == '|')
+               tagp->command_end = p - 1;  // drop trailing bar
+           else
+               tagp->command_end = p;
            p += 2;     /* skip ";\"" */
            if (*p++ == TAB)
                while (ASCII_ISALPHA(*p))
@@ -3784,7 +3787,7 @@ find_extra(char_u **pp)
 {
     char_u     *str = *pp;
 
-    /* Repeat for addresses separated with ';' */
+    // Repeat for addresses separated with ';'
     for (;;)
     {
        if (VIM_ISDIGIT(*str))
@@ -3798,7 +3801,16 @@ find_extra(char_u **pp)
                ++str;
        }
        else
-           str = NULL;
+       {
+           // not a line number or search string, look for terminator.
+           str = (char_u *)strstr((char *)str, "|;\"");
+           if (str != NULL)
+           {
+               ++str;
+               break;
+           }
+
+       }
        if (str == NULL || *str != ';'
                  || !(VIM_ISDIGIT(str[1]) || str[1] == '/' || str[1] == '?'))
            break;
index 0a9350adc700df35b58b388cb1996ee44832ac89..de9ca0c809f4675270f89d3d348e6d3b663fea34 100644 (file)
@@ -5,7 +5,9 @@ func Test_taglist()
        \ "FFoo\tXfoo\t1",
        \ "FBar\tXfoo\t2",
        \ "BFoo\tXbar\t1",
-       \ "BBar\tXbar\t2"
+       \ "BBar\tXbar\t2",
+       \ "Kindly\tXbar\t3;\"\tv\tfile:",
+       \ "Command\tXbar\tcall cursor(3, 4)|;\"\td",
        \ ], 'Xtags')
   set tags=Xtags
   split Xtext
@@ -15,6 +17,18 @@ func Test_taglist()
   call assert_equal(['FFoo', 'BFoo'], map(taglist("Foo", "Xfoo"), {i, v -> v.name}))
   call assert_equal(['BFoo', 'FFoo'], map(taglist("Foo", "Xbar"), {i, v -> v.name}))
 
+  let kind = taglist("Kindly")
+  call assert_equal(1, len(kind))
+  call assert_equal('v', kind[0]['kind'])
+  call assert_equal('3', kind[0]['cmd'])
+  call assert_equal(1, kind[0]['static'])
+  call assert_equal('Xbar', kind[0]['filename'])
+
+  let cmd = taglist("Command")
+  call assert_equal(1, len(cmd))
+  call assert_equal('d', cmd[0]['kind'])
+  call assert_equal('call cursor(3, 4)', cmd[0]['cmd'])
+
   call delete('Xtags')
   bwipe
 endfunc
index 59f7b5dadd78062b98ce67326be6656766052140..88960bafd2eb0817129ce264dc5a01417dca34ad 100644 (file)
@@ -783,6 +783,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    911,
 /**/
     910,
 /**/