# HG changeset patch # User Bram Moolenaar # Date 1602436503 -7200 # Node ID 431367075f29e92e821a2d677150a6af29c33966 # Parent e327c9690dbe38df3915a1b573cbe87c605db2a0 patch 8.2.1835: ":help ??" finds the "!!" tag Commit: https://github.com/vim/vim/commit/6eb36ade9883f54c84c739c6a3504ddfa3343063 Author: Bram Moolenaar Date: Sun Oct 11 19:08:33 2020 +0200 patch 8.2.1835: ":help ??" finds the "!!" tag Problem: ":help ??" finds the "!!" tag. Solution: Do not translate "?" into ".". (Naruhiko Nishino, closes https://github.com/vim/vim/issues/7114, closes #7115) diff --git a/src/help.c b/src/help.c --- a/src/help.c +++ b/src/help.c @@ -323,33 +323,57 @@ find_help_tags( { char_u *s, *d; int i; - static char *(mtable[]) = {"*", "g*", "[*", "]*", ":*", - "/*", "/\\*", "\"*", "**", - "cpo-*", "/\\(\\)", "/\\%(\\)", - "?", ":?", "?", "g?", "g?g?", "g??", - "-?", "q?", "v_g?", - "/\\?", "/\\z(\\)", "\\=", ":s\\=", - "[count]", "[quotex]", - "[range]", ":[range]", - "[pattern]", "\\|", "\\%$", - "s/\\~", "s/\\U", "s/\\L", - "s/\\1", "s/\\2", "s/\\3", "s/\\9"}; - static char *(rtable[]) = {"star", "gstar", "[star", "]star", ":star", - "/star", "/\\\\star", "quotestar", "starstar", - "cpo-star", "/\\\\(\\\\)", "/\\\\%(\\\\)", - "?", ":?", "?", "g?", "g?g?", "g??", - "-?", "q?", "v_g?", - "/\\\\?", "/\\\\z(\\\\)", "\\\\=", ":s\\\\=", - "\\[count]", "\\[quotex]", - "\\[range]", ":\\[range]", - "\\[pattern]", "\\\\bar", "/\\\\%\\$", - "s/\\\\\\~", "s/\\\\U", "s/\\\\L", - "s/\\\\1", "s/\\\\2", "s/\\\\3", "s/\\\\9"}; + // Specific tags that either have a specific replacement or won't go + // throught the generic rules. + static char *(except_tbl[][2]) = { + {"*", "star"}, + {"g*", "gstar"}, + {"[*", "[star"}, + {"]*", "]star"}, + {":*", ":star"}, + {"/*", "/star"}, + {"/\\*", "/\\\\star"}, + {"\"*", "quotestar"}, + {"**", "starstar"}, + {"cpo-*", "cpo-star"}, + {"/\\(\\)", "/\\\\(\\\\)"}, + {"/\\%(\\)", "/\\\\%(\\\\)"}, + {"?", "?"}, + {"??", "??"}, + {":?", ":?"}, + {"?", "?"}, + {"g?", "g?"}, + {"g?g?", "g?g?"}, + {"g??", "g??"}, + {"-?", "-?"}, + {"q?", "q?"}, + {"v_g?", "v_g?"}, + {"/\\?", "/\\\\?"}, + {"/\\z(\\)", "/\\\\z(\\\\)"}, + {"\\=", "\\\\="}, + {":s\\=", ":s\\\\="}, + {"[count]", "\\[count]"}, + {"[quotex]", "\\[quotex]"}, + {"[range]", "\\[range]"}, + {":[range]", ":\\[range]"}, + {"[pattern]", "\\[pattern]"}, + {"\\|", "\\\\bar"}, + {"\\%$", "/\\\\%\\$"}, + {"s/\\~", "s/\\\\\\~"}, + {"s/\\U", "s/\\\\U"}, + {"s/\\L", "s/\\\\L"}, + {"s/\\1", "s/\\\\1"}, + {"s/\\2", "s/\\\\2"}, + {"s/\\3", "s/\\\\3"}, + {"s/\\9", "s/\\\\9"}, + {NULL, NULL} + }; static char *(expr_table[]) = {"!=?", "!~?", "<=?", "=?", ">?", "is?", "isnot?"}; + ">=?", ">?", "is?", "isnot?"}; int flags; d = IObuff; // assume IObuff is long enough! + d[0] = NUL; if (STRNICMP(arg, "expr-", 5) == 0) { @@ -376,16 +400,16 @@ find_help_tags( else { // Recognize a few exceptions to the rule. Some strings that contain - // '*' with "star". Otherwise '*' is recognized as a wildcard. - for (i = (int)(sizeof(mtable) / sizeof(char *)); --i >= 0; ) - if (STRCMP(arg, mtable[i]) == 0) + // '*'are changed to "star", otherwise '*' is recognized as a wildcard. + for (i = 0; except_tbl[i][0] != NULL; ++i) + if (STRCMP(arg, except_tbl[i][0]) == 0) { - STRCPY(d, rtable[i]); + STRCPY(d, except_tbl[i][1]); break; } } - if (i < 0) // no match in table + if (d[0] == NUL) // no match in table { // Replace "\S" with "/\\S", etc. Otherwise every tag is matched. // Also replace "\%^" and "\%(", they match every tag too. diff --git a/src/testdir/test_help_tagjump.vim b/src/testdir/test_help_tagjump.vim --- a/src/testdir/test_help_tagjump.vim +++ b/src/testdir/test_help_tagjump.vim @@ -16,6 +16,11 @@ func Test_help_tagjump() call assert_true(getline('.') =~ '\*quote\*') helpclose + help * + call assert_equal("help", &filetype) + call assert_true(getline('.') =~ '\*star\*') + helpclose + help "* call assert_equal("help", &filetype) call assert_true(getline('.') =~ '\*quotestar\*') @@ -26,6 +31,11 @@ func Test_help_tagjump() call assert_true(getline('.') =~ '\*:smile\*') helpclose + help ?? + call assert_equal("help", &filetype) + call assert_true(getline('.') =~ '\*??\*') + helpclose + help :? call assert_equal("help", &filetype) call assert_true(getline('.') =~ '\*:?\*') diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1835, +/**/ 1834, /**/ 1833,