0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.0611: Vim9: no check for space before #comment

Problem:    Vim9: no check for space before #comment.
Solution:   Add space checks.
This commit is contained in:
Bram Moolenaar
2020-04-20 17:46:14 +02:00
parent 08f4157c5c
commit faac410409
5 changed files with 69 additions and 4 deletions

View File

@@ -1773,7 +1773,7 @@ eval0(
p = skipwhite(arg);
ret = eval1(&p, rettv, evaluate);
if (ret == FAIL || !ends_excmd(*p))
if (ret == FAIL || !ends_excmd2(arg, p))
{
if (ret != FAIL)
clear_tv(rettv);

View File

@@ -737,7 +737,7 @@ ex_let_const(exarg_T *eap, int is_const)
emsg(_(e_invarg));
else if (expr[0] == '.')
emsg(_("E985: .= is not supported with script version 2"));
else if (!ends_excmd(*arg))
else if (!ends_excmd2(eap->cmd, arg))
// ":let var1 var2"
arg = list_arg_vars(eap, arg, &first);
else if (!eap->skip)
@@ -1068,7 +1068,7 @@ list_arg_vars(exarg_T *eap, char_u *arg, int *first)
char_u *tofree;
typval_T tv;
while (!ends_excmd(*arg) && !got_int)
while (!ends_excmd2(eap->cmd, arg) && !got_int)
{
if (error || eap->skip)
{

View File

@@ -7903,7 +7903,7 @@ ex_findpat(exarg_T *eap)
p = skipwhite(p);
// Check for trailing illegal characters
if (!ends_excmd(*p))
if (!ends_excmd2(eap->arg, p))
eap->errmsg = e_trailing;
else
eap->nextcmd = check_nextcmd(p);

View File

@@ -1208,6 +1208,69 @@ def Test_vim9_comment_not_compiled()
'let g:var = 123',
'unlet g:var # something',
], 'E488:')
CheckScriptSuccess([
'vim9script',
'if 1 # comment',
' echo "yes"',
'elseif 2 #comment',
' echo "no"',
'endif',
])
CheckScriptFailure([
'vim9script',
'if 1# comment',
' echo "yes"',
'endif',
], 'E15:')
CheckScriptFailure([
'vim9script',
'if 0 # comment',
' echo "yes"',
'elseif 2#comment',
' echo "no"',
'endif',
], 'E15:')
CheckScriptSuccess([
'vim9script',
'let # comment',
])
CheckScriptFailure([
'vim9script',
'let# comment',
], 'E121:')
CheckScriptSuccess([
'vim9script',
'let v:version # comment',
])
CheckScriptFailure([
'vim9script',
'let v:version# comment',
], 'E121:')
CheckScriptSuccess([
'vim9script',
'new'
'call setline(1, ["# define pat", "last"])',
'$',
'dsearch /pat/ #comment',
'bwipe!',
])
CheckScriptFailure([
'vim9script',
'new'
'call setline(1, ["# define pat", "last"])',
'$',
'dsearch /pat/#comment',
'bwipe!',
], 'E488:')
enddef
" Keep this last, it messes up highlighting.

View File

@@ -746,6 +746,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
611,
/**/
610,
/**/