0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.1.1017: off-by-one error in filetype detection

Problem:    Off-by-one error in filetype detection.
Solution:   Also check the last line of the file.
This commit is contained in:
Bram Moolenaar 2019-03-17 17:16:12 +01:00
parent 26967617a3
commit 493fbe4abe
2 changed files with 8 additions and 6 deletions

View File

@ -197,7 +197,7 @@ func dist#ft#FTe()
exe 'setf ' . g:filetype_euphoria exe 'setf ' . g:filetype_euphoria
else else
let n = 1 let n = 1
while n < 100 && n < line("$") while n < 100 && n <= line("$")
if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$" if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$"
setf specman setf specman
return return
@ -211,7 +211,7 @@ endfunc
" Distinguish between HTML, XHTML and Django " Distinguish between HTML, XHTML and Django
func dist#ft#FThtml() func dist#ft#FThtml()
let n = 1 let n = 1
while n < 10 && n < line("$") while n < 10 && n <= line("$")
if getline(n) =~ '\<DTD\s\+XHTML\s' if getline(n) =~ '\<DTD\s\+XHTML\s'
setf xhtml setf xhtml
return return
@ -222,13 +222,13 @@ func dist#ft#FThtml()
endif endif
let n = n + 1 let n = n + 1
endwhile endwhile
setf html setf FALLBACK html
endfunc endfunc
" Distinguish between standard IDL and MS-IDL " Distinguish between standard IDL and MS-IDL
func dist#ft#FTidl() func dist#ft#FTidl()
let n = 1 let n = 1
while n < 50 && n < line("$") while n < 50 && n <= line("$")
if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"' if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"'
setf msidl setf msidl
return return
@ -699,7 +699,7 @@ endfunc
func dist#ft#FTxml() func dist#ft#FTxml()
let n = 1 let n = 1
while n < 100 && n < line("$") while n < 100 && n <= line("$")
let line = getline(n) let line = getline(n)
" DocBook 4 or DocBook 5. " DocBook 4 or DocBook 5.
let is_docbook4 = line =~ '<!DOCTYPE.*DocBook' let is_docbook4 = line =~ '<!DOCTYPE.*DocBook'
@ -725,7 +725,7 @@ endfunc
func dist#ft#FTy() func dist#ft#FTy()
let n = 1 let n = 1
while n < 100 && n < line("$") while n < 100 && n <= line("$")
let line = getline(n) let line = getline(n)
if line =~ '^\s*%' if line =~ '^\s*%'
setf yacc setf yacc

View File

@ -779,6 +779,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1017,
/**/ /**/
1016, 1016,
/**/ /**/