diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-11-18 11:16:11 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-18 11:16:11 +0800 |
commit | 282cbc2350986c3fc1edb507c4facc8d8fe8cd97 (patch) | |
tree | b743d77f4f8ad3d52bb8056d6f0bae0ab27dd0d1 | |
parent | ba04fffe9869159efe6660d782f436fa8348aae2 (diff) | |
download | rneovim-282cbc2350986c3fc1edb507c4facc8d8fe8cd97.tar.gz rneovim-282cbc2350986c3fc1edb507c4facc8d8fe8cd97.tar.bz2 rneovim-282cbc2350986c3fc1edb507c4facc8d8fe8cd97.zip |
vim-patch:8.2.3776: when a tags file line is long a tag may not be found (#21099)
Problem: When a tags file line is long a tag may not be found.
Solution: When increasing the buffer size read the same line again.
https://github.com/vim/vim/commit/f8e9eb8e173bf0ff9560192ae888941ef8302269
Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r-- | src/nvim/tag.c | 8 | ||||
-rw-r--r-- | src/nvim/testdir/test_taglist.vim | 19 |
2 files changed, 25 insertions, 2 deletions
diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 35b9d71ea3..36d6432c06 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1691,8 +1691,6 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc vim_fseek(fp, search_info.curr_offset, SEEK_SET); eof = vim_fgets((char_u *)lbuf, lbuf_size, fp); if (!eof && search_info.curr_offset != 0) { - // The explicit cast is to work around a bug in gcc 3.4.2 - // (repeated below). search_info.curr_offset = vim_ftell(fp); if (search_info.curr_offset == search_info.high_offset) { // oops, gone a bit too far; try from low offset @@ -1718,6 +1716,7 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc // skip empty and blank lines do { + search_info.curr_offset = vim_ftell(fp); eof = vim_fgets((char_u *)lbuf, lbuf_size, fp); } while (!eof && vim_isblankline(lbuf)); @@ -1840,6 +1839,11 @@ parse_line: lbuf_size *= 2; xfree(lbuf); lbuf = xmalloc((size_t)lbuf_size); + + if (state == TS_STEP_FORWARD) { + // Seek to the same position to read the same line again + vim_fseek(fp, search_info.curr_offset, SEEK_SET); + } // this will try the same thing again, make sure the offset is // different search_info.curr_offset = 0; diff --git a/src/nvim/testdir/test_taglist.vim b/src/nvim/testdir/test_taglist.vim index 658485582c..68f9982e36 100644 --- a/src/nvim/testdir/test_taglist.vim +++ b/src/nvim/testdir/test_taglist.vim @@ -241,4 +241,23 @@ func Test_tag_complete_wildoptions() set tags& endfunc +func Test_tag_complete_with_overlong_line() + let tagslines =<< trim END + !_TAG_FILE_FORMAT 2 // + !_TAG_FILE_SORTED 1 // + !_TAG_FILE_ENCODING utf-8 // + inboundGSV a 1;" r + inboundGovernor a 2;" kind:⊢ type:forall (muxMode :: MuxMode) socket peerAddr versionNumber m a b. (MonadAsync m, MonadCatch m, MonadEvaluate m, MonadThrow m, MonadThrow (STM m), MonadTime m, MonadTimer m, MonadMask m, Ord peerAddr, HasResponder muxMode ~ True) => Tracer m (RemoteTransitionTrace peerAddr) -> Tracer m (InboundGovernorTrace peerAddr) -> ServerControlChannel muxMode peerAddr ByteString m a b -> DiffTime -> MuxConnectionManager muxMode socket peerAddr versionNumber ByteString m a b -> StrictTVar m InboundGovernorObservableState -> m Void + inboundGovernorCounters a 3;" kind:⊢ type:InboundGovernorState muxMode peerAddr m a b -> InboundGovernorCounters + END + call writefile(tagslines, 'Xtags') + set tags=Xtags + + call feedkeys(":tag inbou\<C-A>\<C-B>\"\<CR>", 'xt') + call assert_equal('"tag inboundGSV inboundGovernor inboundGovernorCounters', @:) + + call delete('Xtags') + set tags& +endfunc + " vim: shiftwidth=2 sts=2 expandtab |