diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-05-07 11:42:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-07 11:42:21 +0200 |
commit | bc395b4fd4bb4973f22c68763bf000ea4cff4ccb (patch) | |
tree | c1855b5d165b3efcf395f8a6c3238ea08ec54c12 | |
parent | 400ee59247eae62990baf30c7802bc8effb3704a (diff) | |
parent | 4423759d0360acda87dd829f361957d55748dab5 (diff) | |
download | rneovim-bc395b4fd4bb4973f22c68763bf000ea4cff4ccb.tar.gz rneovim-bc395b4fd4bb4973f22c68763bf000ea4cff4ccb.tar.bz2 rneovim-bc395b4fd4bb4973f22c68763bf000ea4cff4ccb.zip |
Merge #9979 from janlazo/vim-8.0.0876
vim-patch:8.0.{876,1144},8.1.0133
-rw-r--r-- | src/nvim/path.c | 9 | ||||
-rw-r--r-- | src/nvim/quickfix.c | 4 | ||||
-rw-r--r-- | src/nvim/tag.c | 25 | ||||
-rw-r--r-- | src/nvim/testdir/test_taglist.vim | 25 |
4 files changed, 58 insertions, 5 deletions
diff --git a/src/nvim/path.c b/src/nvim/path.c index a706e32773..67b88a861a 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -1346,6 +1346,15 @@ void slash_adjust(char_u *p) if (path_with_url((const char *)p)) { return; } + + if (*p == '`') { + // don't replace backslash in backtick quoted strings + const size_t len = STRLEN(p); + if (len > 2 && *(p + len - 1) == '`') { + return; + } + } + while (*p) { if (*p == (char_u)psepcN) { *p = (char_u)psepc; diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index be643a6062..786e40254d 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -430,7 +430,11 @@ static efm_T * parse_efm_option(char_u *efm) for (int round = FMT_PATTERNS - 1; round >= 0; ) { i += STRLEN(fmt_pat[round--].pattern); } +#ifdef BACKSLASH_IN_FILENAME + i += 12; // "%f" can become twelve chars longer (see efm_to_regpat) +#else i += 2; // "%f" can become two chars longer +#endif char_u *fmtstr = xmalloc(i); while (efm[0] != NUL) { diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 4d0e5b0b1b..81af23f911 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1970,7 +1970,13 @@ static garray_T tag_fnames = GA_EMPTY_INIT_VALUE; */ static void found_tagfile_cb(char_u *fname, void *cookie) { - GA_APPEND(char_u *, &tag_fnames, vim_strsave(fname)); + char_u *const tag_fname = vim_strsave(fname); + +#ifdef BACKSLASH_IN_FILENAME + slash_adjust(tag_fname); +#endif + simplify_filename(tag_fname); + GA_APPEND(char_u *, &tag_fnames, tag_fname); } #if defined(EXITFREE) @@ -2028,9 +2034,20 @@ get_tagfname ( ++tnp->tn_hf_idx; STRCPY(buf, p_hf); STRCPY(path_tail(buf), "tags"); - } else - STRLCPY(buf, ((char_u **)(tag_fnames.ga_data))[ - tnp->tn_hf_idx++], MAXPATHL); +#ifdef BACKSLASH_IN_FILENAME + slash_adjust(buf); +#endif + simplify_filename(buf); + + for (int i = 0; i < tag_fnames.ga_len; i++) { + if (STRCMP(buf, ((char_u **)(tag_fnames.ga_data))[i]) == 0) { + return FAIL; // avoid duplicate file names + } + } + } else { + STRLCPY(buf, ((char_u **)(tag_fnames.ga_data))[tnp->tn_hf_idx++], + MAXPATHL); + } return OK; } diff --git a/src/nvim/testdir/test_taglist.vim b/src/nvim/testdir/test_taglist.vim index f4e939254a..ea0a6b9678 100644 --- a/src/nvim/testdir/test_taglist.vim +++ b/src/nvim/testdir/test_taglist.vim @@ -1,4 +1,4 @@ -" test 'taglist' function and :tags command +" test taglist(), tagfiles() functions and :tags command func Test_taglist() call writefile([ @@ -74,3 +74,26 @@ func Test_tagsfile_without_trailing_newline() call delete('Xtags') endfunc + +func Test_tagfiles() + call assert_equal([], tagfiles()) + + call writefile(["FFoo\tXfoo\t1"], 'Xtags1') + call writefile(["FBar\tXbar\t1"], 'Xtags2') + set tags=Xtags1,Xtags2 + call assert_equal(['Xtags1', 'Xtags2'], tagfiles()) + + help + let tf = tagfiles() + call assert_equal(1, len(tf)) + call assert_equal(fnamemodify(expand('$VIMRUNTIME/doc/tags'), ':p:gs?\\?/?'), + \ fnamemodify(tf[0], ':p:gs?\\?/?')) + helpclose + call assert_equal(['Xtags1', 'Xtags2'], tagfiles()) + set tags& + call assert_equal([], tagfiles()) + + call delete('Xtags1') + call delete('Xtags2') + bd +endfunc |