Correctly detect synatx ft from header
This commit is contained in:
parent
d3f32b5bc3
commit
67ec0d3c80
2 changed files with 8 additions and 5 deletions
|
@ -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)
|
||||
|
|
|
@ -84,13 +84,14 @@ func LoadInput() []*Buffer {
|
|||
var filename string
|
||||
var input []byte
|
||||
var err error
|
||||
var buffers []*Buffer
|
||||
args := flag.Args()
|
||||
buffers := make([]*Buffer, 0, len(args))
|
||||
|
||||
if len(flag.Args()) > 0 {
|
||||
if len(args) > 0 {
|
||||
// Option 1
|
||||
// We go through each file and load it
|
||||
for i := 0; i < len(flag.Args()); i++ {
|
||||
filename = flag.Args()[i]
|
||||
for i := 0; i < len(args); i++ {
|
||||
filename = args[i]
|
||||
|
||||
// Check that the file exists
|
||||
var input *os.File
|
||||
|
|
Loading…
Reference in a new issue