]> granicus.if.org Git - vim/commitdiff
patch 8.1.2312: "line:" field in tags file not used v8.1.2312
authorBram Moolenaar <Bram@vim.org>
Sun, 17 Nov 2019 15:18:31 +0000 (16:18 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 17 Nov 2019 15:18:31 +0000 (16:18 +0100)
Problem:    "line:" field in tags file not used.
Solution:   Recognize the field and use the value. (Andy Massimino, Daniel
            Hahler, closes #5232, closes #2546, closes #1057)

src/tag.c
src/testdir/test_tagjump.vim
src/version.c

index e3ad616633446387bb5df7d9f0748dbc4850c157..b72d82bf53a21dd7c3d7a5d038acb2c1c3d078a3 100644 (file)
--- a/src/tag.c
+++ b/src/tag.c
@@ -35,6 +35,7 @@ typedef struct tag_pointers
     char_u     *tagkind_end;   // end of tagkind
     char_u     *user_data;     // user_data string
     char_u     *user_data_end; // end of user_data
+    linenr_T   tagline;        // "line:" value
 } tagptrs_T;
 
 /*
@@ -3217,6 +3218,7 @@ parse_match(
 
     tagp->tagkind = NULL;
     tagp->user_data = NULL;
+    tagp->tagline = 0;
     tagp->command_end = NULL;
 
     if (retval == OK)
@@ -3237,6 +3239,8 @@ parse_match(
                        tagp->tagkind = p + 5;
                    else if (STRNCMP(p, "user_data:", 10) == 0)
                        tagp->user_data = p + 10;
+                   else if (STRNCMP(p, "line:", 5) == 0)
+                       tagp->tagline = atoi((char *)p + 5);
                    if (tagp->tagkind != NULL && tagp->user_data != NULL)
                        break;
                    pc = vim_strchr(p, ':');
@@ -3537,7 +3541,12 @@ jumpto_tag(
            p_ic = FALSE;       /* don't ignore case now */
            p_scs = FALSE;
            save_lnum = curwin->w_cursor.lnum;
-           curwin->w_cursor.lnum = 0;  /* start search before first line */
+           if (tagp.tagline > 0)
+               // start search before line from "line:" field
+               curwin->w_cursor.lnum = tagp.tagline - 1;
+           else
+               // start search before first line
+               curwin->w_cursor.lnum = 0;
            if (do_search(NULL, pbuf[0], pbuf + 1, (long)1,
                                                         search_options, NULL))
                retval = OK;
index 34a3c3055bd80ca7162074485d3e7346541942f8..14c99036d1cf75d79984d3c77ced2625a24be925 100644 (file)
@@ -526,4 +526,28 @@ func Test_tselect()
   call delete('XTest_tselect')
 endfunc
 
+func Test_tagline()
+  call writefile([
+       \ 'provision    Xtest.py        /^    def provision(self, **kwargs):$/;"        m       line:1  language:Python class:Foo',
+       \ 'provision    Xtest.py        /^    def provision(self, **kwargs):$/;"        m       line:3  language:Python class:Bar',
+       \], 'Xtags')
+  call writefile([
+       \ '    def provision(self, **kwargs):',
+       \ '        pass',
+       \ '    def provision(self, **kwargs):',
+       \ '        pass',
+       \], 'Xtest.py')
+
+  set tags=Xtags
+
+  1tag provision
+  call assert_equal(line('.'), 1)
+  2tag provision
+  call assert_equal(line('.'), 3)
+
+  call delete('Xtags')
+  call delete('Xtest.py')
+  set tags&
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 35969b5a2336881dbfe2374b8f4e5c333abf024f..2f0316fae7f29220e0c003aaeff3332072132b22 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2312,
 /**/
     2311,
 /**/