mirror of
https://github.com/neovim/neovim.git
synced 2025-10-01 15:38:33 +00:00
vim-patch:8.2.4305: tex filetype detection fails
Problem: Tex filetype detection fails.
Solution: Check value to be positive. (closes vim/vim#9704)
e5b7897585
This commit is contained in:
5
runtime/autoload/dist/ft.vim
vendored
5
runtime/autoload/dist/ft.vim
vendored
@@ -726,7 +726,7 @@ func dist#ft#FTperl()
|
|||||||
endif
|
endif
|
||||||
let save_cursor = getpos('.')
|
let save_cursor = getpos('.')
|
||||||
call cursor(1,1)
|
call cursor(1,1)
|
||||||
let has_use = search('^use\s\s*\k', 'c', 30)
|
let has_use = search('^use\s\s*\k', 'c', 30) > 0
|
||||||
call setpos('.', save_cursor)
|
call setpos('.', save_cursor)
|
||||||
if has_use
|
if has_use
|
||||||
setf perl
|
setf perl
|
||||||
@@ -758,7 +758,8 @@ func dist#ft#FTtex()
|
|||||||
let save_cursor = getpos('.')
|
let save_cursor = getpos('.')
|
||||||
call cursor(1,1)
|
call cursor(1,1)
|
||||||
let firstNC = search('^\s*[^[:space:]%]', 'c', 1000)
|
let firstNC = search('^\s*[^[:space:]%]', 'c', 1000)
|
||||||
if firstNC " Check the next thousand lines for a LaTeX or ConTeXt keyword.
|
if firstNC > 0
|
||||||
|
" Check the next thousand lines for a LaTeX or ConTeXt keyword.
|
||||||
let lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>'
|
let lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>'
|
||||||
let cpat = 'start\a\+\|setup\a\+\|usemodule\|enablemode\|enableregime\|setvariables\|useencoding\|usesymbols\|stelle\a\+\|verwende\a\+\|stel\a\+\|gebruik\a\+\|usa\a\+\|imposta\a\+\|regle\a\+\|utilisemodule\>'
|
let cpat = 'start\a\+\|setup\a\+\|usemodule\|enablemode\|enableregime\|setvariables\|useencoding\|usesymbols\|stelle\a\+\|verwende\a\+\|stel\a\+\|gebruik\a\+\|usa\a\+\|imposta\a\+\|regle\a\+\|utilisemodule\>'
|
||||||
let kwline = search('^\s*\\\%(' . lpat . '\)\|^\s*\\\(' . cpat . '\)',
|
let kwline = search('^\s*\\\%(' . lpat . '\)\|^\s*\\\(' . cpat . '\)',
|
||||||
|
@@ -1277,4 +1277,23 @@ func Test_frm_file()
|
|||||||
filetype off
|
filetype off
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_tex_file()
|
||||||
|
filetype on
|
||||||
|
|
||||||
|
" only tests one case, should do more
|
||||||
|
let lines =<< trim END
|
||||||
|
% This is a sentence.
|
||||||
|
|
||||||
|
This is a sentence.
|
||||||
|
END
|
||||||
|
call writefile(lines, "Xfile.tex")
|
||||||
|
split Xfile.tex
|
||||||
|
call assert_equal('plaintex', &filetype)
|
||||||
|
bwipe
|
||||||
|
|
||||||
|
call delete('Xfile.tex')
|
||||||
|
filetype off
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Reference in New Issue
Block a user