mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-30 06:37:14 +09:00
Correctly detect synatx ft from header
This commit is contained in:
@@ -6,7 +6,9 @@ import "regexp"
|
|||||||
// to determine the filetype of the file
|
// to determine the filetype of the file
|
||||||
// It will return the corresponding syntax definition for the filetype
|
// It will return the corresponding syntax definition for the filetype
|
||||||
func MatchFiletype(ftdetect [2]*regexp.Regexp, filename string, firstLine []byte) bool {
|
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 {
|
if ftdetect[1] != nil {
|
||||||
return ftdetect[1].Match(firstLine)
|
return ftdetect[1].Match(firstLine)
|
||||||
|
|||||||
@@ -84,13 +84,14 @@ func LoadInput() []*Buffer {
|
|||||||
var filename string
|
var filename string
|
||||||
var input []byte
|
var input []byte
|
||||||
var err error
|
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
|
// Option 1
|
||||||
// We go through each file and load it
|
// We go through each file and load it
|
||||||
for i := 0; i < len(flag.Args()); i++ {
|
for i := 0; i < len(args); i++ {
|
||||||
filename = flag.Args()[i]
|
filename = args[i]
|
||||||
|
|
||||||
// Check that the file exists
|
// Check that the file exists
|
||||||
var input *os.File
|
var input *os.File
|
||||||
|
|||||||
Reference in New Issue
Block a user