Skip to content

Commit

Permalink
Merge pull request #522 from samdmarshall/master
Browse files Browse the repository at this point in the history
Redo of #516 -- Making micro a bit more user-friendly around the quitting behavior
  • Loading branch information
zyedidia authored Feb 16, 2017
2 parents fb2bf7a + a7e5a5b commit c1db99a
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions cmd/micro/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@ func (v *View) CommandMode(usePlugin bool) bool {
return false
}

// Escape leaves current mode / quits the editor
// Escape leaves current mode
func (v *View) Escape(usePlugin bool) bool {
// check if user is searching, or the last search is still active
if searching || lastSearch != "" {
Expand All @@ -1381,13 +1381,11 @@ func (v *View) Escape(usePlugin bool) bool {
messenger.Reset() // FIXME
return true
}
return v.Quit(usePlugin)

return false
}

// Quit quits the editor
// This behavior needs to be changed and should really only quit the editor if this
// is the last view
// However, since micro only supports one view for now, it doesn't really matter
// Quit this will close the current tab or view that is open
func (v *View) Quit(usePlugin bool) bool {
if usePlugin && !PreActionCall("Quit", v) {
return false
Expand All @@ -1410,7 +1408,6 @@ func (v *View) Quit(usePlugin bool) bool {
curTab--
}
if curTab == 0 {
// CurView().Resize(screen.Size())
CurView().ToggleTabbar()
CurView().matches = Match(CurView())
}
Expand Down Expand Up @@ -1447,18 +1444,23 @@ func (v *View) QuitAll(usePlugin bool) bool {
}

if closeAll {
for _, tab := range tabs {
for _, v := range tab.views {
v.CloseBuffer()
// only quit if all of the buffers can be closed and the user confirms that they actually want to quit everything
should_quit, _ := messenger.YesNoPrompt("Do you want to quit micro (all open files will be closed)?")

if should_quit {
for _, tab := range tabs {
for _, v := range tab.views {
v.CloseBuffer()
}
}
}

if usePlugin {
PostActionCall("QuitAll", v)
}
if usePlugin {
PostActionCall("QuitAll", v)
}

screen.Fini()
os.Exit(0)
screen.Fini()
os.Exit(0)
}
}

return false
Expand Down

0 comments on commit c1db99a

Please sign in to comment.