Correctly detect synatx ft from header

This commit is contained in:
Zachary Yedidia
2017-05-03 11:04:56 -04:00
parent d3f32b5bc3
commit 67ec0d3c80
2 changed files with 8 additions and 5 deletions

View File

@@ -6,7 +6,9 @@ import "regexp"
// to determine the filetype of the file
// It will return the corresponding syntax definition for the filetype
func MatchFiletype(ftdetect [2]*regexp.Regexp, filename string, firstLine []byte) bool {
return ftdetect[0].MatchString(filename)
if ftdetect[0].MatchString(filename) {
return true
}
if ftdetect[1] != nil {
return ftdetect[1].Match(firstLine)