commit 65a4c8f3caf8472778500408c69c5d1c9f82943b
parent abc96ba0ce306ea162d1ceb5133d3b82d0558e2e
Author: brianhuster <phambinhanctb2004@gmail.com>
Date: Thu, 1 May 2025 23:16:57 +0700
vim-patch:9.1.1357: Vim incorrectly escapes tags with "[" in a help buffer
Problem: Vim incorrectly escapes tags containing "[" in a help buffer
Solution: check if the buffer has the "help" filetype set, instead of
already being a help buffer (Phạm Bình An)
fixes: vim/vim#17224
closes: vim/vim#17232
https://github.com/vim/vim/commit/6af20a9be3312045c38ca24b93f2d5d0d70da0b1
Co-authored-by: Phạm Bình An <phambinhanctb2004@gmail.com>
Co-authored-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Diffstat:
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
@@ -3500,7 +3500,7 @@ static void nv_ident(cmdarg_T *cap)
} else if (cmdchar == '#') {
aux_ptr = (magic_isset() ? "/?.*~[^$\\" : "/?^$\\");
} else if (tag_cmd) {
- if (curbuf->b_help) {
+ if (strcmp(curbuf->b_p_ft, "help") == 0) {
// ":help" handles unescaped argument
aux_ptr = "";
} else {
diff --git a/test/old/testdir/test_help.vim b/test/old/testdir/test_help.vim
@@ -225,5 +225,22 @@ func Test_help_using_visual_match()
call CheckScriptFailure(lines, 'E149:')
endfunc
+func Test_helptag_navigation()
+ let helpdir = tempname()
+ let tempfile = helpdir . '/test.txt'
+ call mkdir(helpdir, 'pR')
+ call writefile(['', '*[tag*', '', '|[tag|'], tempfile)
+ exe 'helptags' helpdir
+ exe 'sp' tempfile
+ exe 'lcd' helpdir
+ setl ft=help
+ let &l:iskeyword='!-~,^*,^|,^",192-255'
+ call cursor(4, 2)
+ " Vim must not escape `[` when expanding the tag
+ exe "normal! \<C-]>"
+ call assert_equal(2, line('.'))
+ bw
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab