mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-25 18:07:07 +09:00
Enable autosave option
The autosave option is now specified as an integer, which denotes the number of seconds to wait between saving the file. If the option is 0, then autosaving is disabled. If the option is given by the user as a boolean, it will be converted to 8 if true, and 0 if false. Fixes #1479
This commit is contained in:
@@ -35,7 +35,7 @@ func init() {
|
||||
|
||||
// Options with validators
|
||||
var optionValidators = map[string]optionValidator{
|
||||
// "autosave": validateNonNegativeValue,
|
||||
"autosave": validateNonNegativeValue,
|
||||
"tabsize": validatePositiveValue,
|
||||
"scrollmargin": validateNonNegativeValue,
|
||||
"scrollspeed": validateNonNegativeValue,
|
||||
@@ -58,6 +58,18 @@ func ReadSettings() error {
|
||||
if err != nil {
|
||||
return errors.New("Error reading settings.json: " + err.Error())
|
||||
}
|
||||
|
||||
// check if autosave is a boolean and convert it to float if so
|
||||
if v, ok := parsedSettings["autosave"]; ok {
|
||||
s, ok := v.(bool)
|
||||
if ok {
|
||||
if s {
|
||||
parsedSettings["autosave"] = 8.0
|
||||
} else {
|
||||
parsedSettings["autosave"] = 0.0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -232,7 +244,7 @@ func DefaultCommonSettings() map[string]interface{} {
|
||||
// a list of settings that should only be globally modified and their
|
||||
// default values
|
||||
var defaultGlobalSettings = map[string]interface{}{
|
||||
// "autosave": float64(0),
|
||||
"autosave": float64(0),
|
||||
"colorscheme": "default",
|
||||
"infobar": true,
|
||||
"keymenu": false,
|
||||
|
||||
Reference in New Issue
Block a user