Add autosave option

This commit is contained in:
Zachary Yedidia
2019-08-04 14:22:24 -07:00
parent bc6dd990e5
commit c0293b5d0e
9 changed files with 73 additions and 29 deletions

View File

@@ -1162,14 +1162,20 @@ func (h *BufPane) Quit() bool {
}
}
if h.Buf.Modified() {
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

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