mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-29 22:27:13 +09:00
Fix save callback issue
This commit is contained in:
@@ -636,7 +636,10 @@ func (h *BufPane) Save() bool {
|
|||||||
if h.Buf.Path == "" {
|
if h.Buf.Path == "" {
|
||||||
h.SaveAs()
|
h.SaveAs()
|
||||||
} else {
|
} else {
|
||||||
h.saveBufToFile(h.Buf.Path, "Save")
|
noPrompt := h.saveBufToFile(h.Buf.Path, "Save")
|
||||||
|
if noPrompt {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
@@ -653,7 +656,10 @@ func (h *BufPane) SaveAs() bool {
|
|||||||
InfoBar.Error("Error parsing arguments: ", err)
|
InfoBar.Error("Error parsing arguments: ", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
h.saveBufToFile(filename, "SaveAs")
|
noPrompt := h.saveBufToFile(filename, "SaveAs")
|
||||||
|
if noPrompt {
|
||||||
|
h.completeAction("SaveAs")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return false
|
return false
|
||||||
@@ -661,7 +667,7 @@ func (h *BufPane) SaveAs() bool {
|
|||||||
|
|
||||||
// This function saves the buffer to `filename` and changes the buffer's path and name
|
// This function saves the buffer to `filename` and changes the buffer's path and name
|
||||||
// to `filename` if the save is successful
|
// to `filename` if the save is successful
|
||||||
func (h *BufPane) saveBufToFile(filename string, action string) {
|
func (h *BufPane) saveBufToFile(filename string, action string) bool {
|
||||||
err := h.Buf.SaveAs(filename)
|
err := h.Buf.SaveAs(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.HasSuffix(err.Error(), "permission denied") {
|
if strings.HasSuffix(err.Error(), "permission denied") {
|
||||||
@@ -678,6 +684,7 @@ func (h *BufPane) saveBufToFile(filename string, action string) {
|
|||||||
h.completeAction(action)
|
h.completeAction(action)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
return false
|
||||||
} else {
|
} else {
|
||||||
InfoBar.Error(err)
|
InfoBar.Error(err)
|
||||||
}
|
}
|
||||||
@@ -685,8 +692,8 @@ func (h *BufPane) saveBufToFile(filename string, action string) {
|
|||||||
h.Buf.Path = filename
|
h.Buf.Path = filename
|
||||||
h.Buf.SetName(filename)
|
h.Buf.SetName(filename)
|
||||||
InfoBar.Message("Saved " + filename)
|
InfoBar.Message("Saved " + filename)
|
||||||
h.completeAction(action)
|
|
||||||
}
|
}
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find opens a prompt and searches forward for the input
|
// Find opens a prompt and searches forward for the input
|
||||||
|
|||||||
Reference in New Issue
Block a user