diff --git a/cmd/micro/micro.go b/cmd/micro/micro.go index e0ef0987..a90d7e7a 100644 --- a/cmd/micro/micro.go +++ b/cmd/micro/micro.go @@ -275,6 +275,7 @@ func main() { continue } config.GlobalSettings[k] = nativeValue + config.VolatileSettings[k] = true } } diff --git a/internal/action/command.go b/internal/action/command.go index 7165cee0..6448acdc 100644 --- a/internal/action/command.go +++ b/internal/action/command.go @@ -482,6 +482,7 @@ func SetGlobalOptionNative(option string, nativeValue interface{}) error { if !local { config.GlobalSettings[option] = nativeValue config.ModifiedSettings[option] = true + delete(config.VolatileSettings, option) if option == "colorscheme" { // LoadSyntaxFiles() diff --git a/internal/config/settings.go b/internal/config/settings.go index c1ec391b..d5328ad9 100644 --- a/internal/config/settings.go +++ b/internal/config/settings.go @@ -34,10 +34,15 @@ var ( // ModifiedSettings is a map of settings which should be written to disk // because they have been modified by the user in this session ModifiedSettings map[string]bool + + // VolatileSettings is a map of settings which should not be written to disk + // because they have been temporarily set for this session only + VolatileSettings map[string]bool ) func init() { ModifiedSettings = make(map[string]bool) + VolatileSettings = make(map[string]bool) parsedSettings = make(map[string]interface{}) } @@ -176,7 +181,8 @@ func WriteSettings(filename string) error { for k, v := range parsedSettings { if !strings.HasPrefix(reflect.TypeOf(v).String(), "map") { cur, okcur := GlobalSettings[k] - if def, ok := defaults[k]; ok && okcur && reflect.DeepEqual(cur, def) { + _, vol := VolatileSettings[k] + if def, ok := defaults[k]; ok && okcur && !vol && reflect.DeepEqual(cur, def) { delete(parsedSettings, k) } }