Fix empty buffer being created when opening files using cmdline arguments and allow opening non-existent files

This commit is contained in:
2025-06-07 20:38:36 +03:00
parent fa622762f2
commit 448ebe27cf
4 changed files with 24 additions and 21 deletions
+5 -10
View File
@@ -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()
}