mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.2.2254: Vim9: bool option type is number
Problem: Vim9: bool option type is number. Solution: Have get_option_value() return a different value for bool and number options. (closes #7583)
This commit is contained in:
29
src/typval.c
29
src/typval.c
@@ -1083,7 +1083,7 @@ eval_option(
|
||||
char_u *option_end;
|
||||
long numval;
|
||||
char_u *stringval;
|
||||
int opt_type;
|
||||
getoption_T opt_type;
|
||||
int c;
|
||||
int working = (**arg == '+'); // has("+option")
|
||||
int ret = OK;
|
||||
@@ -1109,7 +1109,7 @@ eval_option(
|
||||
opt_type = get_option_value(*arg, &numval,
|
||||
rettv == NULL ? NULL : &stringval, opt_flags);
|
||||
|
||||
if (opt_type == -3) // invalid name
|
||||
if (opt_type == gov_unknown)
|
||||
{
|
||||
if (rettv != NULL)
|
||||
semsg(_(e_unknown_option), *arg);
|
||||
@@ -1117,20 +1117,29 @@ eval_option(
|
||||
}
|
||||
else if (rettv != NULL)
|
||||
{
|
||||
if (opt_type == -2) // hidden string option
|
||||
if (opt_type == gov_hidden_string)
|
||||
{
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = NULL;
|
||||
}
|
||||
else if (opt_type == -1) // hidden number option
|
||||
else if (opt_type == gov_hidden_bool || opt_type == gov_hidden_number)
|
||||
{
|
||||
rettv->v_type = VAR_NUMBER;
|
||||
rettv->v_type = in_vim9script() && opt_type == gov_hidden_bool
|
||||
? VAR_BOOL : VAR_NUMBER;
|
||||
rettv->vval.v_number = 0;
|
||||
}
|
||||
else if (opt_type == 1) // number option
|
||||
else if (opt_type == gov_bool || opt_type == gov_number)
|
||||
{
|
||||
rettv->v_type = VAR_NUMBER;
|
||||
rettv->vval.v_number = numval;
|
||||
if (in_vim9script() && opt_type == gov_bool)
|
||||
{
|
||||
rettv->v_type = VAR_BOOL;
|
||||
rettv->vval.v_number = numval ? VVAL_TRUE : VVAL_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
rettv->v_type = VAR_NUMBER;
|
||||
rettv->vval.v_number = numval;
|
||||
}
|
||||
}
|
||||
else // string option
|
||||
{
|
||||
@@ -1138,7 +1147,9 @@ eval_option(
|
||||
rettv->vval.v_string = stringval;
|
||||
}
|
||||
}
|
||||
else if (working && (opt_type == -2 || opt_type == -1))
|
||||
else if (working && (opt_type == gov_hidden_bool
|
||||
|| opt_type == gov_hidden_number
|
||||
|| opt_type == gov_hidden_string))
|
||||
ret = FAIL;
|
||||
|
||||
*option_end = c; // put back for error messages
|
||||
|
Reference in New Issue
Block a user