mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-30 06:37:14 +09:00
Generalize save prompt on close code into method
This slightly changes the open and term command to be similar with the Quit action, where the buffer or pane is replaced after the prompts are completed if "n" wasn't pressed after the 1st prompt.
This commit is contained in:
@@ -309,14 +309,7 @@ func (h *BufPane) OpenCmd(args []string) {
|
||||
h.OpenBuffer(b)
|
||||
}
|
||||
if h.Buf.Modified() && !h.Buf.Shared() {
|
||||
InfoBar.YNPrompt("Save changes to "+h.Buf.GetName()+" before closing? (y,n,esc)", func(yes, canceled bool) {
|
||||
if !canceled && !yes {
|
||||
open()
|
||||
} else if !canceled && yes {
|
||||
h.Save()
|
||||
open()
|
||||
}
|
||||
})
|
||||
h.closePrompt("Save", open)
|
||||
} else {
|
||||
open()
|
||||
}
|
||||
@@ -1122,13 +1115,8 @@ func (h *BufPane) TermCmd(args []string) {
|
||||
for i, p := range ps {
|
||||
if p.ID() == h.ID() {
|
||||
if h.Buf.Modified() && !h.Buf.Shared() {
|
||||
InfoBar.YNPrompt("Save changes to "+h.Buf.GetName()+" before closing? (y,n,esc)", func(yes, canceled bool) {
|
||||
if !canceled && !yes {
|
||||
term(i, false)
|
||||
} else if !canceled && yes {
|
||||
h.Save()
|
||||
term(i, false)
|
||||
}
|
||||
h.closePrompt("Save", func() {
|
||||
term(i, false)
|
||||
})
|
||||
} else {
|
||||
term(i, false)
|
||||
|
||||
Reference in New Issue
Block a user