mirror of
https://github.com/vim/vim.git
synced 2025-07-25 10:54:51 -04:00
patch 9.1.1194: filetype: false positive help filetype detection
Problem: filetype: false positive help filetype detection Solution: Only detect a file as help if modeline appears either at start of line or is preceded by whitespace (zeertzjq). closes: #16845 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
c2623824a7
commit
6763b0ee95
@ -1,7 +1,7 @@
|
|||||||
" Vim support file to detect file types
|
" Vim support file to detect file types
|
||||||
"
|
"
|
||||||
" Maintainer: The Vim Project <https://github.com/vim/vim>
|
" Maintainer: The Vim Project <https://github.com/vim/vim>
|
||||||
" Last Change: 2025 Mar 08
|
" Last Change: 2025 Mar 10
|
||||||
" Former Maintainer: Bram Moolenaar <Bram@vim.org>
|
" Former Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||||
|
|
||||||
" Listen very carefully, I will say this only once
|
" Listen very carefully, I will say this only once
|
||||||
@ -53,7 +53,7 @@ endfunc
|
|||||||
|
|
||||||
" Vim help file, set ft explicitly, because 'modeline' might be off
|
" Vim help file, set ft explicitly, because 'modeline' might be off
|
||||||
au BufNewFile,BufRead */doc/*.txt
|
au BufNewFile,BufRead */doc/*.txt
|
||||||
\ if getline('$') =~ 'vim:.*\<\(ft\|filetype\)=help\>'
|
\ if getline('$') =~ '\(^\|\s\)vim:.*\<\(ft\|filetype\)=help\>'
|
||||||
\| setf help
|
\| setf help
|
||||||
\| endif
|
\| endif
|
||||||
|
|
||||||
|
@ -1634,11 +1634,22 @@ func Test_help_file()
|
|||||||
call assert_equal('help', &filetype)
|
call assert_equal('help', &filetype)
|
||||||
bwipe!
|
bwipe!
|
||||||
|
|
||||||
|
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 writefile(['some text'], 'doc/nothelp.txt', 'D')
|
call writefile(['some text'], 'doc/nothelp.txt', 'D')
|
||||||
split doc/nothelp.txt
|
split doc/nothelp.txt
|
||||||
call assert_notequal('help', &filetype)
|
call assert_notequal('help', &filetype)
|
||||||
bwipe!
|
bwipe!
|
||||||
|
|
||||||
|
call writefile(['some text', '`vim:ft=help`'], 'doc/nothelp1.txt', 'D')
|
||||||
|
split doc/nothelp1.txt
|
||||||
|
call assert_notequal('help', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
filetype off
|
filetype off
|
||||||
set modeline&
|
set modeline&
|
||||||
endfunc
|
endfunc
|
||||||
|
@ -704,6 +704,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1194,
|
||||||
/**/
|
/**/
|
||||||
1193,
|
1193,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user