Remove autosave option

With the new backup option, the autosave option is no longer useful.
Since it never really worked well in the first place, it has been
removed.

Closes #1420
This commit is contained in:
Zachary Yedidia
2019-12-26 14:35:48 -05:00
parent 7f7ad29671
commit 8570ff9a8c
6 changed files with 30 additions and 34 deletions

View File

@@ -1230,20 +1230,20 @@ func (h *BufPane) Quit() bool {
}
}
if h.Buf.Modified() {
if config.GlobalSettings["autosave"].(float64) > 0 {
// autosave on means we automatically save when quitting
h.Save()
quit()
} else {
InfoBar.YNPrompt("Save changes to "+h.Buf.GetName()+" before closing? (y,n,esc)", func(yes, canceled bool) {
if !canceled && !yes {
quit()
} else if !canceled && yes {
h.Save()
quit()
}
})
}
// if config.GlobalSettings["autosave"].(float64) > 0 {
// autosave on means we automatically save when quitting
// h.Save()
// quit()
// } else {
InfoBar.YNPrompt("Save changes to "+h.Buf.GetName()+" before closing? (y,n,esc)", func(yes, canceled bool) {
if !canceled && !yes {
quit()
} else if !canceled && yes {
h.Save()
quit()
}
})
// }
} else {
quit()
}

View File

@@ -539,13 +539,13 @@ func SetGlobalOptionNative(option string, nativeValue interface{}) error {
} else {
screen.Screen.EnableMouse()
}
} else if option == "autosave" {
if nativeValue.(float64) > 0 {
config.SetAutoTime(int(nativeValue.(float64)))
config.StartAutoSave()
} else {
config.SetAutoTime(0)
}
// } else if option == "autosave" {
// if nativeValue.(float64) > 0 {
// config.SetAutoTime(int(nativeValue.(float64)))
// config.StartAutoSave()
// } else {
// config.SetAutoTime(0)
// }
} else {
for _, pl := range config.Plugins {
if option == pl.Name {

View File

@@ -17,7 +17,9 @@ const backupMsg = `A backup was detected for this file. This likely means that m
crashed while editing this file, or another instance of micro is currently
editing this file.
The backup was created on %s.
The backup was created on %s, and the file is
%s
* 'recover' will apply the backup as unsaved changes to the current buffer.
When the buffer is closed, the backup will be removed.
@@ -98,7 +100,7 @@ func (b *Buffer) ApplyBackup(fsize int64) bool {
if err == nil {
defer backup.Close()
t := info.ModTime()
msg := fmt.Sprintf(backupMsg, t.Format("Mon Jan _2 at 15:04, 2006"))
msg := fmt.Sprintf(backupMsg, t.Format("Mon Jan _2 at 15:04, 2006"), util.EscapePath(b.AbsPath))
choice := screen.TermPrompt(msg, []string{"r", "i", "recover", "ignore"}, true)
if choice%2 == 0 {

View File

@@ -34,7 +34,7 @@ func init() {
// Options with validators
var optionValidators = map[string]optionValidator{
"autosave": validateNonNegativeValue,
// "autosave": validateNonNegativeValue,
"tabsize": validatePositiveValue,
"scrollmargin": validateNonNegativeValue,
"scrollspeed": validateNonNegativeValue,
@@ -213,7 +213,7 @@ func DefaultCommonSettings() map[string]interface{} {
}
var defaultGlobalSettings = map[string]interface{}{
"autosave": float64(0),
// "autosave": float64(0),
"colorscheme": "default",
"infobar": true,
"keymenu": false,