]> git.lizzy.rs Git - micro.git/blobdiff - cmd/micro/action/command.go
Fix yn callback bug
[micro.git] / cmd / micro / action / command.go
index 7d40baecc1794f8ab8c9568e773e34aa50fd1352..ef4762df95b4d9be9d2d01d90db27c40f3493d28 100644 (file)
@@ -150,6 +150,7 @@ func (h *BufHandler) PluginCmd(args []string) {
 // RetabCmd changes all spaces to tabs or all tabs to spaces
 // depending on the user's settings
 func (h *BufHandler) RetabCmd(args []string) {
+       h.Buf.Retab()
 }
 
 // RawCmd opens a new raw view which displays the escape sequences micro
@@ -558,9 +559,7 @@ func (h *BufHandler) TermCmd(args []string) {
                args = []string{sh}
        }
 
-       term := func(i int) {
-               // If there is only one open file we make a new tab instead of overwriting it
-               newtab := len(MainTab().Panes) == 1 && len(Tabs.List) == 1
+       term := func(i int, newtab bool) {
 
                t := new(shell.Terminal)
                t.Start(args, false, true)
@@ -579,19 +578,27 @@ func (h *BufHandler) TermCmd(args []string) {
                MainTab().SetActive(i)
        }
 
+       // If there is only one open file we make a new tab instead of overwriting it
+       newtab := len(MainTab().Panes) == 1 && len(Tabs.List) == 1
+
+       if newtab {
+               term(0, true)
+               return
+       }
+
        for i, p := range ps {
                if p.ID() == h.ID() {
                        if h.Buf.Modified() {
                                InfoBar.YNPrompt("Save changes to "+h.Buf.GetName()+" before closing? (y,n,esc)", func(yes, canceled bool) {
                                        if !canceled && !yes {
-                                               term(i)
+                                               term(i, false)
                                        } else if !canceled && yes {
                                                h.Save()
-                                               term(i)
+                                               term(i, false)
                                        }
                                })
                        } else {
-                               term(i)
+                               term(i, false)
                        }
                }
        }