summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_filetype.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-06-04 19:00:32 +0200
committerBram Moolenaar <Bram@vim.org>2017-06-04 19:00:32 +0200
commit3e54569b17683318e0cb6693ab0024c2ad1e3e8f (patch)
tree53920e6f30fd8390d9232bd7062959c802d6ba64 /src/testdir/test_filetype.vim
parentce876aaa9a250a5a0d0e34b3a2625e51cf9bf5bb (diff)
patch 8.0.0613: the conf filetype is used before ftdetect from packagesv8.0.0613
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)
Diffstat (limited to 'src/testdir/test_filetype.vim')
-rw-r--r--src/testdir/test_filetype.vim43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim
new file mode 100644
index 0000000000..818603b180
--- /dev/null
+++ b/src/testdir/test_filetype.vim
@@ -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