From 1b3e6e7594e1dd387207ffe304f2583e61afcb77 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sat, 31 Dec 2022 16:00:01 +0100 Subject: [PATCH] vim-patch:9.0.1120: tex filetype detection not sufficiently tested Problem: Tex filetype detection not sufficiently tested. Solution: Add more test cases for "tex" detection. (Jonas Strittmatter, closes vim/vim#11765) https://github.com/vim/vim/commit/c55e8f2c6f5cafe11494df3e2d28ff3d03b92c71 Co-authored-by: smjonas --- src/nvim/testdir/test_filetype.vim | 40 +++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index cf155b3cb9..912e702631 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -1676,17 +1676,45 @@ endfunc func Test_tex_file() filetype on - " only tests one case, should do more - let lines =<< trim END - % This is a sentence. + call writefile(['%& pdflatex'], 'Xfile.tex') + split Xfile.tex + call assert_equal('tex', &filetype) + bwipe - This is a sentence. - END - call writefile(lines, "Xfile.tex") + call writefile(['\newcommand{\test}{some text}'], 'Xfile.tex') + split Xfile.tex + call assert_equal('tex', &filetype) + bwipe + + " tex_flavor is unset + call writefile(['%& plain'], 'Xfile.tex') split Xfile.tex call assert_equal('plaintex', &filetype) bwipe + let g:tex_flavor = 'plain' + call writefile(['just some text'], 'Xfile.tex') + split Xfile.tex + call assert_equal('plaintex', &filetype) + bwipe + + let lines =<< trim END + % This is a comment. + + \usemodule[translate] + END + call writefile(lines, 'Xfile.tex') + split Xfile.tex + call assert_equal('context', &filetype) + bwipe + + let g:tex_flavor = 'context' + call writefile(['just some text'], 'Xfile.tex') + split Xfile.tex + call assert_equal('context', &filetype) + bwipe + unlet g:tex_flavor + call delete('Xfile.tex') filetype off endfunc