mirror of
https://github.com/neovim/neovim.git
synced 2025-09-24 20:18:32 +00:00
feat(options)!: disallow setting hidden options #28400
Problem: There are three different ways of marking an option as hidden, `enable_if = false`, `hidden = true` and `immutable = true`. These also have different behaviors. Options hidden with `enable_if = false` can't have their value fetched using Vim script or the API, but options hidden with `hidden = true` or `immutable = true` can. On the other hand, options with `hidden = true` do not error when trying to set their value, but options with `immutable = true` do. Solution: Remove `enable_if = false`, remove the `hidden` property for options, and use `immutable = true` to mark an option as hidden instead. Also make hidden option variable pointers always point to the default value, which allows fetching the value of every hidden option using Vim script and the API. This does also mean that trying to set a hidden option will now give an error instead of just being ignored.
This commit is contained in:
@@ -647,10 +647,6 @@ static bool option_has_scope(OptIndex opt_idx, OptReqScope req_scope)
|
||||
|
||||
vimoption_T *opt = get_option(opt_idx);
|
||||
|
||||
// Hidden option.
|
||||
if (opt->var == NULL) {
|
||||
return false;
|
||||
}
|
||||
// TTY option.
|
||||
if (is_tty_option(opt->fullname)) {
|
||||
return req_scope == kOptReqGlobal;
|
||||
|
@@ -80,7 +80,7 @@ static int validate_option_value_args(Dict(option) *opts, char *name, OptIndex *
|
||||
*opt_idxp = find_option(name);
|
||||
int flags = get_option_attrs(*opt_idxp);
|
||||
if (flags == 0) {
|
||||
// hidden or unknown option
|
||||
// unknown option
|
||||
api_set_error(err, kErrorTypeValidation, "Unknown option '%s'", name);
|
||||
} else if (*req_scope == kOptReqBuf || *req_scope == kOptReqWin) {
|
||||
// if 'buf' or 'win' is passed, make sure the option supports it
|
||||
@@ -175,7 +175,6 @@ Object nvim_get_option_value(String name, Dict(option) *opts, Error *err)
|
||||
}
|
||||
|
||||
OptVal value = get_option_value_for(opt_idx, scope, req_scope, from, err);
|
||||
bool hidden = is_option_hidden(opt_idx);
|
||||
|
||||
if (ftbuf != NULL) {
|
||||
// restore curwin/curbuf and a few other things
|
||||
@@ -189,7 +188,7 @@ Object nvim_get_option_value(String name, Dict(option) *opts, Error *err)
|
||||
goto err;
|
||||
}
|
||||
|
||||
VALIDATE_S(!hidden && value.type != kOptValTypeNil, "option", name.data, {
|
||||
VALIDATE_S(value.type != kOptValTypeNil, "option", name.data, {
|
||||
goto err;
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user