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

6763b0ee95
This commit is contained in:
zeertzjq
2025-03-11 06:23:12 +08:00
parent 4281a514e9
commit 4533c40786
2 changed files with 12 additions and 1 deletions

View File

@@ -2417,7 +2417,7 @@ local pattern = {
['^%.?gtkrc'] = starsetf('gtkrc'),
['/doc/.*%.txt$'] = function(_, bufnr)
local line = M._getline(bufnr, -1)
local ml = line:find('vim:')
local ml = line:find('^vim:') or line:find('%svim:')
if ml and M._matchregex(line:sub(ml), [[\<\(ft\|filetype\)=help\>]]) then
return 'help'
end