refactor(options): remove code for multitype options

Problem: It was decided on Matrix chat that multitype options won't be necessary for Neovim options, and that options should only have a single canonical type. Therefore the code for supporting multitype options is unnecessary.

Solution: Remove the additional code that's used to provide multitype option support.
This commit is contained in:
Famiu Haque
2024-12-28 14:55:22 +06:00
committed by Lewis Russell
parent b192d58284
commit c5f93d7ab0
4 changed files with 11 additions and 88 deletions

View File

@@ -843,11 +843,10 @@ static char *ex_let_option(char *arg, typval_T *const tv, const bool is_const,
goto theend;
}
// Don't assume current and new values are of the same type in order to future-proof the code for
// when an option can have multiple types.
const bool is_num = ((curval.type == kOptValTypeNumber || curval.type == kOptValTypeBoolean)
&& (newval.type == kOptValTypeNumber || newval.type == kOptValTypeBoolean));
const bool is_string = curval.type == kOptValTypeString && newval.type == kOptValTypeString;
// Current value and new value must have the same type.
assert(curval.type == newval.type);
const bool is_num = curval.type == kOptValTypeNumber || curval.type == kOptValTypeBoolean;
const bool is_string = curval.type == kOptValTypeString;
if (op != NULL && *op != '=') {
if (!hidden && is_num) { // number or bool
@@ -1900,8 +1899,6 @@ static void getwinvar(typval_T *argvars, typval_T *rettv, int off)
///
/// @return Typval converted to OptVal. Must be freed by caller.
/// Returns NIL_OPTVAL for invalid option name.
///
/// TODO(famiu): Refactor this to support multitype options.
static OptVal tv_to_optval(typval_T *tv, OptIndex opt_idx, const char *option, bool *error)
{
OptVal value = NIL_OPTVAL;