patch 9.1.1194: filetype: false positive help filetype detection

Commit: 
https://github.com/vim/vim/commit/6763b0ee95e7e66ab7992653fbba48691e803e70
Author: zeertzjq <zeert...@outlook.com>
Date:   Mon Mar 10 21:30:29 2025 +0100

    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 <zeert...@outlook.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 0ee875ca7..77ca3a3c7 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -1,7 +1,7 @@
 " Vim support file to detect file types
 "
 " Maintainer:  The Vim Project <https://github.com/vim/vim>
-" Last Change: 2025 Mar 08
+" Last Change: 2025 Mar 10
 " Former Maintainer:   Bram Moolenaar <b...@vim.org>
 
 " 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
 au BufNewFile,BufRead */doc/*.txt
-       \  if getline('$') =~ 'vim:.*\<\(ft\|filetype\)=help\>'
+       \  if getline('$') =~ '\(^\|\s\)vim:.*\<\(ft\|filetype\)=help\>'
        \|   setf help
        \| endif
 
diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim
index ae69a04e4..84a4864a4 100644
--- a/src/testdir/test_filetype.vim
+++ b/src/testdir/test_filetype.vim
@@ -1634,11 +1634,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
diff --git a/src/version.c b/src/version.c
index bc21b037e..33758889d 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 */
+/**/
+    1194,
 /**/
     1193,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1trjzi-002iEM-QA%40256bit.org.

Raspunde prin e-mail lui