}
}
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()
}
} else {
screen.Screen.EnableMouse()
}
- // autosave option has been removed
- // } 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 if option == "paste" {
screen.Screen.SetPaste(nativeValue.(bool))
} else {
"errors"
"io"
"io/ioutil"
+ "log"
"os"
"path/filepath"
"strconv"
if syntaxFile == "" {
// search for the syntax file in the user's custom syntax files
for _, f := range config.ListRealRuntimeFiles(config.RTSyntax) {
+ log.Println("real runtime file", f.Name())
data, err := f.Data()
if err != nil {
screen.TermMessage("Error loading syntax file " + f.Name() + ": " + err.Error())
continue
}
- if (ft == "unknown" || ft == "" && highlight.MatchFiletype(header.FtDetect, b.Path, b.lines[0].data)) || header.FileType == ft {
+ if ((ft == "unknown" || ft == "") && highlight.MatchFiletype(header.FtDetect, b.Path, b.lines[0].data)) || header.FileType == ft {
syndef, err := highlight.ParseDef(file, header)
if err != nil {
screen.TermMessage("Error parsing syntax file " + f.Name() + ": " + err.Error())
// Options with validators
var optionValidators = map[string]optionValidator{
- // "autosave": validateNonNegativeValue,
+ "autosave": validateNonNegativeValue,
"tabsize": validatePositiveValue,
"scrollmargin": validateNonNegativeValue,
"scrollspeed": validateNonNegativeValue,
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
// 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,