mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 13:38:34 +00:00
refactor(option): remove OPT_CLEAR
This commit is contained in:
@@ -465,9 +465,6 @@ OptVal get_option_value_for(const char *const name, uint32_t *flagsp, int scope,
|
|||||||
/// @param[in] name Option name.
|
/// @param[in] name Option name.
|
||||||
/// @param[in] value Option value.
|
/// @param[in] value Option value.
|
||||||
/// @param[in] opt_flags Flags: OPT_LOCAL, OPT_GLOBAL, or 0 (both).
|
/// @param[in] opt_flags Flags: OPT_LOCAL, OPT_GLOBAL, or 0 (both).
|
||||||
/// If OPT_CLEAR is set, the value of the option
|
|
||||||
/// is cleared (the exact semantics of this depend
|
|
||||||
/// on the option).
|
|
||||||
/// @param[in] opt_type Option type. See SREQ_* in option_defs.h.
|
/// @param[in] opt_type Option type. See SREQ_* in option_defs.h.
|
||||||
/// @param[in] from Target buffer/window.
|
/// @param[in] from Target buffer/window.
|
||||||
/// @param[out] err Error message, if any.
|
/// @param[out] err Error message, if any.
|
||||||
|
@@ -3722,9 +3722,6 @@ vimoption_T *get_option(int opt_idx)
|
|||||||
/// @param[in] name Option name.
|
/// @param[in] name Option name.
|
||||||
/// @param[in] value Option value. If NIL_OPTVAL, the option value is cleared.
|
/// @param[in] value Option value. If NIL_OPTVAL, the option value is cleared.
|
||||||
/// @param[in] opt_flags Flags: OPT_LOCAL, OPT_GLOBAL, or 0 (both).
|
/// @param[in] opt_flags Flags: OPT_LOCAL, OPT_GLOBAL, or 0 (both).
|
||||||
/// If OPT_CLEAR is set, the value of the option
|
|
||||||
/// is cleared (the exact semantics of this depend
|
|
||||||
/// on the option).
|
|
||||||
///
|
///
|
||||||
/// @return NULL on success, an untranslated error message on error.
|
/// @return NULL on success, an untranslated error message on error.
|
||||||
const char *set_option_value(const char *const name, const OptVal value, int opt_flags)
|
const char *set_option_value(const char *const name, const OptVal value, int opt_flags)
|
||||||
@@ -3765,9 +3762,11 @@ const char *set_option_value(const char *const name, const OptVal value, int opt
|
|||||||
// Copy the value so we can modify the copy.
|
// Copy the value so we can modify the copy.
|
||||||
OptVal v = optval_copy(value);
|
OptVal v = optval_copy(value);
|
||||||
|
|
||||||
if (v.type == kOptValTypeNil) {
|
// Clear an option. For global-local options clear the local value
|
||||||
opt_flags |= OPT_CLEAR;
|
// (the exact semantics of this depend on the option).
|
||||||
|
bool clear = v.type == kOptValTypeNil;
|
||||||
|
|
||||||
|
if (v.type == kOptValTypeNil) {
|
||||||
// Change the type of the OptVal to the type used by the option so that it can be cleared.
|
// Change the type of the OptVal to the type used by the option so that it can be cleared.
|
||||||
// TODO(famiu): Clean up all of this after set_(num|bool|string)_option() is unified.
|
// TODO(famiu): Clean up all of this after set_(num|bool|string)_option() is unified.
|
||||||
if (flags & P_BOOL) {
|
if (flags & P_BOOL) {
|
||||||
@@ -3794,7 +3793,7 @@ const char *set_option_value(const char *const name, const OptVal value, int opt
|
|||||||
case kOptValTypeNil:
|
case kOptValTypeNil:
|
||||||
abort(); // This will never happen.
|
abort(); // This will never happen.
|
||||||
case kOptValTypeBoolean: {
|
case kOptValTypeBoolean: {
|
||||||
if (opt_flags & OPT_CLEAR) {
|
if (clear) {
|
||||||
if ((int *)varp == &curbuf->b_p_ar) {
|
if ((int *)varp == &curbuf->b_p_ar) {
|
||||||
v.data.boolean = kNone;
|
v.data.boolean = kNone;
|
||||||
} else {
|
} else {
|
||||||
@@ -3805,7 +3804,7 @@ const char *set_option_value(const char *const name, const OptVal value, int opt
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case kOptValTypeNumber: {
|
case kOptValTypeNumber: {
|
||||||
if (opt_flags & OPT_CLEAR) {
|
if (clear) {
|
||||||
if ((long *)varp == &curbuf->b_p_ul) {
|
if ((long *)varp == &curbuf->b_p_ul) {
|
||||||
v.data.number = NO_LOCAL_UNDOLEVEL;
|
v.data.number = NO_LOCAL_UNDOLEVEL;
|
||||||
} else if ((long *)varp == &curwin->w_p_so || (long *)varp == &curwin->w_p_siso) {
|
} else if ((long *)varp == &curwin->w_p_so || (long *)varp == &curwin->w_p_siso) {
|
||||||
@@ -3819,7 +3818,7 @@ const char *set_option_value(const char *const name, const OptVal value, int opt
|
|||||||
}
|
}
|
||||||
case kOptValTypeString: {
|
case kOptValTypeString: {
|
||||||
const char *s = v.data.string.data;
|
const char *s = v.data.string.data;
|
||||||
if (s == NULL || opt_flags & OPT_CLEAR) {
|
if (s == NULL || clear) {
|
||||||
s = "";
|
s = "";
|
||||||
}
|
}
|
||||||
errmsg = set_string_option(opt_idx, s, opt_flags, &value_checked, errbuf, sizeof(errbuf));
|
errmsg = set_string_option(opt_idx, s, opt_flags, &value_checked, errbuf, sizeof(errbuf));
|
||||||
|
@@ -70,7 +70,6 @@ typedef enum {
|
|||||||
OPT_ONECOLUMN = 0x40, ///< list options one per line
|
OPT_ONECOLUMN = 0x40, ///< list options one per line
|
||||||
OPT_NO_REDRAW = 0x80, ///< ignore redraw flags on option
|
OPT_NO_REDRAW = 0x80, ///< ignore redraw flags on option
|
||||||
OPT_SKIPRTP = 0x100, ///< "skiprtp" in 'sessionoptions'
|
OPT_SKIPRTP = 0x100, ///< "skiprtp" in 'sessionoptions'
|
||||||
OPT_CLEAR = 0x200, ///< Clear local value of an option.
|
|
||||||
} OptionFlags;
|
} OptionFlags;
|
||||||
|
|
||||||
// Return value from get_option_value_strict
|
// Return value from get_option_value_strict
|
||||||
|
Reference in New Issue
Block a user