action/command: Prevent overwriting settings set locally or by plugin

- on `reload`
- on `filetype` change
This commit is contained in:
Jöran Karl
2024-07-26 21:06:06 +02:00
parent f661b64e0a
commit 05529596cf
3 changed files with 23 additions and 12 deletions

View File

@@ -8,13 +8,9 @@ import (
"github.com/zyedidia/micro/v2/internal/screen"
)
func (b *Buffer) SetOptionNative(option string, nativeValue interface{}) error {
if err := config.OptionIsValid(option, nativeValue); err != nil {
return err
}
func (b *Buffer) DoSetOptionNative(option string, nativeValue interface{}) {
if reflect.DeepEqual(b.Settings[option], nativeValue) {
return nil
return
}
b.Settings[option] = nativeValue
@@ -46,10 +42,14 @@ func (b *Buffer) SetOptionNative(option string, nativeValue interface{}) error {
// filetype should not override volatile settings
continue
}
if _, ok := b.LocalSettings[k]; ok {
// filetype should not override local settings
continue
}
if _, ok := settings[k]; ok {
b.SetOptionNative(k, settings[k])
b.DoSetOptionNative(k, settings[k])
} else {
b.SetOptionNative(k, v)
b.DoSetOptionNative(k, v)
}
}
b.UpdateRules()
@@ -101,6 +101,15 @@ func (b *Buffer) SetOptionNative(option string, nativeValue interface{}) error {
if b.OptionCallback != nil {
b.OptionCallback(option, nativeValue)
}
}
func (b *Buffer) SetOptionNative(option string, nativeValue interface{}) error {
if err := config.OptionIsValid(option, nativeValue); err != nil {
return err
}
b.DoSetOptionNative(option, nativeValue)
b.LocalSettings[option] = true
return nil
}