Skip to content

Commit 73066fb

Browse files
committed
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.
1 parent bf255b6 commit 73066fb

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

internal/config/colorscheme.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ func InitColorscheme() error {
5555
c, err := LoadDefaultColorscheme()
5656
if err == nil {
5757
Colorscheme = c
58+
} else {
59+
// The colorscheme setting seems broken (maybe because we have not validated
60+
// it earlier, see comment in verifySetting()). So reset it to the default
61+
// colorscheme and try again.
62+
GlobalSettings["colorscheme"] = DefaultGlobalOnlySettings["colorscheme"]
63+
if c, err2 := LoadDefaultColorscheme(); err2 == nil {
64+
Colorscheme = c
65+
}
5866
}
5967

6068
return err

internal/config/settings.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,12 @@ func verifySetting(option string, value interface{}, def interface{}) error {
270270
return fmt.Errorf("Error: setting '%s' has incorrect type (%s), using default value: %v (%s)", option, valType, def, defType)
271271
}
272272

273+
if option == "colorscheme" {
274+
// Plugins are not initialized yet, so do not verify if the colorscheme
275+
// exists yet, since the colorscheme may be added by a plugin later.
276+
return nil
277+
}
278+
273279
if err := OptionIsValid(option, value); err != nil {
274280
return err
275281
}

0 commit comments

Comments
 (0)