mirror of
https://github.com/neovim/neovim.git
synced 2025-09-08 04:18:18 +00:00
vim-patch:8.2.1065: Vim9: no line break allowed inside a list
Problem: Vim9: no line break allowed inside a list.
Solution: Handle line break inside a list in Vim9 script.
7147820cb9
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -2971,7 +2971,7 @@ static int eval7(char **arg, typval_T *rettv, evalarg_T *const evalarg, bool wan
|
|||||||
|
|
||||||
// List: [expr, expr]
|
// List: [expr, expr]
|
||||||
case '[':
|
case '[':
|
||||||
ret = get_list_tv(arg, rettv, flags);
|
ret = get_list_tv(arg, rettv, evalarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Dictionary: #{key: val, key: val}
|
// Dictionary: #{key: val, key: val}
|
||||||
@@ -3981,14 +3981,13 @@ void partial_unref(partial_T *pt)
|
|||||||
|
|
||||||
/// Allocate a variable for a List and fill it from "*arg".
|
/// Allocate a variable for a List and fill it from "*arg".
|
||||||
///
|
///
|
||||||
|
/// @param arg "*arg" points to the "[".
|
||||||
/// @return OK or FAIL.
|
/// @return OK or FAIL.
|
||||||
static int get_list_tv(char **arg, typval_T *rettv, const int flags)
|
static int get_list_tv(char **arg, typval_T *rettv, evalarg_T *const evalarg)
|
||||||
{
|
{
|
||||||
const bool evaluate = flags & EVAL_EVALUATE;
|
const bool evaluate = evalarg == NULL ? false : evalarg->eval_flags & EVAL_EVALUATE;
|
||||||
list_T *l = NULL;
|
list_T *l = NULL;
|
||||||
|
|
||||||
evalarg_T evalarg = { .eval_flags = flags };
|
|
||||||
|
|
||||||
if (evaluate) {
|
if (evaluate) {
|
||||||
l = tv_list_alloc(kListLenShouldKnow);
|
l = tv_list_alloc(kListLenShouldKnow);
|
||||||
}
|
}
|
||||||
@@ -3996,7 +3995,7 @@ static int get_list_tv(char **arg, typval_T *rettv, const int flags)
|
|||||||
*arg = skipwhite(*arg + 1);
|
*arg = skipwhite(*arg + 1);
|
||||||
while (**arg != ']' && **arg != NUL) {
|
while (**arg != ']' && **arg != NUL) {
|
||||||
typval_T tv;
|
typval_T tv;
|
||||||
if (eval1(arg, &tv, &evalarg) == FAIL) { // Recursive!
|
if (eval1(arg, &tv, evalarg) == FAIL) { // Recursive!
|
||||||
goto failret;
|
goto failret;
|
||||||
}
|
}
|
||||||
if (evaluate) {
|
if (evaluate) {
|
||||||
@@ -4004,14 +4003,20 @@ static int get_list_tv(char **arg, typval_T *rettv, const int flags)
|
|||||||
tv_list_append_owned_tv(l, tv);
|
tv_list_append_owned_tv(l, tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the comma must comma after the value
|
||||||
|
bool had_comma = **arg == ',';
|
||||||
|
if (had_comma) {
|
||||||
|
*arg = skipwhite(*arg + 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (**arg == ']') {
|
if (**arg == ']') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (**arg != ',') {
|
|
||||||
|
if (!had_comma) {
|
||||||
semsg(_("E696: Missing comma in List: %s"), *arg);
|
semsg(_("E696: Missing comma in List: %s"), *arg);
|
||||||
goto failret;
|
goto failret;
|
||||||
}
|
}
|
||||||
*arg = skipwhite(*arg + 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (**arg != ']') {
|
if (**arg != ']') {
|
||||||
|
@@ -183,22 +183,25 @@ func Test_argument()
|
|||||||
|
|
||||||
let save_columns = &columns
|
let save_columns = &columns
|
||||||
let &columns = 79
|
let &columns = 79
|
||||||
exe 'args ' .. join(range(1, 81))
|
try
|
||||||
call assert_equal(join([
|
exe 'args ' .. join(range(1, 81))
|
||||||
\ '',
|
call assert_equal(join([
|
||||||
\ '[1] 6 11 16 21 26 31 36 41 46 51 56 61 66 71 76 81 ',
|
\ '',
|
||||||
\ '2 7 12 17 22 27 32 37 42 47 52 57 62 67 72 77 ',
|
\ '[1] 6 11 16 21 26 31 36 41 46 51 56 61 66 71 76 81 ',
|
||||||
\ '3 8 13 18 23 28 33 38 43 48 53 58 63 68 73 78 ',
|
\ '2 7 12 17 22 27 32 37 42 47 52 57 62 67 72 77 ',
|
||||||
\ '4 9 14 19 24 29 34 39 44 49 54 59 64 69 74 79 ',
|
\ '3 8 13 18 23 28 33 38 43 48 53 58 63 68 73 78 ',
|
||||||
\ '5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 ',
|
\ '4 9 14 19 24 29 34 39 44 49 54 59 64 69 74 79 ',
|
||||||
\ ], "\n"),
|
\ '5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 ',
|
||||||
\ execute('args'))
|
\ ], "\n"),
|
||||||
|
\ execute('args'))
|
||||||
|
|
||||||
" No trailing newline with one item per row.
|
" No trailing newline with one item per row.
|
||||||
let long_arg = repeat('X', 81)
|
let long_arg = repeat('X', 81)
|
||||||
exe 'args ' .. long_arg
|
exe 'args ' .. long_arg
|
||||||
call assert_equal("\n[".long_arg.']', execute('args'))
|
call assert_equal("\n[".long_arg.']', execute('args'))
|
||||||
let &columns = save_columns
|
finally
|
||||||
|
let &columns = save_columns
|
||||||
|
endtry
|
||||||
|
|
||||||
" Setting argument list should fail when the current buffer has unsaved
|
" Setting argument list should fail when the current buffer has unsaved
|
||||||
" changes
|
" changes
|
||||||
|
Reference in New Issue
Block a user