comparison src/tag.c @ 18640:b9240fe40dd4 v8.1.2312

patch 8.1.2312: "line:" field in tags file not used Commit: https://github.com/vim/vim/commit/077b9dd3541339a23ade0cc6a23e804ee39312c5 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Nov 17 16:18:31 2019 +0100 patch 8.1.2312: "line:" field in tags file not used 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)
author Bram Moolenaar <Bram@vim.org>
date Sun, 17 Nov 2019 16:30:03 +0100
parents 60c46cd053db
children bbea1f108187
comparison
equal deleted inserted replaced
18639:cb3163d590a1 18640:b9240fe40dd4
33 #endif 33 #endif
34 char_u *tagkind; // "kind:" value 34 char_u *tagkind; // "kind:" value
35 char_u *tagkind_end; // end of tagkind 35 char_u *tagkind_end; // end of tagkind
36 char_u *user_data; // user_data string 36 char_u *user_data; // user_data string
37 char_u *user_data_end; // end of user_data 37 char_u *user_data_end; // end of user_data
38 linenr_T tagline; // "line:" value
38 } tagptrs_T; 39 } tagptrs_T;
39 40
40 /* 41 /*
41 * The matching tags are first stored in one of the hash tables. In 42 * The matching tags are first stored in one of the hash tables. In
42 * which one depends on the priority of the match. 43 * which one depends on the priority of the match.
3215 #endif 3216 #endif
3216 tagp); 3217 tagp);
3217 3218
3218 tagp->tagkind = NULL; 3219 tagp->tagkind = NULL;
3219 tagp->user_data = NULL; 3220 tagp->user_data = NULL;
3221 tagp->tagline = 0;
3220 tagp->command_end = NULL; 3222 tagp->command_end = NULL;
3221 3223
3222 if (retval == OK) 3224 if (retval == OK)
3223 { 3225 {
3224 /* Try to find a kind field: "kind:<kind>" or just "<kind>"*/ 3226 /* Try to find a kind field: "kind:<kind>" or just "<kind>"*/
3235 { 3237 {
3236 if (STRNCMP(p, "kind:", 5) == 0) 3238 if (STRNCMP(p, "kind:", 5) == 0)
3237 tagp->tagkind = p + 5; 3239 tagp->tagkind = p + 5;
3238 else if (STRNCMP(p, "user_data:", 10) == 0) 3240 else if (STRNCMP(p, "user_data:", 10) == 0)
3239 tagp->user_data = p + 10; 3241 tagp->user_data = p + 10;
3242 else if (STRNCMP(p, "line:", 5) == 0)
3243 tagp->tagline = atoi((char *)p + 5);
3240 if (tagp->tagkind != NULL && tagp->user_data != NULL) 3244 if (tagp->tagkind != NULL && tagp->user_data != NULL)
3241 break; 3245 break;
3242 pc = vim_strchr(p, ':'); 3246 pc = vim_strchr(p, ':');
3243 pt = vim_strchr(p, '\t'); 3247 pt = vim_strchr(p, '\t');
3244 if (pc == NULL || (pt != NULL && pc > pt)) 3248 if (pc == NULL || (pt != NULL && pc > pt))
3535 save_p_scs = p_scs; 3539 save_p_scs = p_scs;
3536 p_ws = TRUE; /* need 'wrapscan' for backward searches */ 3540 p_ws = TRUE; /* need 'wrapscan' for backward searches */
3537 p_ic = FALSE; /* don't ignore case now */ 3541 p_ic = FALSE; /* don't ignore case now */
3538 p_scs = FALSE; 3542 p_scs = FALSE;
3539 save_lnum = curwin->w_cursor.lnum; 3543 save_lnum = curwin->w_cursor.lnum;
3540 curwin->w_cursor.lnum = 0; /* start search before first line */ 3544 if (tagp.tagline > 0)
3545 // start search before line from "line:" field
3546 curwin->w_cursor.lnum = tagp.tagline - 1;
3547 else
3548 // start search before first line
3549 curwin->w_cursor.lnum = 0;
3541 if (do_search(NULL, pbuf[0], pbuf + 1, (long)1, 3550 if (do_search(NULL, pbuf[0], pbuf + 1, (long)1,
3542 search_options, NULL)) 3551 search_options, NULL))
3543 retval = OK; 3552 retval = OK;
3544 else 3553 else
3545 { 3554 {