mirror of
https://github.com/EnumeratedDev/typer.git
synced 2026-09-16 05:36:10 +00:00
Fix empty buffer being created when opening files using cmdline arguments and allow opening non-existent files
This commit is contained in:
+5
-10
@@ -11,26 +11,21 @@ func main() {
|
||||
log.Fatalf("Failed to create window: %v", err)
|
||||
}
|
||||
|
||||
var initialBuffer *Buffer = nil
|
||||
|
||||
if len(os.Args) > 0 {
|
||||
if len(os.Args) > 1 {
|
||||
for _, file := range os.Args[1:] {
|
||||
b, err := CreateFileBuffer(file)
|
||||
b, err := CreateFileBuffer(file, true)
|
||||
if err != nil {
|
||||
PrintMessage(window, "Could not open file: "+file)
|
||||
continue
|
||||
}
|
||||
|
||||
if initialBuffer == nil {
|
||||
initialBuffer = b
|
||||
if window.textArea.CurrentBuffer.Name == "New File 1" {
|
||||
delete(Buffers, window.textArea.CurrentBuffer.Id)
|
||||
window.textArea.CurrentBuffer = b
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if initialBuffer != nil {
|
||||
window.textArea.CurrentBuffer = initialBuffer
|
||||
}
|
||||
|
||||
for window.screen != nil {
|
||||
window.Draw()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user