vim-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)
3bf5e6a4c8
This commit is contained in:
Jan Edmund Lazo
2018-08-27 19:23:40 -04:00
parent 106b308ed4
commit 9d7dc49db1
2 changed files with 48 additions and 10 deletions

View File

@@ -4688,7 +4688,8 @@ int find_help_tags(char_u *arg, int *num_matches, char_u ***matches, int keep_la
static char *(mtable[]) = {"*", "g*", "[*", "]*",
"/*", "/\\*", "\"*", "**",
"/\\(\\)", "/\\%(\\)",
"?", ":?", "-?", "?<CR>", "g?", "g?g?", "g??",
"?", ":?", "?<CR>", "g?", "g?g?", "g??",
"-?", "q?", "v_g?",
"/\\?", "/\\z(\\)", "\\=", ":s\\=",
"[count]", "[quotex]",
"[range]", ":[range]",
@@ -4698,26 +4699,40 @@ int find_help_tags(char_u *arg, int *num_matches, char_u ***matches, int keep_la
static char *(rtable[]) = {"star", "gstar", "[star", "]star",
"/star", "/\\\\star", "quotestar", "starstar",
"/\\\\(\\\\)", "/\\\\%(\\\\)",
"?", ":?", "-?", "?<CR>", "g?", "g?g?", "g??",
"?", ":?", "?<CR>", "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"};
static char *(expr_table[]) = {"!=?", "!~?", "<=?", "<?", "==?", "=~?",
">=?", ">?", "is?", "isnot?"};
int flags;
d = IObuff; /* assume IObuff is long enough! */
/*
* Recognize a few exceptions to the rule. Some strings that contain '*'
* with "star". Otherwise '*' is recognized as a wildcard.
*/
for (i = (int)ARRAY_SIZE(mtable); --i >= 0; )
if (STRCMP(arg, mtable[i]) == 0) {
STRCPY(d, rtable[i]);
break;
if (STRNICMP(arg, "expr-", 5) == 0) {
// When the string starting with "expr-" and containing '?' and matches
// the table, it is taken literally. Otherwise '?' is recognized as a
// wildcard.
for (i = (int)ARRAY_SIZE(expr_table); --i >= 0; ) {
if (STRCMP(arg + 5, expr_table[i]) == 0) {
STRCPY(d, arg);
break;
}
}
} else {
// Recognize a few exceptions to the rule. Some strings that contain
// '*' with "star". Otherwise '*' is recognized as a wildcard.
for (i = (int)ARRAY_SIZE(mtable); --i >= 0; ) {
if (STRCMP(arg, mtable[i]) == 0) {
STRCPY(d, rtable[i]);
break;
}
}
}
if (i < 0) { /* no match in table */
/* Replace "\S" with "/\\S", etc. Otherwise every tag is matched.

View File

@@ -38,11 +38,34 @@ func Test_help_tagjump()
call assert_true(getline('.') =~ '\*:?\*')
helpclose
help q?
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*q?\*')
call assert_true(expand('<cword>') == 'q?')
helpclose
help -?
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*-?\*')
helpclose
help v_g?
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*v_g?\*')
helpclose
help expr-!=?
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*expr-!=?\*')
call assert_true(expand('<cword>') == 'expr-!=?')
helpclose
help expr-isnot?
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*expr-isnot?\*')
call assert_true(expand('<cword>') == 'expr-isnot?')
helpclose
help FileW*Post
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*FileWritePost\*')