mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 12:45:17 -07:00
fix(:let): fix error when applying operator to boolean option (#24030)
This commit is contained in:
parent
d81f78713b
commit
1f8fb7c000
@ -817,12 +817,11 @@ static char *ex_let_option(char *arg, typval_T *const tv, const bool is_const,
|
||||
new_n = num_modulus(cur_n, new_n); break;
|
||||
}
|
||||
|
||||
// clamp boolean values
|
||||
if (newval.type == kOptValTypeBoolean && (new_n > 1 || new_n < -1)) {
|
||||
new_n = (new_n > 1) ? 1 : -1;
|
||||
if (curval.type == kOptValTypeNumber) {
|
||||
newval = NUMBER_OPTVAL(new_n);
|
||||
} else {
|
||||
newval = BOOLEAN_OPTVAL(new_n == 0 ? kFalse : (new_n >= 1 ? kTrue : kNone));
|
||||
}
|
||||
|
||||
newval = kOptValTypeNumber ? NUMBER_OPTVAL(new_n) : BOOLEAN_OPTVAL((TriState)new_n);
|
||||
} else if (!hidden && is_string
|
||||
&& curval.data.string.data != NULL && newval.data.string.data != NULL) { // string
|
||||
OptVal newval_old = newval;
|
||||
|
@ -92,6 +92,20 @@ describe(':let', function()
|
||||
]])
|
||||
eq(1, eval('1'))
|
||||
end)
|
||||
|
||||
it('can apply operator to boolean option', function()
|
||||
eq(true, meths.get_option_value('equalalways', {}))
|
||||
command('let &equalalways -= 1')
|
||||
eq(false, meths.get_option_value('equalalways', {}))
|
||||
command('let &equalalways += 1')
|
||||
eq(true, meths.get_option_value('equalalways', {}))
|
||||
command('let &equalalways *= 1')
|
||||
eq(true, meths.get_option_value('equalalways', {}))
|
||||
command('let &equalalways /= 1')
|
||||
eq(true, meths.get_option_value('equalalways', {}))
|
||||
command('let &equalalways %= 1')
|
||||
eq(false, meths.get_option_value('equalalways', {}))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe(':let and :const', function()
|
||||
|
Loading…
Reference in New Issue
Block a user