mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.1835: ":help ??" finds the "!!" tag (#18350)
* vim-patch:8.2.1835: ":help ??" finds the "!!" tag
Problem: ":help ??" finds the "!!" tag.
Solution: Do not translate "?" into ".". (Naruhiko Nishino, closes vim/vim#7114,
closes vim/vim#7115)
6eb36ade98
Change test because patch 8.2.1794 hasn't been ported yet.
This commit is contained in:
parent
1e970c003f
commit
327a6d885c
@ -5023,37 +5023,59 @@ static int help_compare(const void *s1, const void *s2)
|
|||||||
int find_help_tags(const char *arg, int *num_matches, char ***matches, bool keep_lang)
|
int find_help_tags(const char *arg, int *num_matches, char ***matches, bool keep_lang)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
static const char *(mtable[]) = {
|
|
||||||
"*", "g*", "[*", "]*",
|
// Specific tags that either have a specific replacement or won't go
|
||||||
"/*", "/\\*", "\"*", "**",
|
// throught the generic rules.
|
||||||
"/\\(\\)", "/\\%(\\)",
|
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" }, // NOLINT
|
||||||
"s/\\~", "s/\\U", "s/\\L",
|
{ "/\\*", "/\\\\star" },
|
||||||
"s/\\1", "s/\\2", "s/\\3", "s/\\9"
|
{ "\"*", "quotestar" },
|
||||||
};
|
{ "**", "starstar" },
|
||||||
static const char *(rtable[]) = {
|
{ "cpo-*", "cpo-star" },
|
||||||
"star", "gstar", "[star", "]star",
|
{ "/\\(\\)", "/\\\\(\\\\)" },
|
||||||
"/star", "/\\\\star", "quotestar", "starstar",
|
{ "/\\%(\\)", "/\\\\%(\\\\)" },
|
||||||
"/\\\\(\\\\)", "/\\\\%(\\\\)",
|
{ "?", "?" },
|
||||||
"?", ":?", "?<CR>", "g?", "g?g?", "g??",
|
{ "??", "??" },
|
||||||
"-?", "q?", "v_g?",
|
{ ":?", ":?" },
|
||||||
"/\\\\?", "/\\\\z(\\\\)", "\\\\=", ":s\\\\=",
|
{ "?<CR>", "?<CR>" },
|
||||||
"\\[count]", "\\[quotex]",
|
{ "g?", "g?" },
|
||||||
"\\[range]", ":\\[range]",
|
{ "g?g?", "g?g?" },
|
||||||
"\\[pattern]", "\\\\bar", "/\\\\%\\$",
|
{ "g??", "g??" },
|
||||||
"s/\\\\\\~", "s/\\\\U", "s/\\\\L",
|
{ "-?", "-?" },
|
||||||
"s/\\\\1", "s/\\\\2", "s/\\\\3", "s/\\\\9"
|
{ "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 const char *(expr_table[]) = {
|
static const char *(expr_table[]) = {
|
||||||
"!=?", "!~?", "<=?", "<?", "==?", "=~?",
|
"!=?", "!~?", "<=?", "<?", "==?", "=~?",
|
||||||
">=?", ">?", "is?", "isnot?"
|
">=?", ">?", "is?", "isnot?"
|
||||||
};
|
};
|
||||||
char *d = (char *)IObuff; // assume IObuff is long enough!
|
char *d = (char *)IObuff; // assume IObuff is long enough!
|
||||||
|
d[0] = NUL;
|
||||||
|
|
||||||
if (STRNICMP(arg, "expr-", 5) == 0) {
|
if (STRNICMP(arg, "expr-", 5) == 0) {
|
||||||
// When the string starting with "expr-" and containing '?' and matches
|
// When the string starting with "expr-" and containing '?' and matches
|
||||||
@ -5075,16 +5097,16 @@ int find_help_tags(const char *arg, int *num_matches, char ***matches, bool keep
|
|||||||
}
|
}
|
||||||
} 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)ARRAY_SIZE(mtable); --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.
|
||||||
// Also "\zs", "\z1", etc.
|
// Also "\zs", "\z1", etc.
|
||||||
|
@ -28,11 +28,25 @@ 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\*')
|
||||||
helpclose
|
helpclose
|
||||||
|
|
||||||
|
" The test result is different in vim. There ":help ??" will jump to the
|
||||||
|
" falsy operator ??, which hasn't been ported to neovim yet. Instead, neovim
|
||||||
|
" jumps to the tag "g??". This test result needs to be changed if neovim
|
||||||
|
" ports the falsy operator.
|
||||||
|
help ??
|
||||||
|
call assert_equal("help", &filetype)
|
||||||
|
call assert_true(getline('.') =~ '\*g??\*')
|
||||||
|
helpclose
|
||||||
|
|
||||||
help ch?ckhealth
|
help ch?ckhealth
|
||||||
call assert_equal("help", &filetype)
|
call assert_equal("help", &filetype)
|
||||||
call assert_true(getline('.') =~ '\*:checkhealth\*')
|
call assert_true(getline('.') =~ '\*:checkhealth\*')
|
||||||
|
Loading…
Reference in New Issue
Block a user