refactor(options): swap immutable and hidden option property names

Ref: https://github.com/neovim/neovim/pull/28018#issuecomment-2021622120
This commit is contained in:
Famiu Haque 2024-03-27 14:37:50 +06:00 committed by Lewis Russell
parent 635fa2c51c
commit 63f7b1f31e
3 changed files with 18 additions and 19 deletions

View File

@ -3481,11 +3481,11 @@ static const char *did_set_option(OptIndex opt_idx, void *varp, OptVal old_value
.os_win = curwin .os_win = curwin
}; };
if (direct || opt->immutable) { if (direct || opt->hidden) {
// Don't do any extra processing if setting directly or if option is immutable. // Don't do any extra processing if setting directly or if option is hidden.
} }
// Disallow changing hidden options. // Disallow changing immutable options.
else if (opt->hidden && !optval_equal(old_value, new_value)) { else if (opt->immutable && !optval_equal(old_value, new_value)) {
errmsg = e_unsupportedoption; errmsg = e_unsupportedoption;
} }
// Disallow changing some options from secure mode. // Disallow changing some options from secure mode.
@ -3509,9 +3509,9 @@ static const char *did_set_option(OptIndex opt_idx, void *varp, OptVal old_value
restore_chartab = did_set_cb_args.os_restore_chartab; restore_chartab = did_set_cb_args.os_restore_chartab;
} }
// If option is immutable or if an error is detected, restore the previous value and don't do any // If option is hidden or if an error is detected, restore the previous value and don't do any
// further processing. // further processing.
if (opt->immutable || errmsg != NULL) { if (opt->hidden || errmsg != NULL) {
set_option_varp(opt_idx, varp, old_value, true); set_option_varp(opt_idx, varp, old_value, true);
// When resetting some values, need to act on it. // When resetting some values, need to act on it.
if (restore_chartab) { if (restore_chartab) {

View File

@ -49,9 +49,8 @@ typedef struct {
///< buffer-local option: global value ///< buffer-local option: global value
idopt_T indir; ///< global option: PV_NONE; idopt_T indir; ///< global option: PV_NONE;
///< local option: indirect option index ///< local option: indirect option index
bool hidden; ///< option is hidden and cannot be set. bool hidden; ///< option is hidden, any attempt to set its value will be ignored.
bool immutable; ///< option value can be set but any attempt to change the option is bool immutable; ///< option is immutable, trying to set its value will give an error.
/// ignored.
/// callback function to invoke after an option is modified to validate and /// callback function to invoke after an option is modified to validate and
/// apply the new value. /// apply the new value.

View File

@ -1341,7 +1341,7 @@ return {
scope = { 'global' }, scope = { 'global' },
short_desc = N_('No description'), short_desc = N_('No description'),
type = 'boolean', type = 'boolean',
hidden = true, immutable = true,
}, },
{ {
abbreviation = 'cpt', abbreviation = 'cpt',
@ -2300,7 +2300,7 @@ return {
scope = { 'global' }, scope = { 'global' },
short_desc = N_('No description'), short_desc = N_('No description'),
type = 'boolean', type = 'boolean',
hidden = true, immutable = true,
}, },
{ {
abbreviation = 'emo', abbreviation = 'emo',
@ -3889,7 +3889,7 @@ return {
scope = { 'global' }, scope = { 'global' },
short_desc = N_('No description'), short_desc = N_('No description'),
type = 'boolean', type = 'boolean',
hidden = true, immutable = true,
}, },
{ {
abbreviation = 'hkp', abbreviation = 'hkp',
@ -3898,7 +3898,7 @@ return {
scope = { 'global' }, scope = { 'global' },
short_desc = N_('No description'), short_desc = N_('No description'),
type = 'boolean', type = 'boolean',
hidden = true, immutable = true,
}, },
{ {
abbreviation = 'hls', abbreviation = 'hls',
@ -4296,7 +4296,7 @@ return {
scope = { 'global' }, scope = { 'global' },
short_desc = N_('No description'), short_desc = N_('No description'),
type = 'boolean', type = 'boolean',
hidden = true, immutable = true,
}, },
{ {
abbreviation = 'isf', abbreviation = 'isf',
@ -5147,7 +5147,7 @@ return {
scope = { 'global' }, scope = { 'global' },
short_desc = N_('maximum nr of combining characters displayed'), short_desc = N_('maximum nr of combining characters displayed'),
type = 'number', type = 'number',
immutable = true, hidden = true,
}, },
{ {
abbreviation = 'mfd', abbreviation = 'mfd',
@ -6048,7 +6048,7 @@ return {
scope = { 'global' }, scope = { 'global' },
short_desc = N_('enable prompt in Ex mode'), short_desc = N_('enable prompt in Ex mode'),
type = 'boolean', type = 'boolean',
hidden = true, immutable = true,
}, },
{ {
abbreviation = 'pb', abbreviation = 'pb',
@ -6305,7 +6305,7 @@ return {
scope = { 'global' }, scope = { 'global' },
short_desc = N_('No description'), short_desc = N_('No description'),
type = 'boolean', type = 'boolean',
hidden = true, immutable = true,
}, },
{ {
defaults = { if_true = 2 }, defaults = { if_true = 2 },
@ -8844,7 +8844,7 @@ return {
scope = { 'global' }, scope = { 'global' },
short_desc = N_('No description'), short_desc = N_('No description'),
type = 'boolean', type = 'boolean',
hidden = true, immutable = true,
}, },
{ {
abbreviation = 'tw', abbreviation = 'tw',
@ -9089,7 +9089,7 @@ return {
scope = { 'global' }, scope = { 'global' },
short_desc = N_('No description'), short_desc = N_('No description'),
type = 'boolean', type = 'boolean',
hidden = true, immutable = true,
}, },
{ {
abbreviation = 'udir', abbreviation = 'udir',