]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1754: :helptags doesn't skip examples with syntax v9.1.1754
authorzeertzjq <zeertzjq@outlook.com>
Thu, 11 Sep 2025 19:21:52 +0000 (15:21 -0400)
committerChristian Brabandt <cb@256bit.org>
Thu, 11 Sep 2025 19:21:52 +0000 (15:21 -0400)
Problem:  :helptags doesn't skip examples with syntax
          (Evgeni Chasnovski)
Solution: Check for examples with syntax (zeertzjq).

fixes: #18273
closes: #18277

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/help.c
src/testdir/test_help.vim
src/version.c

index 106236201188eeff758e618cd25fc253a3283a8d..b4df3809b69ceff3d8aa7891efa38b27cbf94530 100644 (file)
@@ -965,7 +965,6 @@ helptags_one(
     int                this_utf8;
     int                firstline;
     int                in_example;
-    int                len;
     int                mix = FALSE;    // detected mixed encodings
 
     // Find all *.txt files.
@@ -1117,10 +1116,16 @@ helptags_one(
                }
                p1 = p2;
            }
-           len = (int)STRLEN(IObuff);
-           if ((len == 2 && STRCMP(&IObuff[len - 2], ">\n") == 0)
-                   || (len >= 3 && STRCMP(&IObuff[len - 3], " >\n") == 0))
-               in_example = TRUE;
+           size_t off = STRLEN(IObuff);
+           if (off >= 2 && IObuff[off - 1] == '\n')
+           {
+               off -= 2;
+               while (off > 0 && (ASCII_ISLOWER(IObuff[off])
+                                                 || VIM_ISDIGIT(IObuff[off])))
+                   off--;
+               if (IObuff[off] == '>' && (off == 0 || IObuff[off - 1] == ' '))
+                   in_example = TRUE;
+           }
            line_breakcheck();
        }
 
index dac153d863654e9d495c4c14f512d1b8200f49bd..820338abdc4cbfcafba21b1f7825f857abd5bfc5 100644 (file)
@@ -139,11 +139,17 @@ func Test_helptag_cmd()
   call delete('Xtagdir/tags')
 
   " Test parsing tags
-  call writefile(['*tag1*', 'Example: >', '  *notag*', 'Example end: *tag2*'],
+  call writefile(['*tag1*', 'Example: >', '  *notag1*', 'Example end: *tag2*',
+                \ '>', '  *notag2*', '<',
+                \ '*tag3*', 'Code: >vim', '  *notag3*', 'Code end: *tag4*',
+                \ '>i3config', '  *notag4*', '<'],
     \ 'Xtagdir/a/doc/sample.txt')
   helptags Xtagdir
   call assert_equal(["tag1\ta/doc/sample.txt\t/*tag1*",
-                  \  "tag2\ta/doc/sample.txt\t/*tag2*"], readfile('Xtagdir/tags'))
+                   \ "tag2\ta/doc/sample.txt\t/*tag2*",
+                   \ "tag3\ta/doc/sample.txt\t/*tag3*",
+                   \ "tag4\ta/doc/sample.txt\t/*tag4*"],
+    \ readfile('Xtagdir/tags'))
 
   " Duplicate tags in the help file
   call writefile(['*tag1*', '*tag1*', '*tag2*'], 'Xtagdir/a/doc/sample.txt')
index 3dbb664c33234f4fcf44e2cf672fb1face2b0d57..89787c4d63c8e6cd5530077fbd88c0c89aea5237 100644 (file)
@@ -724,6 +724,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1754,
 /**/
     1753,
 /**/