1
0
forked from aniani/vim

patch 8.0.0613: the conf filetype is used before ftdetect from packages

Problem:    The conf filetype detection is done before ftdetect scripts from
            packages that are added later.
Solution:   Add the FALLBACK argument to :setfiletype. (closes #1679,
            closes #1693)
This commit is contained in:
Bram Moolenaar
2017-06-04 19:00:32 +02:00
parent ce876aaa9a
commit 3e54569b17
6 changed files with 84 additions and 9 deletions

View File

@@ -16,6 +16,7 @@ source test_expr.vim
source test_feedkeys.vim
source test_file_perm.vim
source test_fileformat.vim
source test_filetype.vim
source test_filter_cmd.vim
source test_filter_map.vim
source test_findfile.vim

View File

@@ -0,0 +1,43 @@
" Test :setfiletype
func Test_detection()
filetype on
augroup filetypedetect
au BufNewFile,BufRead * call assert_equal(1, did_filetype())
augroup END
new something.vim
call assert_equal('vim', &filetype)
bwipe!
filetype off
endfunc
func Test_conf_type()
filetype on
call writefile(['# some comment', 'must be conf'], 'Xfile')
augroup filetypedetect
au BufNewFile,BufRead * call assert_equal(0, did_filetype())
augroup END
split Xfile
call assert_equal('conf', &filetype)
bwipe!
call delete('Xfile')
filetype off
endfunc
func Test_other_type()
filetype on
augroup filetypedetect
au BufNewFile,BufRead * call assert_equal(0, did_filetype())
au BufNewFile,BufRead Xfile setf testfile
au BufNewFile,BufRead * call assert_equal(1, did_filetype())
augroup END
call writefile(['# some comment', 'must be conf'], 'Xfile')
split Xfile
call assert_equal('testfile', &filetype)
bwipe!
call delete('Xfile')
filetype off
endfunc