diff options
-rw-r--r-- | contrib/flake.nix | 4 | ||||
-rw-r--r-- | src/nvim/autocmd.c | 7 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 82 | ||||
-rw-r--r-- | src/nvim/testdir/test_help_tagjump.vim | 14 |
4 files changed, 74 insertions, 33 deletions
diff --git a/contrib/flake.nix b/contrib/flake.nix index 848c52d208..a1072674ba 100644 --- a/contrib/flake.nix +++ b/contrib/flake.nix @@ -16,6 +16,10 @@ neovim = pkgs.neovim-unwrapped.overrideAttrs (oa: { version = "master"; src = ../.; + + buildInputs = oa.buildInputs ++ pkgs.lib.optionals pkgs.stdenv.isDarwin (with pkgs.darwin.apple_sdk.frameworks; [ + CoreServices + ]); }); # a development binary to help debug issues diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index bfeb70dce9..9bc0a4fabf 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -1191,8 +1191,9 @@ char_u *aucmd_next_pattern(char_u *pat, size_t patlen) /// Return OK for success, FAIL for failure; /// /// @param do_msg give message for no matching autocmds? -int do_doautocmd(char_u *arg, bool do_msg, bool *did_something) +int do_doautocmd(char_u *arg_start, bool do_msg, bool *did_something) { + char_u *arg = arg_start; int nothing_done = true; if (did_something != NULL) { @@ -1224,8 +1225,8 @@ int do_doautocmd(char_u *arg, bool do_msg, bool *did_something) } } - if (nothing_done && do_msg) { - msg(_("No matching autocommands")); + if (nothing_done && do_msg && !aborting()) { + smsg(_("No matching autocommands: %s"), arg_start); } if (did_something != NULL) { *did_something = !nothing_done; diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 5cd3e7f968..06fa981ba7 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -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 i; - static const char *(mtable[]) = { - "*", "g*", "[*", "]*", - "/*", "/\\*", "\"*", "**", - "/\\(\\)", "/\\%(\\)", - "?", ":?", "?<CR>", "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 const char *(rtable[]) = { - "star", "gstar", "[star", "]star", - "/star", "/\\\\star", "quotestar", "starstar", - "/\\\\(\\\\)", "/\\\\%(\\\\)", - "?", ":?", "?<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" + + // 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" }, // NOLINT + { "/\\*", "/\\\\star" }, + { "\"*", "quotestar" }, + { "**", "starstar" }, + { "cpo-*", "cpo-star" }, + { "/\\(\\)", "/\\\\(\\\\)" }, + { "/\\%(\\)", "/\\\\%(\\\\)" }, + { "?", "?" }, + { "??", "??" }, + { ":?", ":?" }, + { "?<CR>", "?<CR>" }, + { "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 const char *(expr_table[]) = { "!=?", "!~?", "<=?", "<?", "==?", "=~?", ">=?", ">?", "is?", "isnot?" }; char *d = (char *)IObuff; // assume IObuff is long enough! + d[0] = NUL; if (STRNICMP(arg, "expr-", 5) == 0) { // 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 { // 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]); + // '*'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, 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. // Also "\zs", "\z1", etc. diff --git a/src/nvim/testdir/test_help_tagjump.vim b/src/nvim/testdir/test_help_tagjump.vim index a43889b57e..ece8ccf215 100644 --- a/src/nvim/testdir/test_help_tagjump.vim +++ b/src/nvim/testdir/test_help_tagjump.vim @@ -28,11 +28,25 @@ 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\*') 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 call assert_equal("help", &filetype) call assert_true(getline('.') =~ '\*:checkhealth\*') |