]> granicus.if.org Git - vim/commitdiff
patch 8.2.3776: when a tags file line is long a tag may not be found v8.2.3776
authorBram Moolenaar <Bram@vim.org>
Fri, 10 Dec 2021 20:15:15 +0000 (20:15 +0000)
committerBram Moolenaar <Bram@vim.org>
Fri, 10 Dec 2021 20:15:15 +0000 (20:15 +0000)
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.

src/tag.c
src/testdir/test_taglist.vim
src/version.c

index 41d21b7514ceaea2d90d73ac56227c82385cec1e..48a69d466c916ca0a3db94dc398c43a940fbdbb6 100644 (file)
--- a/src/tag.c
+++ b/src/tag.c
@@ -2011,8 +2011,6 @@ find_tags(
                eof = vim_fgets(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)
                    {
@@ -2052,7 +2050,10 @@ find_tags(
                        eof = cs_fgets(lbuf, lbuf_size);
                    else
 #endif
+                   {
+                       search_info.curr_offset = vim_ftell(fp);
                        eof = vim_fgets(lbuf, lbuf_size, fp);
+                   }
                } while (!eof && vim_isblankline(lbuf));
 
                if (eof)
@@ -2294,6 +2295,10 @@ parse_line:
                lbuf = alloc(lbuf_size);
                if (lbuf == NULL)
                    goto findtag_end;
+
+               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);
 #ifdef FEAT_TAG_BINS
                // this will try the same thing again, make sure the offset is
                // different
index 58ad56512e62d18cad37857c8e78e1bd67cfdbe6..3ba5ec0943548d144d48959ca0f2eb2a128ab3ce 100644 (file)
@@ -236,4 +236,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
index 9bf1fa27c723db055c4f88b700718c1446a1127e..03dee7ee7807ea206e163e2a4481e336e4216311 100644 (file)
@@ -753,6 +753,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3776,
 /**/
     3775,
 /**/