diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-06-04 19:00:32 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-06-04 19:00:32 +0200 |
commit | 3e54569b17683318e0cb6693ab0024c2ad1e3e8f (patch) | |
tree | 53920e6f30fd8390d9232bd7062959c802d6ba64 /src | |
parent | ce876aaa9a250a5a0d0e34b3a2625e51cf9bf5bb (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')
-rw-r--r-- | src/Makefile | 1 | ||||
-rw-r--r-- | src/ex_docmd.c | 13 | ||||
-rw-r--r-- | src/testdir/test_alot.vim | 1 | ||||
-rw-r--r-- | src/testdir/test_filetype.vim | 43 | ||||
-rw-r--r-- | src/version.c | 2 |
5 files changed, 58 insertions, 2 deletions
diff --git a/src/Makefile b/src/Makefile index ddb61dc08a..8fa004e8f7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2133,6 +2133,7 @@ test_arglist \ test_feedkeys \ test_file_perm \ test_fileformat \ + test_filetype \ test_filter_cmd \ test_filter_map \ test_findfile \ diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 13d5fe495e..2c9c8782e7 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -12172,13 +12172,22 @@ ex_filetype(exarg_T *eap) } /* - * ":setfiletype {name}" + * ":setfiletype [FALLBACK] {name}" */ static void ex_setfiletype(exarg_T *eap) { if (!did_filetype) - set_option_value((char_u *)"filetype", 0L, eap->arg, OPT_LOCAL); + { + char_u *arg = eap->arg; + + if (STRNCMP(arg, "FALLBACK ", 9) == 0) + arg += 9; + + set_option_value((char_u *)"filetype", 0L, arg, OPT_LOCAL); + if (arg != eap->arg) + did_filetype = FALSE; + } } #endif diff --git a/src/testdir/test_alot.vim b/src/testdir/test_alot.vim index e961e99451..fec22714e7 100644 --- a/src/testdir/test_alot.vim +++ b/src/testdir/test_alot.vim @@ -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 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 diff --git a/src/version.c b/src/version.c index 91cd500526..f5b5732ad7 100644 --- a/src/version.c +++ b/src/version.c @@ -765,6 +765,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 613, +/**/ 612, /**/ 611, |