Improve buffer saving and loading

This commit is contained in:
2025-06-07 15:40:06 +03:00
parent bde4eeb070
commit fa622762f2
2 changed files with 88 additions and 29 deletions
+12 -6
View File
@@ -49,13 +49,19 @@ func initTopMenu() {
return
}
buffer, err := CreateFileBuffer(input)
if err != nil {
PrintMessage(window, fmt.Sprintf("Could not open file: %s", err.Error()))
return
if openBuffer := GetOpenFileBuffer(input); openBuffer != nil {
PrintMessage(window, fmt.Sprintf("File already open! Switching to buffer: %s", openBuffer.Name))
window.textArea.CurrentBuffer = openBuffer
} else {
newBuffer, err := CreateFileBuffer(input)
if err != nil {
PrintMessage(window, fmt.Sprintf("Could not open file: %s", err.Error()))
return
}
PrintMessage(window, fmt.Sprintf("Opening file at: %s", newBuffer.filename))
window.textArea.CurrentBuffer = newBuffer
}
PrintMessage(window, fmt.Sprintf("Opening file: %s", input))
window.textArea.CurrentBuffer = buffer
}()
case 3:
delete(Buffers, window.textArea.CurrentBuffer.Id)