From 638b3c0717219ce152cbd255cbc878aa1b34ab95 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 11 Mar 2025 06:13:31 +0800 Subject: vim-patch:9.1.1186: filetype: help files in git repos are not detected Problem: filetype: help files in git repos are not detected Solution: detect */doc/*.txt files as help if they end with a help modeline, even if 'modeline' is off Here's how I checked that this would still detect vim's own help files correctly: $ find . -type f -path '*/doc/*.txt' \ > -exec awk '{ } ENDFILE { print FILENAME ":" $0; }' '{}' + | > grep -v 'vim:.*\<\(ft\|filetype\)=help\>' ./src/libvterm/doc/seqs.txt: 23 DECSM 42 = DECNRCM, national/multinational character closes: vim/vim#16817 https://github.com/vim/vim/commit/16d6fff98ed3a9dfd34a41696b005b0c4c7800f8 Split the pattern into a Lua pattern for the first part and a Vim regex pattern for the second part, so that if the first part doesn't match there is no need to use the Vim regex. Co-authored-by: David Mandelberg --- test/old/testdir/test_filetype.vim | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim index 296062f92c..0355956447 100644 --- a/test/old/testdir/test_filetype.vim +++ b/test/old/testdir/test_filetype.vim @@ -916,8 +916,6 @@ func s:GetFilenameChecks() abort \ '.zcompdump', '.zlogin', '.zlogout', '.zshenv', '.zshrc', '.zsh_history', \ '.zcompdump-file', '.zlog', '.zlog-file', '.zsh', '.zsh-file', \ 'any/etc/zprofile', 'zlog', 'zlog-file', 'zsh', 'zsh-file'], - \ - \ 'help': [$VIMRUNTIME .. '/doc/help.txt'], \ } endfunc @@ -1620,6 +1618,23 @@ func Test_haredoc_file() filetype off endfunc +func Test_help_file() + 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 writefile(['some text'], 'doc/nothelp.txt', 'D') + split doc/nothelp.txt + call assert_notequal('help', &filetype) + bwipe! + + filetype off +endfunc + func Test_hook_file() filetype on -- cgit From 4281a514e9b751a5a83b29659bdcc9dd8fcd5d06 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 11 Mar 2025 06:22:22 +0800 Subject: vim-patch:9.1.1191: tests: test for patch 9.1.1186 doesn't fail without the patch Problem: Test for patch 9.1.1186 doesn't fail without the patch. Solution: Set 'nomodeline' in the test (zeertzjq). closes: vim/vim#16835 https://github.com/vim/vim/commit/d6c7913e24e07c1d0ea099cda85e0014e8627c5c --- test/old/testdir/test_filetype.vim | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test') diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim index 0355956447..3d8772e477 100644 --- a/test/old/testdir/test_filetype.vim +++ b/test/old/testdir/test_filetype.vim @@ -1619,6 +1619,7 @@ func Test_haredoc_file() endfunc func Test_help_file() + set nomodeline filetype on call assert_true(mkdir('doc', 'pR')) @@ -1633,6 +1634,7 @@ func Test_help_file() bwipe! filetype off + set modeline& endfunc func Test_hook_file() -- cgit From 4533c40786a68d57b878babd46ea70e761392cf0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 11 Mar 2025 06:23:12 +0800 Subject: vim-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: vim/vim#16845 https://github.com/vim/vim/commit/6763b0ee95e7e66ab7992653fbba48691e803e70 --- test/old/testdir/test_filetype.vim | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test') diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim index 3d8772e477..633166c5ce 100644 --- a/test/old/testdir/test_filetype.vim +++ b/test/old/testdir/test_filetype.vim @@ -1628,11 +1628,22 @@ func Test_help_file() call assert_equal('help', &filetype) 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') split doc/nothelp.txt call assert_notequal('help', &filetype) bwipe! + call writefile(['some text', '`vim:ft=help`'], 'doc/nothelp1.txt', 'D') + split doc/nothelp1.txt + call assert_notequal('help', &filetype) + bwipe! + filetype off set modeline& endfunc -- cgit