comparison runtime/autoload/dist/ft.vim @ 27557:ce72087b601f v8.2.4305

patch 8.2.4305: tex filetype detection fails Commit: https://github.com/vim/vim/commit/e5b7897585eccec84431d8b23df5cde2e283828c Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 5 19:50:34 2022 +0000 patch 8.2.4305: tex filetype detection fails Problem: Tex filetype detection fails. Solution: Check value to be positive. (closes https://github.com/vim/vim/issues/9704)
author Bram Moolenaar <Bram@vim.org>
date Sat, 05 Feb 2022 21:00:03 +0100
parents f37561549ec2
children e63514ae0c29
comparison
equal deleted inserted replaced
27556:b940866eac65 27557:ce72087b601f
1 vim9script 1 vim9script
2 2
3 # Vim functions for file type detection 3 # Vim functions for file type detection
4 # 4 #
5 # Maintainer: Bram Moolenaar <Bram@vim.org> 5 # Maintainer: Bram Moolenaar <Bram@vim.org>
6 # Last Change: 2022 Feb 04 6 # Last Change: 2022 Feb 05
7 7
8 # These functions are moved here from runtime/filetype.vim to make startup 8 # These functions are moved here from runtime/filetype.vim to make startup
9 # faster. 9 # faster.
10 10
11 export def Check_inp() 11 export def Check_inp()
720 setf perl 720 setf perl
721 return 1 721 return 1
722 endif 722 endif
723 var save_cursor = getpos('.') 723 var save_cursor = getpos('.')
724 call cursor(1, 1) 724 call cursor(1, 1)
725 var has_use = search('^use\s\s*\k', 'c', 30) 725 var has_use = search('^use\s\s*\k', 'c', 30) > 0
726 call setpos('.', save_cursor) 726 call setpos('.', save_cursor)
727 if has_use 727 if has_use
728 setf perl 728 setf perl
729 return 1 729 return 1
730 endif 730 endif
753 format = exists("g:tex_flavor") ? g:tex_flavor : 'plain' 753 format = exists("g:tex_flavor") ? g:tex_flavor : 'plain'
754 # Save position, go to the top of the file, find first non-comment line. 754 # Save position, go to the top of the file, find first non-comment line.
755 var save_cursor = getpos('.') 755 var save_cursor = getpos('.')
756 call cursor(1, 1) 756 call cursor(1, 1)
757 var firstNC = search('^\s*[^[:space:]%]', 'c', 1000) 757 var firstNC = search('^\s*[^[:space:]%]', 'c', 1000)
758 if firstNC # Check the next thousand lines for a LaTeX or ConTeXt keyword. 758 if firstNC > 0
759 # Check the next thousand lines for a LaTeX or ConTeXt keyword.
759 var lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>' 760 var lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>'
760 var 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\>' 761 var 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\>'
761 var kwline = search('^\s*\\\%(' .. lpat .. '\)\|^\s*\\\(' .. cpat .. '\)', 762 var kwline = search('^\s*\\\%(' .. lpat .. '\)\|^\s*\\\(' .. cpat .. '\)',
762 'cnp', firstNC + 1000) 763 'cnp', firstNC + 1000)
763 if kwline == 1 # lpat matched 764 if kwline == 1 # lpat matched