]> git.lizzy.rs Git - micro.git/commitdiff
Don't apply cli options to settings.json
authorZachary Yedidia <zyedidia@gmail.com>
Tue, 9 Jun 2020 02:19:15 +0000 (22:19 -0400)
committerZachary Yedidia <zyedidia@gmail.com>
Tue, 9 Jun 2020 02:19:15 +0000 (22:19 -0400)
internal/action/command.go
internal/config/settings.go

index 8034f291a82a7895b254453f8659784ec96c0641..90792a26cfb5c97f12f446e486e102c130f88ee6 100644 (file)
@@ -480,6 +480,7 @@ func SetGlobalOptionNative(option string, nativeValue interface{}) error {
 
        if !local {
                config.GlobalSettings[option] = nativeValue
+               config.ModifiedSettings[option] = true
 
                if option == "colorscheme" {
                        // LoadSyntaxFiles()
index c35878eaa643e48c628c3792e4fef64fb24ddb80..55aed63ed851995c72238982832be0e2110dcdf7 100644 (file)
@@ -28,9 +28,14 @@ var (
 
        // This is the raw parsed json
        parsedSettings map[string]interface{}
+
+       // 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
 )
 
 func init() {
+       ModifiedSettings = make(map[string]bool)
        parsedSettings = make(map[string]interface{})
 }
 
@@ -163,7 +168,9 @@ func WriteSettings(filename string) error {
                // add any options to parsedSettings that have since been marked as non-default
                for k, v := range GlobalSettings {
                        if def, ok := defaults[k]; !ok || !reflect.DeepEqual(v, def) {
-                               parsedSettings[k] = v
+                               if _, wr := ModifiedSettings[k]; wr {
+                                       parsedSettings[k] = v
+                               }
                        }
                }
 
@@ -183,7 +190,9 @@ func OverwriteSettings(filename string) error {
                defaults := DefaultGlobalSettings()
                for k, v := range GlobalSettings {
                        if def, ok := defaults[k]; !ok || !reflect.DeepEqual(v, def) {
-                               settings[k] = v
+                               if _, wr := ModifiedSettings[k]; wr {
+                                       settings[k] = v
+                               }
                        }
                }