diff options
author | James McCoy <jamessan@jamessan.com> | 2017-03-19 14:50:00 -0400 |
---|---|---|
committer | James McCoy <jamessan@jamessan.com> | 2017-03-19 23:42:14 -0400 |
commit | e1af49b425f25024a3e6361ed576cf69296a1da4 (patch) | |
tree | 308e29aec15838904484d19284fa236dca906aed | |
parent | 058516aaf9c29b41bf27c8d4adfa2773c3896205 (diff) | |
download | rneovim-e1af49b425f25024a3e6361ed576cf69296a1da4.tar.gz rneovim-e1af49b425f25024a3e6361ed576cf69296a1da4.tar.bz2 rneovim-e1af49b425f25024a3e6361ed576cf69296a1da4.zip |
vim-patch:8.0.0195
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 vim/vim#1387)
https://github.com/vim/vim/commit/a9d23c20879d0dcb289a4db54b3c7df060f87c3c
-rw-r--r-- | src/nvim/tag.c | 22 | ||||
-rw-r--r-- | src/nvim/testdir/test_tagjump.vim | 18 |
2 files changed, 30 insertions, 10 deletions
diff --git a/src/nvim/tag.c b/src/nvim/tag.c index c3c2634598..92a535ab91 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -82,10 +82,6 @@ typedef struct { #define MT_GL_CUR 1 /* global match in current file */ #define MT_GL_OTH 2 /* global 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_RE_OFF 8 /* add for regexp match */ #define MT_MASK 7 /* mask for printing priority */ @@ -1826,7 +1822,7 @@ parse_line: if (tagp.command + 2 < temp_end) { len = (int)(temp_end - tagp.command - 2); - mfp = xmalloc(sizeof(char_u) + len + 1); + mfp = xmalloc(len + 2); STRLCPY(mfp, tagp.command + 2, len + 1); } else mfp = NULL; @@ -1849,11 +1845,12 @@ parse_line: * Emacs tag: <mtt><tag_fname><NUL><ebuf><NUL><lbuf> * other tag: <mtt><tag_fname><NUL><NUL><lbuf> * without Emacs tags: <mtt><tag_fname><NUL><lbuf> + * Here <mtt> is the "mtt" value plus 1 to avoid NUL. */ len = (int)tag_fname_len + (int)STRLEN(lbuf) + 3; mfp = xmalloc(sizeof(char_u) + len + 1); p = mfp; - p[0] = mtt; + p[0] = mtt + 1; STRCPY(p + 1, tag_fname); #ifdef BACKSLASH_IN_FILENAME /* Ignore differences in slashes, avoid adding @@ -1969,10 +1966,15 @@ findtag_end: if (matches == NULL) { xfree(mfp); } else { - // now change the TAG_SEP back to NUL - for (p = mfp; *p != NUL; p++) { - if (*p == TAG_SEP) { - *p = NUL; + if (!name_only) { + // Change mtt back to zero-based. + *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; diff --git a/src/nvim/testdir/test_tagjump.vim b/src/nvim/testdir/test_tagjump.vim index 678ad0ada8..54b5f4afd6 100644 --- a/src/nvim/testdir/test_tagjump.vim +++ b/src/nvim/testdir/test_tagjump.vim @@ -23,4 +23,22 @@ func Test_cancel_ptjump() quit 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 + " vim: shiftwidth=2 sts=2 expandtab |