mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #20110 from ii14/vim-7c7e1e9b98d4
vim-patch:8.2.3702,9.0.0409
This commit is contained in:
commit
e93f22f28a
@ -2997,7 +2997,9 @@ static int eval7(char **arg, typval_T *rettv, int evaluate, int want_string)
|
|||||||
// decimal, hex or octal number
|
// decimal, hex or octal number
|
||||||
vim_str2nr(*arg, NULL, &len, STR2NR_ALL, &n, NULL, 0, true);
|
vim_str2nr(*arg, NULL, &len, STR2NR_ALL, &n, NULL, 0, true);
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
|
if (evaluate) {
|
||||||
semsg(_(e_invexpr2), *arg);
|
semsg(_(e_invexpr2), *arg);
|
||||||
|
}
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -4582,22 +4584,21 @@ static int dict_get_tv(char **arg, typval_T *rettv, int evaluate, bool literal)
|
|||||||
{
|
{
|
||||||
typval_T tv;
|
typval_T tv;
|
||||||
char *key = NULL;
|
char *key = NULL;
|
||||||
char *start = skipwhite(*arg + 1);
|
char *curly_expr = skipwhite(*arg + 1);
|
||||||
char buf[NUMBUFLEN];
|
char buf[NUMBUFLEN];
|
||||||
|
|
||||||
// First check if it's not a curly-braces thing: {expr}.
|
// First check if it's not a curly-braces expression: {expr}.
|
||||||
// Must do this without evaluating, otherwise a function may be called
|
// Must do this without evaluating, otherwise a function may be called
|
||||||
// twice. Unfortunately this means we need to call eval1() twice for the
|
// twice. Unfortunately this means we need to call eval1() twice for the
|
||||||
// first item.
|
// first item.
|
||||||
// But {} is an empty Dictionary.
|
// "{}" is an empty Dictionary.
|
||||||
if (*start != '}') {
|
// "#{abc}" is never a curly-braces expression.
|
||||||
if (eval1(&start, &tv, false) == FAIL) { // recursive!
|
if (*curly_expr != '}'
|
||||||
return FAIL;
|
&& !literal
|
||||||
}
|
&& eval1(&curly_expr, &tv, false) == OK
|
||||||
if (*skipwhite(start) == '}') {
|
&& *skipwhite(curly_expr) == '}') {
|
||||||
return NOTDONE;
|
return NOTDONE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
dict_T *d = NULL;
|
dict_T *d = NULL;
|
||||||
if (evaluate) {
|
if (evaluate) {
|
||||||
|
@ -165,6 +165,13 @@ func Test_dict()
|
|||||||
call assert_equal({'c': 'ccc', '1': 99, 'b': [1, 2, function('strlen')], '3': 33, '-1': {'a': 1}}, d)
|
call assert_equal({'c': 'ccc', '1': 99, 'b': [1, 2, function('strlen')], '3': 33, '-1': {'a': 1}}, d)
|
||||||
call filter(d, 'v:key =~ ''[ac391]''')
|
call filter(d, 'v:key =~ ''[ac391]''')
|
||||||
call assert_equal({'c': 'ccc', '1': 99, '3': 33, '-1': {'a': 1}}, d)
|
call assert_equal({'c': 'ccc', '1': 99, '3': 33, '-1': {'a': 1}}, d)
|
||||||
|
|
||||||
|
" allow key starting with number at the start, not a curly expression
|
||||||
|
call assert_equal({'1foo': 77}, #{1foo: 77})
|
||||||
|
|
||||||
|
" #{expr} is not a curly expression
|
||||||
|
let x = 'x'
|
||||||
|
call assert_equal(#{g: x}, #{g:x})
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Dictionary identity
|
" Dictionary identity
|
||||||
|
@ -104,7 +104,7 @@ describe(':source', function()
|
|||||||
eq("0zBEEFCAFE", meths.exec('echo d', true))
|
eq("0zBEEFCAFE", meths.exec('echo d', true))
|
||||||
|
|
||||||
exec('set cpoptions+=C')
|
exec('set cpoptions+=C')
|
||||||
eq('Vim(let):E15: Invalid expression: #{', exc_exec('source'))
|
eq('Vim(let):E723: Missing end of Dictionary \'}\': ', exc_exec('source'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('selection in current buffer', function()
|
it('selection in current buffer', function()
|
||||||
@ -138,7 +138,7 @@ describe(':source', function()
|
|||||||
eq('Vim(echo):E117: Unknown function: s:C', exc_exec('echo D()'))
|
eq('Vim(echo):E117: Unknown function: s:C', exc_exec('echo D()'))
|
||||||
|
|
||||||
exec('set cpoptions+=C')
|
exec('set cpoptions+=C')
|
||||||
eq('Vim(let):E15: Invalid expression: #{', exc_exec("'<,'>source"))
|
eq('Vim(let):E723: Missing end of Dictionary \'}\': ', exc_exec("'<,'>source"))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not break if current buffer is modified while sourced', function()
|
it('does not break if current buffer is modified while sourced', function()
|
||||||
|
Loading…
Reference in New Issue
Block a user