Skip to content

Commit 3bf5e6a

Browse files
committed
patch 8.1.0235: more help tags that jump to the wrong location
Problem: More help tags that jump to the wrong location. Solution: Add more exceptions and a table for "expr-" tags. (Hirohito Higashi)
1 parent 41c363a commit 3bf5e6a

File tree

3 files changed

+54
-12
lines changed

3 files changed

+54
-12
lines changed

src/ex_cmds.c

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6583,7 +6583,8 @@ find_help_tags(
65836583
static char *(mtable[]) = {"*", "g*", "[*", "]*", ":*",
65846584
"/*", "/\\*", "\"*", "**",
65856585
"cpo-*", "/\\(\\)", "/\\%(\\)",
6586-
"?", ":?", "-?", "?<CR>", "g?", "g?g?", "g??",
6586+
"?", ":?", "?<CR>", "g?", "g?g?", "g??",
6587+
"-?", "q?", "v_g?",
65876588
"/\\?", "/\\z(\\)", "\\=", ":s\\=",
65886589
"[count]", "[quotex]",
65896590
"[range]", ":[range]",
@@ -6593,27 +6594,43 @@ find_help_tags(
65936594
static char *(rtable[]) = {"star", "gstar", "[star", "]star", ":star",
65946595
"/star", "/\\\\star", "quotestar", "starstar",
65956596
"cpo-star", "/\\\\(\\\\)", "/\\\\%(\\\\)",
6596-
"?", ":?", "-?", "?<CR>", "g?", "g?g?", "g??",
6597+
"?", ":?", "?<CR>", "g?", "g?g?", "g??",
6598+
"-?", "q?", "v_g?",
65976599
"/\\\\?", "/\\\\z(\\\\)", "\\\\=", ":s\\\\=",
65986600
"\\[count]", "\\[quotex]",
65996601
"\\[range]", ":\\[range]",
66006602
"\\[pattern]", "\\\\bar", "/\\\\%\\$",
66016603
"s/\\\\\\~", "s/\\\\U", "s/\\\\L",
66026604
"s/\\\\1", "s/\\\\2", "s/\\\\3", "s/\\\\9"};
6605+
static char *(expr_table[]) = {"!=?", "!~?", "<=?", "<?", "==?", "=~?",
6606+
">=?", ">?", "is?", "isnot?"};
66036607
int flags;
66046608

66056609
d = IObuff; /* assume IObuff is long enough! */
66066610

6607-
/*
6608-
* Recognize a few exceptions to the rule. Some strings that contain '*'
6609-
* with "star". Otherwise '*' is recognized as a wildcard.
6610-
*/
6611-
for (i = (int)(sizeof(mtable) / sizeof(char *)); --i >= 0; )
6612-
if (STRCMP(arg, mtable[i]) == 0)
6613-
{
6614-
STRCPY(d, rtable[i]);
6615-
break;
6616-
}
6611+
if (STRNICMP(arg, "expr-", 5) == 0)
6612+
{
6613+
// When the string starting with "expr-" and containing '?' and matches
6614+
// the table, it is taken literally. Otherwise '?' is recognized as a
6615+
// wildcard.
6616+
for (i = (int)(sizeof(expr_table) / sizeof(char *)); --i >= 0; )
6617+
if (STRCMP(arg + 5, expr_table[i]) == 0)
6618+
{
6619+
STRCPY(d, arg);
6620+
break;
6621+
}
6622+
}
6623+
else
6624+
{
6625+
// Recognize a few exceptions to the rule. Some strings that contain
6626+
// '*' with "star". Otherwise '*' is recognized as a wildcard.
6627+
for (i = (int)(sizeof(mtable) / sizeof(char *)); --i >= 0; )
6628+
if (STRCMP(arg, mtable[i]) == 0)
6629+
{
6630+
STRCPY(d, rtable[i]);
6631+
break;
6632+
}
6633+
}
66176634

66186635
if (i < 0) /* no match in table */
66196636
{

src/testdir/test_help_tagjump.vim

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,34 @@ func Test_help_tagjump()
2626
call assert_true(getline('.') =~ '\*:?\*')
2727
helpclose
2828

29+
help q?
30+
call assert_equal("help", &filetype)
31+
call assert_true(getline('.') =~ '\*q?\*')
32+
call assert_true(expand('<cword>') == 'q?')
33+
helpclose
34+
2935
help -?
3036
call assert_equal("help", &filetype)
3137
call assert_true(getline('.') =~ '\*-?\*')
3238
helpclose
3339

40+
help v_g?
41+
call assert_equal("help", &filetype)
42+
call assert_true(getline('.') =~ '\*v_g?\*')
43+
helpclose
44+
45+
help expr-!=?
46+
call assert_equal("help", &filetype)
47+
call assert_true(getline('.') =~ '\*expr-!=?\*')
48+
call assert_true(expand('<cword>') == 'expr-!=?')
49+
helpclose
50+
51+
help expr-isnot?
52+
call assert_equal("help", &filetype)
53+
call assert_true(getline('.') =~ '\*expr-isnot?\*')
54+
call assert_true(expand('<cword>') == 'expr-isnot?')
55+
helpclose
56+
3457
help FileW*Post
3558
call assert_equal("help", &filetype)
3659
call assert_true(getline('.') =~ '\*FileWritePost\*')

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,8 @@ static char *(features[]) =
794794

795795
static int included_patches[] =
796796
{ /* Add new patch number below this line */
797+
/**/
798+
235,
797799
/**/
798800
234,
799801
/**/

0 commit comments

Comments
 (0)