aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2025-04-08 08:13:12 +0800
committerGitHub <noreply@github.com>2025-04-08 00:13:12 +0000
commit8af9f8ab5ecd59df52aed9019e8ecc9f8101ee7d (patch)
tree438fbabbea79543cd29f660606a2e81ac87f9c60
parent1ffc7d6bf89c9fedf79486f5714e665c65b383ce (diff)
downloadrneovim-8af9f8ab5ecd59df52aed9019e8ecc9f8101ee7d.tar.gz
rneovim-8af9f8ab5ecd59df52aed9019e8ecc9f8101ee7d.tar.bz2
rneovim-8af9f8ab5ecd59df52aed9019e8ecc9f8101ee7d.zip
vim-patch:9.1.1286: filetype: help files not detected when 'iskeyword' includes ":" (#33377)
Problem: Help files not detected when 'iskeyword' includes ":". Solution: Do not use \< and \> in the pattern (zeertzjq). fixes: vim/vim#17069 closes: vim/vim#17071 https://github.com/vim/vim/commit/e370141bf41919642061ee2e78340dca84678712
-rw-r--r--runtime/lua/vim/filetype.lua22
-rw-r--r--test/old/testdir/test_filetype.vim28
2 files changed, 42 insertions, 8 deletions
diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua
index 64d39bab0a..832af32612 100644
--- a/runtime/lua/vim/filetype.lua
+++ b/runtime/lua/vim/filetype.lua
@@ -2429,8 +2429,26 @@ local pattern = {
['^%.?gtkrc'] = starsetf('gtkrc'),
['/doc/.*%.txt$'] = function(_, bufnr)
local line = M._getline(bufnr, -1)
- local ml = line:find('^vim:') or line:find('%svim:')
- if ml and M._matchregex(line:sub(ml), [[\<\(ft\|filetype\)=help\>]]) then
+ if
+ M._findany(line, {
+ '^vim:ft=help[:%s]',
+ '^vim:ft=help$',
+ '^vim:filetype=help[:%s]',
+ '^vim:filetype=help$',
+ '^vim:.*[:%s]ft=help[:%s]',
+ '^vim:.*[:%s]ft=help$',
+ '^vim:.*[:%s]filetype=help[:%s]',
+ '^vim:.*[:%s]filetype=help$',
+ '%svim:ft=help[:%s]',
+ '%svim:ft=help$',
+ '%svim:filetype=help[:%s]',
+ '%svim:filetype=help$',
+ '%svim:.*[:%s]ft=help[:%s]',
+ '%svim:.*[:%s]ft=help$',
+ '%svim:.*[:%s]filetype=help[:%s]',
+ '%svim:.*[:%s]filetype=help$',
+ })
+ then
return 'help'
end
end,
diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim
index e2863433eb..fd8d095b4e 100644
--- a/test/old/testdir/test_filetype.vim
+++ b/test/old/testdir/test_filetype.vim
@@ -1630,20 +1630,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