diff --git a/cmd/micro/command.go b/cmd/micro/command.go index 8600d7a1..39bc2f8f 100644 --- a/cmd/micro/command.go +++ b/cmd/micro/command.go @@ -117,7 +117,7 @@ func HandleCommand(input string, view *View) { case "set": SetOption(view, args) case "quit": - if view.CanClose("Quit anyway? ") { + if view.CanClose("Quit anyway? (yes, no, save) ") { screen.Fini() os.Exit(0) } diff --git a/cmd/micro/micro.go b/cmd/micro/micro.go index 962d8959..829a4e24 100644 --- a/cmd/micro/micro.go +++ b/cmd/micro/micro.go @@ -192,7 +192,7 @@ func main() { switch e.Key() { case tcell.KeyCtrlQ: // Make sure not to quit if there are unsaved changes - if view.CanClose("Quit anyway? ") { + if view.CanClose("Quit anyway? (yes, no, save) ") { screen.Fini() os.Exit(0) } diff --git a/cmd/micro/view.go b/cmd/micro/view.go index 1a276798..69a65a75 100644 --- a/cmd/micro/view.go +++ b/cmd/micro/view.go @@ -196,6 +196,9 @@ func (v *View) CanClose(msg string) bool { if !canceled { if strings.ToLower(quit) == "yes" || strings.ToLower(quit) == "y" { return true + } else if strings.ToLower(quit) == "save" || strings.ToLower(quit) == "s" { + v.Save() + return true } } } else { @@ -276,7 +279,7 @@ func (v *View) SelectAll() { // OpenFile opens a new file in the current view // It makes sure that the current buffer can be closed first (unsaved changes) func (v *View) OpenFile() { - if v.CanClose("Continue? ") { + if v.CanClose("Continue? (yes, no, save) ") { filename, canceled := messenger.Prompt("File to open: ") if canceled { return