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

6af20a9be3

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>
This commit is contained in:
brianhuster
2025-05-01 23:16:57 +07:00
committed by zeertzjq
parent abc96ba0ce
commit 65a4c8f3ca
2 changed files with 18 additions and 1 deletions

View File

@@ -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 {

View File

@@ -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