mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Problem: Vim9: cannot split an expression into multiple lines. Solution: Continue in next line after an operator.
This commit is contained in:
@@ -2069,6 +2069,24 @@ next_line_from_context(cctx_T *cctx)
|
||||
return line;
|
||||
}
|
||||
|
||||
/*
|
||||
* If "*arg" is at the end of the line, advance to the next line.
|
||||
* Return FAIL if beyond the last line, "*arg" is unmodified then.
|
||||
*/
|
||||
static int
|
||||
may_get_next_line(char_u **arg, cctx_T *cctx)
|
||||
{
|
||||
if (**arg == NUL)
|
||||
{
|
||||
char_u *next = next_line_from_context(cctx);
|
||||
|
||||
if (next == NULL)
|
||||
return FAIL;
|
||||
*arg = skipwhite(next);
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generate an instruction to load script-local variable "name", without the
|
||||
* leading "s:".
|
||||
@@ -3394,14 +3412,17 @@ compile_expr6(char_u **arg, cctx_T *cctx)
|
||||
op = skipwhite(*arg);
|
||||
if (*op != '*' && *op != '/' && *op != '%')
|
||||
break;
|
||||
if (!VIM_ISWHITE(**arg) || !VIM_ISWHITE(op[1]))
|
||||
if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(op[1]))
|
||||
{
|
||||
char_u buf[3];
|
||||
|
||||
vim_strncpy(buf, op, 1);
|
||||
semsg(_(e_white_both), buf);
|
||||
return FAIL;
|
||||
}
|
||||
*arg = skipwhite(op + 1);
|
||||
if (may_get_next_line(arg, cctx) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
// get the second variable
|
||||
if (compile_expr7(arg, cctx) == FAIL)
|
||||
@@ -3438,15 +3459,18 @@ compile_expr5(char_u **arg, cctx_T *cctx)
|
||||
break;
|
||||
oplen = (*op == '.' ? 2 : 1);
|
||||
|
||||
if (!VIM_ISWHITE(**arg) || !VIM_ISWHITE(op[oplen]))
|
||||
if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(op[oplen]))
|
||||
{
|
||||
char_u buf[3];
|
||||
|
||||
vim_strncpy(buf, op, oplen);
|
||||
semsg(_(e_white_both), buf);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
*arg = skipwhite(op + oplen);
|
||||
if (may_get_next_line(arg, cctx) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
// get the second variable
|
||||
if (compile_expr6(arg, cctx) == FAIL)
|
||||
@@ -3572,16 +3596,20 @@ compile_expr4(char_u **arg, cctx_T *cctx)
|
||||
++len;
|
||||
// nothing appended: match case
|
||||
|
||||
if (!VIM_ISWHITE(**arg) || !VIM_ISWHITE(p[len]))
|
||||
if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[len]))
|
||||
{
|
||||
char_u buf[7];
|
||||
|
||||
vim_strncpy(buf, p, len);
|
||||
semsg(_(e_white_both), buf);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// get the second variable
|
||||
*arg = skipwhite(p + len);
|
||||
if (may_get_next_line(arg, cctx) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
if (compile_expr5(arg, cctx) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
@@ -3611,8 +3639,11 @@ compile_and_or(char_u **arg, cctx_T *cctx, char *op)
|
||||
ga_init2(&end_ga, sizeof(int), 10);
|
||||
while (p[0] == opchar && p[1] == opchar)
|
||||
{
|
||||
if (!VIM_ISWHITE(**arg) || !VIM_ISWHITE(p[2]))
|
||||
if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[2]))
|
||||
{
|
||||
semsg(_(e_white_both), op);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (ga_grow(&end_ga, 1) == FAIL)
|
||||
{
|
||||
@@ -3626,6 +3657,9 @@ compile_and_or(char_u **arg, cctx_T *cctx, char *op)
|
||||
|
||||
// eval the next expression
|
||||
*arg = skipwhite(p + 2);
|
||||
if (may_get_next_line(arg, cctx) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
if ((opchar == '|' ? compile_expr3(arg, cctx)
|
||||
: compile_expr4(arg, cctx)) == FAIL)
|
||||
{
|
||||
@@ -3726,13 +3760,19 @@ compile_expr1(char_u **arg, cctx_T *cctx)
|
||||
type_T *type1;
|
||||
type_T *type2;
|
||||
|
||||
if (!VIM_ISWHITE(**arg) || !VIM_ISWHITE(p[1]))
|
||||
if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[1]))
|
||||
{
|
||||
semsg(_(e_white_both), "?");
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
generate_JUMP(cctx, JUMP_IF_FALSE, 0);
|
||||
|
||||
// evaluate the second expression; any type is accepted
|
||||
*arg = skipwhite(p + 1);
|
||||
if (may_get_next_line(arg, cctx) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
if (compile_expr1(arg, cctx) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
@@ -3754,11 +3794,17 @@ compile_expr1(char_u **arg, cctx_T *cctx)
|
||||
emsg(_(e_missing_colon));
|
||||
return FAIL;
|
||||
}
|
||||
if (!VIM_ISWHITE(**arg) || !VIM_ISWHITE(p[1]))
|
||||
if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[1]))
|
||||
{
|
||||
semsg(_(e_white_both), ":");
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// evaluate the third expression
|
||||
*arg = skipwhite(p + 1);
|
||||
if (may_get_next_line(arg, cctx) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
if (compile_expr1(arg, cctx) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
|
Reference in New Issue
Block a user