}
// SaveAsCB performs a save as and does a callback at the very end (after all prompts have been resolved)
+// The callback is only called if the save was successful
func (h *BufPane) SaveAsCB(action string, callback func()) bool {
InfoBar.Prompt("Filename: ", "", "Save", nil, func(resp string, canceled bool) {
if !canceled {
// This function saves the buffer to `filename` and changes the buffer's path and name
// to `filename` if the save is successful
+// The callback is only called if the save was successful
func (h *BufPane) saveBufToFile(filename string, action string, callback func()) bool {
err := h.Buf.SaveAs(filename)
if err != nil {
h.Buf.Path = filename
h.Buf.SetName(filename)
InfoBar.Message("Saved " + filename)
+ if callback != nil {
+ callback()
+ }
}
}
if h.Buf.Settings["autosu"].(bool) {
saveWithSudo()
h.completeAction(action)
}
- if callback != nil {
- callback()
- }
})
return false
}
h.Buf.Path = filename
h.Buf.SetName(filename)
InfoBar.Message("Saved " + filename)
- }
- if callback != nil {
- callback()
+ if callback != nil {
+ callback()
+ }
}
return true
}