0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.0.0195: fail to jump to static tag in current file

Problem:    Jumping to a tag that is a static item in the current file fails.
            (Kazunobu Kuriyama)
Solution:   Make sure the first byte of the tag key is not NUL. (Suggested by
            James McCoy, closes #1387)
This commit is contained in:
Bram Moolenaar
2017-01-16 20:53:34 +01:00
parent e32bbded64
commit a9d23c2087
3 changed files with 33 additions and 10 deletions

View File

@@ -44,10 +44,6 @@ typedef struct tag_pointers
#define MT_GL_CUR 1 /* global match in current file */ #define MT_GL_CUR 1 /* global match in current file */
#define MT_GL_OTH 2 /* global match in other file */ #define MT_GL_OTH 2 /* global match in other file */
#define MT_ST_OTH 3 /* static match in other file */ #define MT_ST_OTH 3 /* static match in other file */
#define MT_IC_ST_CUR 4 /* icase static match in current file */
#define MT_IC_GL_CUR 5 /* icase global match in current file */
#define MT_IC_GL_OTH 6 /* icase global match in other file */
#define MT_IC_ST_OTH 7 /* icase static match in other file */
#define MT_IC_OFF 4 /* add for icase match */ #define MT_IC_OFF 4 /* add for icase match */
#define MT_RE_OFF 8 /* add for regexp match */ #define MT_RE_OFF 8 /* add for regexp match */
#define MT_MASK 7 /* mask for printing priority */ #define MT_MASK 7 /* mask for printing priority */
@@ -2317,7 +2313,7 @@ parse_line:
if (tagp.command + 2 < temp_end) if (tagp.command + 2 < temp_end)
{ {
len = (int)(temp_end - tagp.command - 2); len = (int)(temp_end - tagp.command - 2);
mfp = (char_u *)alloc((int)sizeof(char_u) + len + 1); mfp = (char_u *)alloc(len + 2);
if (mfp != NULL) if (mfp != NULL)
vim_strncpy(mfp, tagp.command + 2, len); vim_strncpy(mfp, tagp.command + 2, len);
} }
@@ -2351,6 +2347,7 @@ parse_line:
* Emacs tag: <mtt><tag_fname><0x01><ebuf><0x01><lbuf><NUL> * Emacs tag: <mtt><tag_fname><0x01><ebuf><0x01><lbuf><NUL>
* other tag: <mtt><tag_fname><0x01><0x01><lbuf><NUL> * other tag: <mtt><tag_fname><0x01><0x01><lbuf><NUL>
* without Emacs tags: <mtt><tag_fname><0x01><lbuf><NUL> * without Emacs tags: <mtt><tag_fname><0x01><lbuf><NUL>
* Here <mtt> is the "mtt" value plus 1 to avoid NUL.
*/ */
len = (int)tag_fname_len + (int)STRLEN(lbuf) + 3; len = (int)tag_fname_len + (int)STRLEN(lbuf) + 3;
#ifdef FEAT_EMACS_TAGS #ifdef FEAT_EMACS_TAGS
@@ -2366,7 +2363,7 @@ parse_line:
if (mfp != NULL) if (mfp != NULL)
{ {
p = mfp; p = mfp;
p[0] = mtt; p[0] = mtt + 1;
STRCPY(p + 1, tag_fname); STRCPY(p + 1, tag_fname);
#ifdef BACKSLASH_IN_FILENAME #ifdef BACKSLASH_IN_FILENAME
/* Ignore differences in slashes, avoid adding /* Ignore differences in slashes, avoid adding
@@ -2548,10 +2545,16 @@ findtag_end:
vim_free(mfp); vim_free(mfp);
else else
{ {
/* now change the TAG_SEP back to NUL */ if (!name_only)
for (p = mfp; *p != NUL; ++p) {
if (*p == TAG_SEP) /* Change mtt back to zero-based. */
*p = NUL; *mfp = *mfp - 1;
/* change the TAG_SEP back to NUL */
for (p = mfp + 1; *p != NUL; ++p)
if (*p == TAG_SEP)
*p = NUL;
}
matches[match_count++] = (char_u *)mfp; matches[match_count++] = (char_u *)mfp;
} }
todo--; todo--;

View File

@@ -23,6 +23,24 @@ func Test_cancel_ptjump()
quit quit
endfunc endfunc
func Test_static_tagjump()
set tags=Xtags
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
\ "one\tXfile1\t/^one/;\"\tf\tfile:\tsignature:(void)",
\ "word\tXfile2\tcmd2"],
\ 'Xtags')
new Xfile1
call setline(1, ['empty', 'one()', 'empty'])
write
tag one
call assert_equal(2, line('.'))
set tags&
call delete('Xtags')
call delete('Xfile1')
bwipe!
endfunc
" Tests for [ CTRL-I and CTRL-W CTRL-I commands " Tests for [ CTRL-I and CTRL-W CTRL-I commands
function Test_keyword_jump() function Test_keyword_jump()
call writefile(["#include Xinclude", "", call writefile(["#include Xinclude", "",

View File

@@ -764,6 +764,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
195,
/**/ /**/
194, 194,
/**/ /**/