mirror of
https://github.com/bloeys/gopad.git
synced 2025-12-29 15:08:21 +00:00
Fix bug when opening file on launch
This commit is contained in:
@ -496,6 +496,8 @@ func NewEditor(fPath string) *Editor {
|
|||||||
FilePath: fPath,
|
FilePath: fPath,
|
||||||
FileContents: string(b),
|
FileContents: string(b),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
e.RefreshFontSettings()
|
||||||
e.LinesHead, e.LineCount = ParseLines(e.FileContents)
|
e.LinesHead, e.LineCount = ParseLines(e.FileContents)
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
|||||||
26
main.go
26
main.go
@ -111,18 +111,10 @@ func (g *Gopad) Init() {
|
|||||||
|
|
||||||
//Read os.Args
|
//Read os.Args
|
||||||
for i := 1; i < len(os.Args); i++ {
|
for i := 1; i < len(os.Args); i++ {
|
||||||
b, err := os.ReadFile(os.Args[i])
|
|
||||||
if err != nil {
|
|
||||||
errMsg := "Error opening file. Error: " + err.Error()
|
|
||||||
println(errMsg)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
g.editors = append(g.editors, Editor{
|
e := *NewEditor(os.Args[i])
|
||||||
FileName: filepath.Base(os.Args[i]),
|
g.editors = append(g.editors, e)
|
||||||
FilePath: os.Args[i],
|
g.activeEditor = len(g.editors) - 1
|
||||||
FileContents: string(b),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g.activeEditor = len(g.editors) - 1
|
g.activeEditor = len(g.editors) - 1
|
||||||
@ -171,12 +163,6 @@ func (g *Gopad) Update() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close editors if needed
|
|
||||||
if g.editorToClose > -1 {
|
|
||||||
g.closeEditor(g.editorToClose)
|
|
||||||
g.editorToClose = -1
|
|
||||||
}
|
|
||||||
|
|
||||||
if g.haveErr {
|
if g.haveErr {
|
||||||
g.showErrorPopup()
|
g.showErrorPopup()
|
||||||
}
|
}
|
||||||
@ -448,6 +434,12 @@ func (g *Gopad) handleFileClick(fPath string) {
|
|||||||
|
|
||||||
func (g *Gopad) FrameEnd() {
|
func (g *Gopad) FrameEnd() {
|
||||||
g.newRunes = []rune{}
|
g.newRunes = []rune{}
|
||||||
|
|
||||||
|
// Close editors if needed
|
||||||
|
if g.editorToClose > -1 {
|
||||||
|
g.closeEditor(g.editorToClose)
|
||||||
|
g.editorToClose = -1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Gopad) DeInit() {
|
func (g *Gopad) DeInit() {
|
||||||
|
|||||||
Reference in New Issue
Block a user