0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.2.1835: ":help ??" finds the "!!" tag

Problem:    ":help ??" finds the "!!" tag.
Solution:   Do not translate "?" into ".".  (Naruhiko Nishino, closes #7114,
            closes #7115)
This commit is contained in:
Bram Moolenaar 2020-10-11 19:08:33 +02:00
parent efc0d94afc
commit 6eb36ade98
3 changed files with 64 additions and 28 deletions

View File

@ -323,33 +323,57 @@ find_help_tags(
{ {
char_u *s, *d; char_u *s, *d;
int i; int i;
static char *(mtable[]) = {"*", "g*", "[*", "]*", ":*", // Specific tags that either have a specific replacement or won't go
"/*", "/\\*", "\"*", "**", // throught the generic rules.
"cpo-*", "/\\(\\)", "/\\%(\\)", static char *(except_tbl[][2]) = {
"?", ":?", "?<CR>", "g?", "g?g?", "g??", {"*", "star"},
"-?", "q?", "v_g?", {"g*", "gstar"},
"/\\?", "/\\z(\\)", "\\=", ":s\\=", {"[*", "[star"},
"[count]", "[quotex]", {"]*", "]star"},
"[range]", ":[range]", {":*", ":star"},
"[pattern]", "\\|", "\\%$", {"/*", "/star"},
"s/\\~", "s/\\U", "s/\\L", {"/\\*", "/\\\\star"},
"s/\\1", "s/\\2", "s/\\3", "s/\\9"}; {"\"*", "quotestar"},
static char *(rtable[]) = {"star", "gstar", "[star", "]star", ":star", {"**", "starstar"},
"/star", "/\\\\star", "quotestar", "starstar", {"cpo-*", "cpo-star"},
"cpo-star", "/\\\\(\\\\)", "/\\\\%(\\\\)", {"/\\(\\)", "/\\\\(\\\\)"},
"?", ":?", "?<CR>", "g?", "g?g?", "g??", {"/\\%(\\)", "/\\\\%(\\\\)"},
"-?", "q?", "v_g?", {"?", "?"},
"/\\\\?", "/\\\\z(\\\\)", "\\\\=", ":s\\\\=", {"??", "??"},
"\\[count]", "\\[quotex]", {":?", ":?"},
"\\[range]", ":\\[range]", {"?<CR>", "?<CR>"},
"\\[pattern]", "\\\\bar", "/\\\\%\\$", {"g?", "g?"},
"s/\\\\\\~", "s/\\\\U", "s/\\\\L", {"g?g?", "g?g?"},
"s/\\\\1", "s/\\\\2", "s/\\\\3", "s/\\\\9"}; {"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[]) = {"!=?", "!~?", "<=?", "<?", "==?", "=~?", static char *(expr_table[]) = {"!=?", "!~?", "<=?", "<?", "==?", "=~?",
">=?", ">?", "is?", "isnot?"}; ">=?", ">?", "is?", "isnot?"};
int flags; int flags;
d = IObuff; // assume IObuff is long enough! d = IObuff; // assume IObuff is long enough!
d[0] = NUL;
if (STRNICMP(arg, "expr-", 5) == 0) if (STRNICMP(arg, "expr-", 5) == 0)
{ {
@ -376,16 +400,16 @@ find_help_tags(
else else
{ {
// Recognize a few exceptions to the rule. Some strings that contain // Recognize a few exceptions to the rule. Some strings that contain
// '*' with "star". Otherwise '*' is recognized as a wildcard. // '*'are changed to "star", otherwise '*' is recognized as a wildcard.
for (i = (int)(sizeof(mtable) / sizeof(char *)); --i >= 0; ) for (i = 0; except_tbl[i][0] != NULL; ++i)
if (STRCMP(arg, mtable[i]) == 0) if (STRCMP(arg, except_tbl[i][0]) == 0)
{ {
STRCPY(d, rtable[i]); STRCPY(d, except_tbl[i][1]);
break; 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. // Replace "\S" with "/\\S", etc. Otherwise every tag is matched.
// Also replace "\%^" and "\%(", they match every tag too. // Also replace "\%^" and "\%(", they match every tag too.

View File

@ -16,6 +16,11 @@ func Test_help_tagjump()
call assert_true(getline('.') =~ '\*quote\*') call assert_true(getline('.') =~ '\*quote\*')
helpclose helpclose
help *
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*star\*')
helpclose
help "* help "*
call assert_equal("help", &filetype) call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*quotestar\*') call assert_true(getline('.') =~ '\*quotestar\*')
@ -26,6 +31,11 @@ func Test_help_tagjump()
call assert_true(getline('.') =~ '\*:smile\*') call assert_true(getline('.') =~ '\*:smile\*')
helpclose helpclose
help ??
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*??\*')
helpclose
help :? help :?
call assert_equal("help", &filetype) call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*:?\*') call assert_true(getline('.') =~ '\*:?\*')

View File

@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1835,
/**/ /**/
1834, 1834,
/**/ /**/