mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-16 05:47:06 +09:00
Disable early validation of colorscheme option
Adding early validation of options in ReadSettings() caused a regression: colorschemes registered by plugins via config.AddRuntimeFile() stopped working, since ReadSettings() is called when plugins are not initialized (or even loaded) yet, so a colorscheme is not registered yet and thus its validation fails. Fix that with an ad-hoc fix: treat the "colorscheme" option as a special case and do not verify it early when reading settings.json, postponing that until the moment when we try to load this colorscheme.
This commit is contained in:
@@ -55,6 +55,14 @@ func InitColorscheme() error {
|
|||||||
c, err := LoadDefaultColorscheme()
|
c, err := LoadDefaultColorscheme()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
Colorscheme = c
|
Colorscheme = c
|
||||||
|
} else {
|
||||||
|
// The colorscheme setting seems broken (maybe because we have not validated
|
||||||
|
// it earlier, see comment in verifySetting()). So reset it to the default
|
||||||
|
// colorscheme and try again.
|
||||||
|
GlobalSettings["colorscheme"] = DefaultGlobalOnlySettings["colorscheme"]
|
||||||
|
if c, err2 := LoadDefaultColorscheme(); err2 == nil {
|
||||||
|
Colorscheme = c
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -270,6 +270,12 @@ func verifySetting(option string, value interface{}, def interface{}) error {
|
|||||||
return fmt.Errorf("Error: setting '%s' has incorrect type (%s), using default value: %v (%s)", option, valType, def, defType)
|
return fmt.Errorf("Error: setting '%s' has incorrect type (%s), using default value: %v (%s)", option, valType, def, defType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if option == "colorscheme" {
|
||||||
|
// Plugins are not initialized yet, so do not verify if the colorscheme
|
||||||
|
// exists yet, since the colorscheme may be added by a plugin later.
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if err := OptionIsValid(option, value); err != nil {
|
if err := OptionIsValid(option, value); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user