Skip to content

Commit c51f848

Browse files
committed
action/command: On reload prevent overwriting settings.json
1 parent 7f6e5bc commit c51f848

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

internal/action/command.go

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,9 @@ func reloadRuntime(reloadPlugins bool) {
362362
defaultSettings := config.DefaultAllSettings()
363363
for k := range defaultSettings {
364364
if _, ok := parsedSettings[k]; ok {
365-
err = SetGlobalOptionNative(k, parsedSettings[k])
365+
err = doSetGlobalOptionNative(k, parsedSettings[k])
366366
} else {
367-
err = SetGlobalOptionNative(k, defaultSettings[k])
367+
err = doSetGlobalOptionNative(k, defaultSettings[k])
368368
}
369369
if err != nil {
370370
screen.TermMessage(err)
@@ -525,15 +525,7 @@ func (h *BufPane) NewTabCmd(args []string) {
525525
}
526526
}
527527

528-
func SetGlobalOptionNative(option string, nativeValue interface{}) error {
529-
// check for local option first...
530-
for _, s := range config.LocalSettings {
531-
if s == option {
532-
return MainTab().CurPane().Buf.SetOptionNative(option, nativeValue)
533-
}
534-
}
535-
536-
// ...if it's not local continue with the globals
528+
func doSetGlobalOptionNative(option string, nativeValue interface{}) error {
537529
config.GlobalSettings[option] = nativeValue
538530
config.ModifiedSettings[option] = true
539531
delete(config.VolatileSettings, option)
@@ -586,6 +578,23 @@ func SetGlobalOptionNative(option string, nativeValue interface{}) error {
586578
}
587579
}
588580

581+
return nil
582+
}
583+
584+
func SetGlobalOptionNative(option string, nativeValue interface{}) error {
585+
// check for local option first...
586+
for _, s := range config.LocalSettings {
587+
if s == option {
588+
return MainTab().CurPane().Buf.SetOptionNative(option, nativeValue)
589+
}
590+
}
591+
592+
// ...if it's not local continue with the globals...
593+
if err := doSetGlobalOptionNative(option, nativeValue); err != nil {
594+
return err
595+
}
596+
597+
// ...at last check the buffer locals
589598
for _, b := range buffer.OpenBuffers {
590599
if err := b.SetOptionNative(option, nativeValue); err != nil {
591600
return err

0 commit comments

Comments
 (0)