Skip to content

Commit 664fd12

Browse files
zeertzjqbrammool
authored andcommitted
patch 9.0.1601: filetype detection fails for *.conf file without comments
Problem: Filetype detection fails for *.conf file without comments. (Dmitrii Tcyganok) Solution: Use "conf" filetype as a fallback for an empty .conf file. (closes #12487, closes #12483)
1 parent f0e68c0 commit 664fd12

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

runtime/filetype.vim

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2811,8 +2811,10 @@ augroup END
28112811
" Generic configuration file. Use FALLBACK, it's just guessing!
28122812
au filetypedetect BufNewFile,BufRead,StdinReadPost *
28132813
\ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
2814-
\ && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#'
2815-
\ || getline(4) =~ '^#' || getline(5) =~ '^#') |
2814+
\ && (expand("<amatch>") =~# '\.conf$'
2815+
\ || getline(1) =~ '^#' || getline(2) =~ '^#'
2816+
\ || getline(3) =~ '^#' || getline(4) =~ '^#'
2817+
\ || getline(5) =~ '^#') |
28162818
\ setf FALLBACK conf |
28172819
\ endif
28182820

src/testdir/test_filetype.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def s:GetFilenameChecks(): dict<list<string>>
122122
cobol: ['file.cbl', 'file.cob', 'file.lib'],
123123
coco: ['file.atg'],
124124
conaryrecipe: ['file.recipe'],
125-
conf: ['auto.master'],
125+
conf: ['auto.master', 'file.conf'],
126126
config: ['configure.in', 'configure.ac', '/etc/hostname.file', 'any/etc/hostname.file'],
127127
confini: ['/etc/pacman.conf', 'any/etc/pacman.conf', 'mpv.conf', 'any/.aws/config', 'any/.aws/credentials', 'file.nmconnection'],
128128
context: ['tex/context/any/file.tex', 'file.mkii', 'file.mkiv', 'file.mkvi', 'file.mkxl', 'file.mklx'],

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,8 @@ static char *(features[]) =
695695

696696
static int included_patches[] =
697697
{ /* Add new patch number below this line */
698+
/**/
699+
1601,
698700
/**/
699701
1600,
700702
/**/

0 commit comments

Comments
 (0)