Commit: patch 9.1.1286: filetype: help files not detected when 'iskeyword' includes ":"

0 views
Skip to first unread message

Christian Brabandt

unread,
Apr 7, 2025, 3:30:13 PM4/7/25
to vim...@googlegroups.com
patch 9.1.1286: filetype: help files not detected when 'iskeyword' includes ":"

Commit: https://github.com/vim/vim/commit/e370141bf41919642061ee2e78340dca84678712
Author: zeertzjq <zeer...@outlook.com>
Date: Mon Apr 7 21:14:41 2025 +0200

patch 9.1.1286: filetype: help files not detected when 'iskeyword' includes ":"

Problem: Help files not detected when 'iskeyword' includes ":".
Solution: Do not use \< and \> in the pattern (zeertzjq).

fixes: #17069
closes: #17071

Signed-off-by: zeertzjq <zeer...@outlook.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 59e6a810b..2d9d3ad6f 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -53,7 +53,7 @@ endfunc

" Vim help file, set ft explicitly, because 'modeline' might be off
au BufNewFile,BufRead */doc/*.txt
- \ if getline('$') =~ '\(^\|\s\)vim:.*\<\(ft\|filetype\)=help\>'
+ \ if getline('$') =~ '\%(^\|\s\)vim:\%(.*\%(:\|\s\)\)\?\%(ft\|filetype\)=help\%(:\|\s\|$\)'
\| setf help
\| endif

diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim
index f6948e669..e2286abd3 100644
--- a/src/testdir/test_filetype.vim
+++ b/src/testdir/test_filetype.vim
@@ -1635,20 +1635,36 @@ func Test_haredoc_file()
endfunc

func Test_help_file()
+ func! s:Check_help_with_iskeyword(fname)
+ exe 'split' a:fname
+ call assert_equal('help', &filetype)
+ bwipe!
+ set iskeyword+=:
+ exe 'split' a:fname
+ call assert_equal('help', &filetype)
+ bwipe!
+ set iskeyword&
+ endfunc
+
set nomodeline
filetype on
call assert_true(mkdir('doc', 'pR'))

call writefile(['some text', 'vim:ft=help:'], 'doc/help.txt', 'D')
- split doc/help.txt
- call assert_equal('help', &filetype)
- bwipe!
+ call s:Check_help_with_iskeyword('doc/help.txt')

call writefile(['some text', 'Copyright: |manual-copyright| vim:ft=help:'],
\ 'doc/help1.txt', 'D')
- split doc/help1.txt
- call assert_equal('help', &filetype)
- bwipe!
+ call s:Check_help_with_iskeyword('doc/help1.txt')
+
+ call writefile(['some text', 'vim:noet:ft=help:'], 'doc/help2.txt', 'D')
+ call s:Check_help_with_iskeyword('doc/help2.txt')
+
+ call writefile(['some text', 'vim: noet ft=help'], 'doc/help3.txt', 'D')
+ call s:Check_help_with_iskeyword('doc/help3.txt')
+
+ call writefile(['some text', 'vim: ft=help noet'], 'doc/help4.txt', 'D')
+ call s:Check_help_with_iskeyword('doc/help4.txt')

call writefile(['some text'], 'doc/nothelp.txt', 'D')
split doc/nothelp.txt
diff --git a/src/version.c b/src/version.c
index 466fdd5c2..259fbc0e8 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1286,
/**/
1285,
/**/
Reply all
Reply to author
Forward
0 new messages