Tell user that option can't be set locally when user tries to set

global only option instead of just telling that option is invalid

Signed-off-by: Yevhen Babiichuk (DustDFG) <dfgdust@gmail.com>
This commit is contained in:
Yevhen Babiichuk (DustDFG) 2023-12-01 11:43:08 +02:00
parent d8e9d61a95
commit aab3854874
2 changed files with 5 additions and 0 deletions

View file

@ -86,6 +86,9 @@ func (b *Buffer) SetOptionNative(option string, nativeValue interface{}) error {
// SetOption sets a given option to a value just for this buffer
func (b *Buffer) SetOption(option, value string) error {
if _, ok := b.Settings[option]; !ok {
if _, ok := config.DefaultGlobalOnlySettings[option]; ok {
return config.ErrGlobalOnlyOption
}
return config.ErrInvalidOption
}

View file

@ -23,6 +23,8 @@ var (
ErrInvalidOption = errors.New("Invalid option")
ErrInvalidValue = errors.New("Invalid value")
ErrGlobalOnlyOption = errors.New("This option can't be set locally")
// The options that the user can set
GlobalSettings map[string]interface{}