void
separate_nextcmd(exarg_T *eap, int keep_backslash)
{
+ int vim9script = in_vim9script();
char_u *p;
#ifdef FEAT_QUICKFIX
// :@" and :*" do not start a comment!
// :redir @" doesn't either.
else if ((*p == '"'
- && !in_vim9script()
+ && !vim9script
&& !(eap->argt & EX_NOTRLCOM)
&& ((eap->cmdidx != CMD_at && eap->cmdidx != CMD_star)
|| p != eap->arg)
&& (eap->cmdidx != CMD_redir
|| p != eap->arg + 1 || p[-1] != '@'))
|| (*p == '#'
- && in_vim9script()
+ && vim9script
&& !(eap->argt & EX_NOTRLCOM)
&& p > eap->cmd && VIM_ISWHITE(p[-1]))
|| (*p == '|'
}
else
{
- eap->nextcmd = check_nextcmd(p);
+ set_nextcmd(eap, p);
*p = NUL;
break;
}
void
set_nextcmd(exarg_T *eap, char_u *arg)
{
- char_u *p = check_nextcmd(arg);
+ char_u *p = skipwhite(arg);
+
+ if (in_vim9script() && *p == '#')
+ {
+ char_u *nl = vim_strchr(p, NL);
+ if (nl != NULL)
+ p = nl;
+ }
+
+ p = check_nextcmd(p);
if (eap->nextcmd == NULL)
eap->nextcmd = p;
v9.CheckSourceSuccess(lines)
enddef
+" Test for a block in a command with comments
+def Test_block_command_with_comment()
+ var lines =<< trim END
+ vim9script
+
+ g:Str = ''
+ command Cmd1 {
+ g:Str = 'Hello' # comment1
+ var x: string # comment2
+ g:Str ..= ' World' # comment3
+ }
+ Cmd1
+ assert_equal('Hello World', g:Str)
+
+ g:Str = ''
+ command Cmd2 {
+ # comment1
+ g:Str = 'Hello'
+ # comment2
+ g:Str ..= ' World'
+ # comment3
+ }
+ Cmd2
+ assert_equal('Hello World', g:Str)
+
+ command Cmd3 {
+ new # comment1
+ setline(1, 'hello') # comment2
+ }
+ Cmd3
+ assert_equal(['hello'], getline(1, '$'))
+ :bw!
+
+ command Cmd4 {
+ # comment1
+ new
+ # comment2
+ setline(1, 'hello') # comment2
+ }
+ Cmd4
+ assert_equal(['hello'], getline(1, '$'))
+ :bw!
+ END
+ v9.CheckSourceSuccess(lines)
+enddef
+
" Test for using too many nested blocks
def Test_too_many_nested_blocks()
var lines = ['vim9script']
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1770,
/**/
1769,
/**/