mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.3365: Vim9: cannot use option for all operations
Problem: Vim9: cannot use option for all operations. Solution: Recognize more operations. (closes #8779)
This commit is contained in:
@@ -3425,12 +3425,26 @@ find_ex_command(
|
|||||||
{
|
{
|
||||||
char_u *pskip = skip_option_env_lead(eap->cmd);
|
char_u *pskip = skip_option_env_lead(eap->cmd);
|
||||||
|
|
||||||
if (vim_strchr((char_u *)"{('[\"@", *p) != NULL
|
if (vim_strchr((char_u *)"{('[\"@&", *p) != NULL
|
||||||
|| ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL))
|
|| ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL))
|
||||||
{
|
{
|
||||||
int oplen;
|
int oplen;
|
||||||
int heredoc;
|
int heredoc;
|
||||||
char_u *swp = skipwhite(p);
|
char_u *swp;
|
||||||
|
|
||||||
|
if (*eap->cmd == '&')
|
||||||
|
{
|
||||||
|
p = to_name_end(eap->cmd + 1, FALSE);
|
||||||
|
if (ends_excmd(*skipwhite(p)))
|
||||||
|
{
|
||||||
|
// "&option <NL>" is the start of an expression.
|
||||||
|
eap->cmdidx = CMD_eval;
|
||||||
|
return eap->cmd;
|
||||||
|
}
|
||||||
|
// "&option" can be followed by "->" or "=", check below
|
||||||
|
}
|
||||||
|
|
||||||
|
swp = skipwhite(p);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
// "(..." is an expression.
|
// "(..." is an expression.
|
||||||
@@ -3530,10 +3544,14 @@ find_ex_command(
|
|||||||
|
|
||||||
// Recognize an assignment if we recognize the variable name:
|
// Recognize an assignment if we recognize the variable name:
|
||||||
// "g:var = expr"
|
// "g:var = expr"
|
||||||
|
// "@r = expr"
|
||||||
|
// "&opt = expr"
|
||||||
// "var = expr" where "var" is a variable name or we are skipping
|
// "var = expr" where "var" is a variable name or we are skipping
|
||||||
// (variable declaration might have been skipped).
|
// (variable declaration might have been skipped).
|
||||||
if (*eap->cmd == '@')
|
if (*eap->cmd == '@')
|
||||||
p = eap->cmd + 2;
|
p = eap->cmd + 2;
|
||||||
|
else if (*eap->cmd == '&')
|
||||||
|
p = skiptowhite_esc(eap->cmd + 1);
|
||||||
oplen = assignment_len(skipwhite(p), &heredoc);
|
oplen = assignment_len(skipwhite(p), &heredoc);
|
||||||
if (oplen > 0)
|
if (oplen > 0)
|
||||||
{
|
{
|
||||||
|
@@ -8,6 +8,7 @@ imported_T *find_imported(char_u *name, size_t len, cctx_T *cctx);
|
|||||||
imported_T *find_imported_in_script(char_u *name, size_t len, int sid);
|
imported_T *find_imported_in_script(char_u *name, size_t len, int sid);
|
||||||
char_u *peek_next_line_from_context(cctx_T *cctx);
|
char_u *peek_next_line_from_context(cctx_T *cctx);
|
||||||
char_u *next_line_from_context(cctx_T *cctx, int skip_comment);
|
char_u *next_line_from_context(cctx_T *cctx, int skip_comment);
|
||||||
|
char_u *to_name_end(char_u *arg, int use_namespace);
|
||||||
char_u *to_name_const_end(char_u *arg);
|
char_u *to_name_const_end(char_u *arg);
|
||||||
int get_lambda_tv_and_compile(char_u **arg, typval_T *rettv, int types_optional, evalarg_T *evalarg);
|
int get_lambda_tv_and_compile(char_u **arg, typval_T *rettv, int types_optional, evalarg_T *evalarg);
|
||||||
exprtype_T get_compare_type(char_u *p, int *len, int *type_is);
|
exprtype_T get_compare_type(char_u *p, int *len, int *type_is);
|
||||||
|
@@ -521,6 +521,22 @@ def Test_method_and_user_command()
|
|||||||
CheckScriptSuccess(lines)
|
CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_option_use_linebreak()
|
||||||
|
var lines =<< trim END
|
||||||
|
new
|
||||||
|
&matchpairs = '(:)'
|
||||||
|
&matchpairs->setline(1)
|
||||||
|
&matchpairs = '[:]'
|
||||||
|
&matchpairs ->setline(2)
|
||||||
|
&matchpairs = '{:}'
|
||||||
|
&matchpairs
|
||||||
|
->setline(3)
|
||||||
|
assert_equal(['(:)', '[:]', '{:}'], getline(1, '$'))
|
||||||
|
bwipe!
|
||||||
|
END
|
||||||
|
CheckDefAndScriptSuccess(lines)
|
||||||
|
enddef
|
||||||
|
|
||||||
def Test_skipped_expr_linebreak()
|
def Test_skipped_expr_linebreak()
|
||||||
if 0
|
if 0
|
||||||
var x = []
|
var x = []
|
||||||
|
@@ -755,6 +755,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
3365,
|
||||||
/**/
|
/**/
|
||||||
3364,
|
3364,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -3579,7 +3579,7 @@ theend:
|
|||||||
* Return a pointer to just after the name. Equal to "arg" if there is no
|
* Return a pointer to just after the name. Equal to "arg" if there is no
|
||||||
* valid name.
|
* valid name.
|
||||||
*/
|
*/
|
||||||
static char_u *
|
char_u *
|
||||||
to_name_end(char_u *arg, int use_namespace)
|
to_name_end(char_u *arg, int use_namespace)
|
||||||
{
|
{
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
Reference in New Issue
Block a user