mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	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:
		| @@ -2417,7 +2417,7 @@ local pattern = { | |||||||
|     ['^%.?gtkrc'] = starsetf('gtkrc'), |     ['^%.?gtkrc'] = starsetf('gtkrc'), | ||||||
|     ['/doc/.*%.txt$'] = function(_, bufnr) |     ['/doc/.*%.txt$'] = function(_, bufnr) | ||||||
|       local line = M._getline(bufnr, -1) |       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 |       if ml and M._matchregex(line:sub(ml), [[\<\(ft\|filetype\)=help\>]]) then | ||||||
|         return 'help' |         return 'help' | ||||||
|       end |       end | ||||||
|   | |||||||
| @@ -1628,11 +1628,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 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 zeertzjq
					zeertzjq