mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-25 18:07:07 +09:00
Don't crash if only file to open is directory
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
@@ -208,6 +209,13 @@ func main() {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
b := LoadInput()
|
b := LoadInput()
|
||||||
|
|
||||||
|
if len(b) == 0 {
|
||||||
|
// No buffers to open
|
||||||
|
screen.Screen.Fini()
|
||||||
|
runtime.Goexit()
|
||||||
|
}
|
||||||
|
|
||||||
action.InitTabs(b)
|
action.InitTabs(b)
|
||||||
action.InitGlobals()
|
action.InitGlobals()
|
||||||
|
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ func NewBufferFromFile(path string, btype BufType) (*Buffer, error) {
|
|||||||
fileInfo, _ := os.Stat(filename)
|
fileInfo, _ := os.Stat(filename)
|
||||||
|
|
||||||
if err == nil && fileInfo.IsDir() {
|
if err == nil && fileInfo.IsDir() {
|
||||||
return nil, errors.New(filename + " is a directory")
|
return nil, errors.New("Error: " + filename + " is a directory and cannot be opened")
|
||||||
}
|
}
|
||||||
|
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|||||||
Reference in New Issue
Block a user