Mercurial > vim
comparison runtime/autoload/dist/ft.vim @ 16024:7fd3a9eaeedb v8.1.1017
patch 8.1.1017: off-by-one error in filetype detection
commit https://github.com/vim/vim/commit/493fbe4abee660d30b4f2aef87b754b0a720213c
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 17 17:16:12 2019 +0100
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 17 Mar 2019 17:30:14 +0100 |
parents | 963dd629d19a |
children | bd7461db24b3 |
comparison
equal
deleted
inserted
replaced
16023:dc766e1b0c95 | 16024:7fd3a9eaeedb |
---|---|
195 func dist#ft#FTe() | 195 func dist#ft#FTe() |
196 if exists('g:filetype_euphoria') | 196 if exists('g:filetype_euphoria') |
197 exe 'setf ' . g:filetype_euphoria | 197 exe 'setf ' . g:filetype_euphoria |
198 else | 198 else |
199 let n = 1 | 199 let n = 1 |
200 while n < 100 && n < line("$") | 200 while n < 100 && n <= line("$") |
201 if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$" | 201 if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$" |
202 setf specman | 202 setf specman |
203 return | 203 return |
204 endif | 204 endif |
205 let n = n + 1 | 205 let n = n + 1 |
209 endfunc | 209 endfunc |
210 | 210 |
211 " Distinguish between HTML, XHTML and Django | 211 " Distinguish between HTML, XHTML and Django |
212 func dist#ft#FThtml() | 212 func dist#ft#FThtml() |
213 let n = 1 | 213 let n = 1 |
214 while n < 10 && n < line("$") | 214 while n < 10 && n <= line("$") |
215 if getline(n) =~ '\<DTD\s\+XHTML\s' | 215 if getline(n) =~ '\<DTD\s\+XHTML\s' |
216 setf xhtml | 216 setf xhtml |
217 return | 217 return |
218 endif | 218 endif |
219 if getline(n) =~ '{%\s*\(extends\|block\|load\)\>\|{#\s\+' | 219 if getline(n) =~ '{%\s*\(extends\|block\|load\)\>\|{#\s\+' |
220 setf htmldjango | 220 setf htmldjango |
221 return | 221 return |
222 endif | 222 endif |
223 let n = n + 1 | 223 let n = n + 1 |
224 endwhile | 224 endwhile |
225 setf html | 225 setf FALLBACK html |
226 endfunc | 226 endfunc |
227 | 227 |
228 " Distinguish between standard IDL and MS-IDL | 228 " Distinguish between standard IDL and MS-IDL |
229 func dist#ft#FTidl() | 229 func dist#ft#FTidl() |
230 let n = 1 | 230 let n = 1 |
231 while n < 50 && n < line("$") | 231 while n < 50 && n <= line("$") |
232 if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"' | 232 if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"' |
233 setf msidl | 233 setf msidl |
234 return | 234 return |
235 endif | 235 endif |
236 let n = n + 1 | 236 let n = n + 1 |
697 return | 697 return |
698 endfunc | 698 endfunc |
699 | 699 |
700 func dist#ft#FTxml() | 700 func dist#ft#FTxml() |
701 let n = 1 | 701 let n = 1 |
702 while n < 100 && n < line("$") | 702 while n < 100 && n <= line("$") |
703 let line = getline(n) | 703 let line = getline(n) |
704 " DocBook 4 or DocBook 5. | 704 " DocBook 4 or DocBook 5. |
705 let is_docbook4 = line =~ '<!DOCTYPE.*DocBook' | 705 let is_docbook4 = line =~ '<!DOCTYPE.*DocBook' |
706 let is_docbook5 = line =~ ' xmlns="http://docbook.org/ns/docbook"' | 706 let is_docbook5 = line =~ ' xmlns="http://docbook.org/ns/docbook"' |
707 if is_docbook4 || is_docbook5 | 707 if is_docbook4 || is_docbook5 |
723 setf xml | 723 setf xml |
724 endfunc | 724 endfunc |
725 | 725 |
726 func dist#ft#FTy() | 726 func dist#ft#FTy() |
727 let n = 1 | 727 let n = 1 |
728 while n < 100 && n < line("$") | 728 while n < 100 && n <= line("$") |
729 let line = getline(n) | 729 let line = getline(n) |
730 if line =~ '^\s*%' | 730 if line =~ '^\s*%' |
731 setf yacc | 731 setf yacc |
732 return | 732 return |
733 endif | 733 endif |