forked from aniani/vim
patch 8.2.0578: heredoc for interfaces does not support "trim"
Problem: Heredoc for interfaces does not support "trim". Solution: Update the script heredoc support to be same as the :let command. (Yegappan Lakshmanan, closes #5916)
This commit is contained in:
@@ -32,7 +32,7 @@ Examples:
|
|||||||
:lua local curbuf = vim.buffer() curbuf[7] = "line #7"
|
:lua local curbuf = vim.buffer() curbuf[7] = "line #7"
|
||||||
<
|
<
|
||||||
|
|
||||||
:[range]lua << [endmarker]
|
:[range]lua << [trim] [{endmarker}]
|
||||||
{script}
|
{script}
|
||||||
{endmarker}
|
{endmarker}
|
||||||
Execute Lua script {script}.
|
Execute Lua script {script}.
|
||||||
@@ -40,10 +40,9 @@ Examples:
|
|||||||
feature wasn't compiled in. To avoid errors, see
|
feature wasn't compiled in. To avoid errors, see
|
||||||
|script-here|.
|
|script-here|.
|
||||||
|
|
||||||
The {endmarker} must NOT be preceded by any white space.
|
|
||||||
|
|
||||||
If [endmarker] is omitted from after the "<<", a dot '.' must be used after
|
If [endmarker] is omitted from after the "<<", a dot '.' must be used after
|
||||||
{script}, like for the |:append| and |:insert| commands.
|
{script}, like for the |:append| and |:insert| commands. Refer to
|
||||||
|
|:let-heredoc| for more information.
|
||||||
|
|
||||||
This form of the |:lua| command is mainly useful for including Lua code
|
This form of the |:lua| command is mainly useful for including Lua code
|
||||||
in Vim scripts.
|
in Vim scripts.
|
||||||
|
@@ -39,7 +39,7 @@ To speed up the process, you might also want to use --disable-gracket and
|
|||||||
:[range]mz[scheme] {stmt}
|
:[range]mz[scheme] {stmt}
|
||||||
Execute MzScheme statement {stmt}.
|
Execute MzScheme statement {stmt}.
|
||||||
|
|
||||||
:[range]mz[scheme] << [endmarker]
|
:[range]mz[scheme] << [trim] [{endmarker}]
|
||||||
{script}
|
{script}
|
||||||
{endmarker}
|
{endmarker}
|
||||||
Execute inlined MzScheme script {script}.
|
Execute inlined MzScheme script {script}.
|
||||||
@@ -47,12 +47,11 @@ To speed up the process, you might also want to use --disable-gracket and
|
|||||||
feature wasn't compiled in. To avoid errors, see
|
feature wasn't compiled in. To avoid errors, see
|
||||||
|script-here|.
|
|script-here|.
|
||||||
|
|
||||||
The {endmarker} below the {script} must NOT be
|
|
||||||
preceded by any white space.
|
|
||||||
|
|
||||||
If [endmarker] is omitted from after the "<<", a dot
|
If [endmarker] is omitted from after the "<<", a dot
|
||||||
'.' must be used after {script}, like for the
|
'.' must be used after {script}, like for the
|
||||||
|:append| and |:insert| commands.
|
|:append| and |:insert| commands. Refer to
|
||||||
|
|:let-heredoc| for more information.
|
||||||
|
|
||||||
|
|
||||||
*:mzfile* *:mzf*
|
*:mzfile* *:mzf*
|
||||||
:[range]mzf[ile] {file} Execute the MzScheme script in {file}.
|
:[range]mzf[ile] {file} Execute the MzScheme script in {file}.
|
||||||
|
@@ -55,7 +55,7 @@ The ActiveState one should work, Strawberry Perl is a good alternative.
|
|||||||
working: >
|
working: >
|
||||||
:perl VIM::Msg("Hello")
|
:perl VIM::Msg("Hello")
|
||||||
|
|
||||||
:pe[rl] << [endmarker]
|
:pe[rl] << [trim] [{endmarker}]
|
||||||
{script}
|
{script}
|
||||||
{endmarker}
|
{endmarker}
|
||||||
Execute Perl script {script}.
|
Execute Perl script {script}.
|
||||||
|
@@ -34,7 +34,7 @@ Both can be available at the same time, but read |python-2-and-3|.
|
|||||||
the `:python` command is working: >
|
the `:python` command is working: >
|
||||||
:python print "Hello"
|
:python print "Hello"
|
||||||
|
|
||||||
:[range]py[thon] << [endmarker]
|
:[range]py[thon] << [trim] [{endmarker}]
|
||||||
{script}
|
{script}
|
||||||
{endmarker}
|
{endmarker}
|
||||||
Execute Python script {script}.
|
Execute Python script {script}.
|
||||||
@@ -42,10 +42,9 @@ Both can be available at the same time, but read |python-2-and-3|.
|
|||||||
feature wasn't compiled in. To avoid errors, see
|
feature wasn't compiled in. To avoid errors, see
|
||||||
|script-here|.
|
|script-here|.
|
||||||
|
|
||||||
The {endmarker} below the {script} must NOT be preceded by any white space.
|
|
||||||
|
|
||||||
If [endmarker] is omitted from after the "<<", a dot '.' must be used after
|
If [endmarker] is omitted from after the "<<", a dot '.' must be used after
|
||||||
{script}, like for the |:append| and |:insert| commands.
|
{script}, like for the |:append| and |:insert| commands. Refer to
|
||||||
|
|:let-heredoc| for more information.
|
||||||
|
|
||||||
This form of the |:python| command is mainly useful for including python code
|
This form of the |:python| command is mainly useful for including python code
|
||||||
in Vim scripts.
|
in Vim scripts.
|
||||||
@@ -768,12 +767,12 @@ match the Python 2.x or Python 3 version Vim was compiled with.
|
|||||||
|
|
||||||
*:py3* *:python3*
|
*:py3* *:python3*
|
||||||
:[range]py3 {stmt}
|
:[range]py3 {stmt}
|
||||||
:[range]py3 << [endmarker]
|
:[range]py3 << [trim] [{endmarker}]
|
||||||
{script}
|
{script}
|
||||||
{endmarker}
|
{endmarker}
|
||||||
|
|
||||||
:[range]python3 {stmt}
|
:[range]python3 {stmt}
|
||||||
:[range]python3 << [endmarker]
|
:[range]python3 << [trim] [{endmarker}]
|
||||||
{script}
|
{script}
|
||||||
{endmarker}
|
{endmarker}
|
||||||
The `:py3` and `:python3` commands work similar to `:python`. A
|
The `:py3` and `:python3` commands work similar to `:python`. A
|
||||||
|
@@ -28,15 +28,15 @@ downloading Ruby there.
|
|||||||
:rub[y] {cmd} Execute Ruby command {cmd}. A command to try it out: >
|
:rub[y] {cmd} Execute Ruby command {cmd}. A command to try it out: >
|
||||||
:ruby print "Hello"
|
:ruby print "Hello"
|
||||||
|
|
||||||
:rub[y] << [endmarker]
|
:rub[y] << [trim] [{endmarker}]
|
||||||
{script}
|
{script}
|
||||||
{endmarker}
|
{endmarker}
|
||||||
Execute Ruby script {script}.
|
Execute Ruby script {script}.
|
||||||
The {endmarker} after {script} must NOT be preceded by
|
|
||||||
any white space.
|
|
||||||
|
|
||||||
If [endmarker] is omitted, it defaults to a dot '.'
|
If [endmarker] is omitted, it defaults to a dot '.'
|
||||||
like for the |:append| and |:insert| commands.
|
like for the |:append| and |:insert| commands. Refer
|
||||||
|
to |:let-heredoc| for more information.
|
||||||
|
|
||||||
|
|
||||||
This form of the |:ruby| command is mainly useful for
|
This form of the |:ruby| command is mainly useful for
|
||||||
including ruby code in vim scripts.
|
including ruby code in vim scripts.
|
||||||
|
@@ -30,7 +30,7 @@ comments, ideas etc to <Ingo.Wilken@informatik.uni-oldenburg.de>
|
|||||||
is working: >
|
is working: >
|
||||||
:tcl puts "Hello"
|
:tcl puts "Hello"
|
||||||
|
|
||||||
:[range]tc[l] << [endmarker]
|
:[range]tc[l] << [trim] [{endmarker}]
|
||||||
{script}
|
{script}
|
||||||
{endmarker}
|
{endmarker}
|
||||||
Execute Tcl script {script}.
|
Execute Tcl script {script}.
|
||||||
@@ -38,10 +38,9 @@ comments, ideas etc to <Ingo.Wilken@informatik.uni-oldenburg.de>
|
|||||||
wasn't compiled in. To avoid errors, see
|
wasn't compiled in. To avoid errors, see
|
||||||
|script-here|.
|
|script-here|.
|
||||||
|
|
||||||
The {endmarker} after {script} must NOT be preceded by any white space.
|
|
||||||
|
|
||||||
If [endmarker] is omitted from after the "<<", a dot '.' must be used after
|
If [endmarker] is omitted from after the "<<", a dot '.' must be used after
|
||||||
{script}, like for the |:append| and |:insert| commands.
|
{script}, like for the |:append| and |:insert| commands. Refer to
|
||||||
|
|:let-heredoc| for more information.
|
||||||
|
|
||||||
This form of the |:tcl| command is mainly useful for including tcl code in Vim
|
This form of the |:tcl| command is mainly useful for including tcl code in Vim
|
||||||
scripts.
|
scripts.
|
||||||
|
@@ -541,10 +541,15 @@ list_script_vars(int *first)
|
|||||||
* The {marker} is a string. If the optional 'trim' word is supplied before the
|
* The {marker} is a string. If the optional 'trim' word is supplied before the
|
||||||
* marker, then the leading indentation before the lines (matching the
|
* marker, then the leading indentation before the lines (matching the
|
||||||
* indentation in the 'cmd' line) is stripped.
|
* indentation in the 'cmd' line) is stripped.
|
||||||
|
*
|
||||||
|
* When getting lines for an embedded script (e.g. python, lua, perl, ruby,
|
||||||
|
* tcl, mzscheme), script_get is set to TRUE. In this case, if the marker is
|
||||||
|
* missing, then '.' is accepted as a marker.
|
||||||
|
*
|
||||||
* Returns a List with {lines} or NULL.
|
* Returns a List with {lines} or NULL.
|
||||||
*/
|
*/
|
||||||
list_T *
|
list_T *
|
||||||
heredoc_get(exarg_T *eap, char_u *cmd)
|
heredoc_get(exarg_T *eap, char_u *cmd, int script_get)
|
||||||
{
|
{
|
||||||
char_u *theline;
|
char_u *theline;
|
||||||
char_u *marker;
|
char_u *marker;
|
||||||
@@ -553,6 +558,7 @@ heredoc_get(exarg_T *eap, char_u *cmd)
|
|||||||
int marker_indent_len = 0;
|
int marker_indent_len = 0;
|
||||||
int text_indent_len = 0;
|
int text_indent_len = 0;
|
||||||
char_u *text_indent = NULL;
|
char_u *text_indent = NULL;
|
||||||
|
char_u dot[] = ".";
|
||||||
|
|
||||||
if (eap->getline == NULL)
|
if (eap->getline == NULL)
|
||||||
{
|
{
|
||||||
@@ -598,8 +604,15 @@ heredoc_get(exarg_T *eap, char_u *cmd)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
emsg(_("E172: Missing marker"));
|
// When getting lines for an embedded script, if the marker is missing,
|
||||||
return NULL;
|
// accept '.' as the marker.
|
||||||
|
if (script_get)
|
||||||
|
marker = dot;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
emsg(_("E172: Missing marker"));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
l = list_alloc();
|
l = list_alloc();
|
||||||
@@ -746,7 +759,7 @@ ex_let_const(exarg_T *eap, int is_const)
|
|||||||
list_T *l;
|
list_T *l;
|
||||||
|
|
||||||
// HERE document
|
// HERE document
|
||||||
l = heredoc_get(eap, expr + 3);
|
l = heredoc_get(eap, expr + 3, FALSE);
|
||||||
if (l != NULL)
|
if (l != NULL)
|
||||||
{
|
{
|
||||||
rettv_list_set(&rettv, l);
|
rettv_list_set(&rettv, l);
|
||||||
|
@@ -4408,44 +4408,37 @@ open_cmdwin(void)
|
|||||||
* Returns a pointer to allocated memory with {script} or NULL.
|
* Returns a pointer to allocated memory with {script} or NULL.
|
||||||
*/
|
*/
|
||||||
char_u *
|
char_u *
|
||||||
script_get(exarg_T *eap, char_u *cmd)
|
script_get(exarg_T *eap UNUSED, char_u *cmd UNUSED)
|
||||||
{
|
{
|
||||||
char_u *theline;
|
#ifdef FEAT_EVAL
|
||||||
char *end_pattern = NULL;
|
list_T *l;
|
||||||
char dot[] = ".";
|
listitem_T *li;
|
||||||
|
char_u *s;
|
||||||
garray_T ga;
|
garray_T ga;
|
||||||
|
|
||||||
if (cmd[0] != '<' || cmd[1] != '<' || eap->getline == NULL)
|
if (cmd[0] != '<' || cmd[1] != '<' || eap->getline == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
cmd += 2;
|
||||||
|
|
||||||
|
l = heredoc_get(eap, cmd, TRUE);
|
||||||
|
if (l == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
ga_init2(&ga, 1, 0x400);
|
ga_init2(&ga, 1, 0x400);
|
||||||
|
|
||||||
if (cmd[2] != NUL)
|
FOR_ALL_LIST_ITEMS(l, li)
|
||||||
end_pattern = (char *)skipwhite(cmd + 2);
|
|
||||||
else
|
|
||||||
end_pattern = dot;
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
{
|
||||||
theline = eap->getline(
|
s = tv_get_string(&li->li_tv);
|
||||||
#ifdef FEAT_EVAL
|
ga_concat(&ga, s);
|
||||||
eap->cstack->cs_looplevel > 0 ? -1 :
|
|
||||||
#endif
|
|
||||||
NUL, eap->cookie, 0, TRUE);
|
|
||||||
|
|
||||||
if (theline == NULL || STRCMP(end_pattern, theline) == 0)
|
|
||||||
{
|
|
||||||
vim_free(theline);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ga_concat(&ga, theline);
|
|
||||||
ga_append(&ga, '\n');
|
ga_append(&ga, '\n');
|
||||||
vim_free(theline);
|
|
||||||
}
|
}
|
||||||
ga_append(&ga, NUL);
|
ga_append(&ga, NUL);
|
||||||
|
|
||||||
|
list_free(l);
|
||||||
return (char_u *)ga.ga_data;
|
return (char_u *)ga.ga_data;
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(FEAT_EVAL) || defined(PROTO)
|
#if defined(FEAT_EVAL) || defined(PROTO)
|
||||||
|
@@ -13,7 +13,7 @@ list_T *eval_spell_expr(char_u *badword, char_u *expr);
|
|||||||
int get_spellword(list_T *list, char_u **pp);
|
int get_spellword(list_T *list, char_u **pp);
|
||||||
void prepare_vimvar(int idx, typval_T *save_tv);
|
void prepare_vimvar(int idx, typval_T *save_tv);
|
||||||
void restore_vimvar(int idx, typval_T *save_tv);
|
void restore_vimvar(int idx, typval_T *save_tv);
|
||||||
list_T *heredoc_get(exarg_T *eap, char_u *cmd);
|
list_T *heredoc_get(exarg_T *eap, char_u *cmd, int script_get);
|
||||||
void ex_let(exarg_T *eap);
|
void ex_let(exarg_T *eap);
|
||||||
void ex_const(exarg_T *eap);
|
void ex_const(exarg_T *eap);
|
||||||
int ex_let_vars(char_u *arg_start, typval_T *tv, int copy, int semicolon, int var_count, int flags, char_u *op);
|
int ex_let_vars(char_u *arg_start, typval_T *tv, int copy, int semicolon, int var_count, int flags, char_u *op);
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -597,14 +597,33 @@ func Test_lua_set_cursor()
|
|||||||
new
|
new
|
||||||
call setline(1, ['first line', 'second line'])
|
call setline(1, ['first line', 'second line'])
|
||||||
normal gg
|
normal gg
|
||||||
lua << EOF
|
lua << trim EOF
|
||||||
w = vim.window()
|
w = vim.window()
|
||||||
w.line = 1
|
w.line = 1
|
||||||
w.col = 5
|
w.col = 5
|
||||||
EOF
|
EOF
|
||||||
call assert_equal([1, 5], [line('.'), col('.')])
|
call assert_equal([1, 5], [line('.'), col('.')])
|
||||||
|
|
||||||
" Check that movement after setting cursor position keeps current column.
|
" Check that movement after setting cursor position keeps current column.
|
||||||
normal j
|
normal j
|
||||||
call assert_equal([2, 5], [line('.'), col('.')])
|
call assert_equal([2, 5], [line('.'), col('.')])
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for various heredoc syntax
|
||||||
|
func Test_lua_heredoc()
|
||||||
|
lua << END
|
||||||
|
vim.command('let s = "A"')
|
||||||
|
END
|
||||||
|
lua <<
|
||||||
|
vim.command('let s ..= "B"')
|
||||||
|
.
|
||||||
|
lua << trim END
|
||||||
|
vim.command('let s ..= "C"')
|
||||||
|
END
|
||||||
|
lua << trim
|
||||||
|
vim.command('let s ..= "D"')
|
||||||
|
.
|
||||||
|
call assert_equal('ABCD', s)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -219,11 +219,11 @@ endfunc
|
|||||||
|
|
||||||
func Test_stdio()
|
func Test_stdio()
|
||||||
redir =>l:out
|
redir =>l:out
|
||||||
perl <<EOF
|
perl << trim EOF
|
||||||
VIM::Msg("&VIM::Msg");
|
VIM::Msg("&VIM::Msg");
|
||||||
print "STDOUT";
|
print "STDOUT";
|
||||||
print STDERR "STDERR";
|
print STDERR "STDERR";
|
||||||
EOF
|
EOF
|
||||||
redir END
|
redir END
|
||||||
call assert_equal(['&VIM::Msg', 'STDOUT', 'STDERR'], split(l:out, "\n"))
|
call assert_equal(['&VIM::Msg', 'STDOUT', 'STDERR'], split(l:out, "\n"))
|
||||||
endfunc
|
endfunc
|
||||||
@@ -290,3 +290,22 @@ func Test_set_cursor()
|
|||||||
normal j
|
normal j
|
||||||
call assert_equal([2, 6], [line('.'), col('.')])
|
call assert_equal([2, 6], [line('.'), col('.')])
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for various heredoc syntax
|
||||||
|
func Test_perl_heredoc()
|
||||||
|
perl << END
|
||||||
|
VIM::DoCommand('let s = "A"')
|
||||||
|
END
|
||||||
|
perl <<
|
||||||
|
VIM::DoCommand('let s ..= "B"')
|
||||||
|
.
|
||||||
|
perl << trim END
|
||||||
|
VIM::DoCommand('let s ..= "C"')
|
||||||
|
END
|
||||||
|
perl << trim
|
||||||
|
VIM::DoCommand('let s ..= "D"')
|
||||||
|
.
|
||||||
|
call assert_equal('ABCD', s)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -167,3 +167,22 @@ func Test_Catch_Exception_Message()
|
|||||||
call assert_match( '^Vim(.*):RuntimeError: TEST$', v:exception )
|
call assert_match( '^Vim(.*):RuntimeError: TEST$', v:exception )
|
||||||
endtry
|
endtry
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for various heredoc syntax
|
||||||
|
func Test_python_heredoc()
|
||||||
|
python << END
|
||||||
|
s='A'
|
||||||
|
END
|
||||||
|
python <<
|
||||||
|
s+='B'
|
||||||
|
.
|
||||||
|
python << trim END
|
||||||
|
s+='C'
|
||||||
|
END
|
||||||
|
python << trim
|
||||||
|
s+='D'
|
||||||
|
.
|
||||||
|
call assert_equal('ABCD', pyxeval('s'))
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -295,9 +295,11 @@ func Test_python3_opt_reset_local_to_global()
|
|||||||
" Set the global and buffer-local option values and then clear the
|
" Set the global and buffer-local option values and then clear the
|
||||||
" buffer-local option value.
|
" buffer-local option value.
|
||||||
for opt in bopts
|
for opt in bopts
|
||||||
py3 pyopt = vim.bindeval("opt")
|
py3 << trim END
|
||||||
py3 vim.options[pyopt[0]] = pyopt[1]
|
pyopt = vim.bindeval("opt")
|
||||||
py3 curbuf.options[pyopt[0]] = pyopt[2]
|
vim.options[pyopt[0]] = pyopt[1]
|
||||||
|
curbuf.options[pyopt[0]] = pyopt[2]
|
||||||
|
END
|
||||||
exe "call assert_equal(opt[2], &" .. opt[0] .. ")"
|
exe "call assert_equal(opt[2], &" .. opt[0] .. ")"
|
||||||
exe "call assert_equal(opt[1], &g:" .. opt[0] .. ")"
|
exe "call assert_equal(opt[1], &g:" .. opt[0] .. ")"
|
||||||
exe "call assert_equal(opt[2], &l:" .. opt[0] .. ")"
|
exe "call assert_equal(opt[2], &l:" .. opt[0] .. ")"
|
||||||
@@ -315,9 +317,11 @@ func Test_python3_opt_reset_local_to_global()
|
|||||||
\ ['sidescrolloff', 6, 12, -1],
|
\ ['sidescrolloff', 6, 12, -1],
|
||||||
\ ['statusline', '%<%f', '%<%F', '']]
|
\ ['statusline', '%<%f', '%<%F', '']]
|
||||||
for opt in wopts
|
for opt in wopts
|
||||||
py3 pyopt = vim.bindeval("opt")
|
py3 << trim
|
||||||
py3 vim.options[pyopt[0]] = pyopt[1]
|
pyopt = vim.bindeval("opt")
|
||||||
py3 curwin.options[pyopt[0]] = pyopt[2]
|
vim.options[pyopt[0]] = pyopt[1]
|
||||||
|
curwin.options[pyopt[0]] = pyopt[2]
|
||||||
|
.
|
||||||
exe "call assert_equal(opt[2], &" .. opt[0] .. ")"
|
exe "call assert_equal(opt[2], &" .. opt[0] .. ")"
|
||||||
exe "call assert_equal(opt[1], &g:" .. opt[0] .. ")"
|
exe "call assert_equal(opt[1], &g:" .. opt[0] .. ")"
|
||||||
exe "call assert_equal(opt[2], &l:" .. opt[0] .. ")"
|
exe "call assert_equal(opt[2], &l:" .. opt[0] .. ")"
|
||||||
@@ -331,4 +335,21 @@ func Test_python3_opt_reset_local_to_global()
|
|||||||
close!
|
close!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for various heredoc syntax
|
||||||
|
func Test_python3_heredoc()
|
||||||
|
python3 << END
|
||||||
|
s='A'
|
||||||
|
END
|
||||||
|
python3 <<
|
||||||
|
s+='B'
|
||||||
|
.
|
||||||
|
python3 << trim END
|
||||||
|
s+='C'
|
||||||
|
END
|
||||||
|
python3 << trim
|
||||||
|
s+='D'
|
||||||
|
.
|
||||||
|
call assert_equal('ABCD', pyxeval('s'))
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -15,10 +15,10 @@ endfunc
|
|||||||
|
|
||||||
func Test_pyx()
|
func Test_pyx()
|
||||||
redir => var
|
redir => var
|
||||||
pyx << EOF
|
pyx << trim EOF
|
||||||
import sys
|
import sys
|
||||||
print(sys.version)
|
print(sys.version)
|
||||||
EOF
|
EOF
|
||||||
redir END
|
redir END
|
||||||
call assert_match(s:py2pattern, split(var)[0])
|
call assert_match(s:py2pattern, split(var)[0])
|
||||||
endfunc
|
endfunc
|
||||||
@@ -79,3 +79,22 @@ func Test_Catch_Exception_Message()
|
|||||||
call assert_match( '^Vim(.*):RuntimeError: TEST$', v:exception )
|
call assert_match( '^Vim(.*):RuntimeError: TEST$', v:exception )
|
||||||
endtry
|
endtry
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for various heredoc syntaxes
|
||||||
|
func Test_pyx2_heredoc()
|
||||||
|
pyx << END
|
||||||
|
result='A'
|
||||||
|
END
|
||||||
|
pyx <<
|
||||||
|
result+='B'
|
||||||
|
.
|
||||||
|
pyx << trim END
|
||||||
|
result+='C'
|
||||||
|
END
|
||||||
|
pyx << trim
|
||||||
|
result+='D'
|
||||||
|
.
|
||||||
|
call assert_equal('ABCD', pyxeval('result'))
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -15,10 +15,10 @@ endfunc
|
|||||||
|
|
||||||
func Test_pyx()
|
func Test_pyx()
|
||||||
redir => var
|
redir => var
|
||||||
pyx << EOF
|
pyx << trim EOF
|
||||||
import sys
|
import sys
|
||||||
print(sys.version)
|
print(sys.version)
|
||||||
EOF
|
EOF
|
||||||
redir END
|
redir END
|
||||||
call assert_match(s:py3pattern, split(var)[0])
|
call assert_match(s:py3pattern, split(var)[0])
|
||||||
endfunc
|
endfunc
|
||||||
@@ -79,3 +79,22 @@ func Test_Catch_Exception_Message()
|
|||||||
call assert_match( '^Vim(.*):RuntimeError: TEST$', v:exception )
|
call assert_match( '^Vim(.*):RuntimeError: TEST$', v:exception )
|
||||||
endtry
|
endtry
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for various heredoc syntaxes
|
||||||
|
func Test_pyx3_heredoc()
|
||||||
|
pyx << END
|
||||||
|
result='A'
|
||||||
|
END
|
||||||
|
pyx <<
|
||||||
|
result+='B'
|
||||||
|
.
|
||||||
|
pyx << trim END
|
||||||
|
result+='C'
|
||||||
|
END
|
||||||
|
pyx << trim
|
||||||
|
result+='D'
|
||||||
|
.
|
||||||
|
call assert_equal('ABCD', pyxeval('result'))
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -332,11 +332,11 @@ func Test_ruby_Vim_evaluate_list()
|
|||||||
call setline(line('$'), ['2 line 2'])
|
call setline(line('$'), ['2 line 2'])
|
||||||
ruby Vim.command("normal /^2\n")
|
ruby Vim.command("normal /^2\n")
|
||||||
let l = ["abc", "def"]
|
let l = ["abc", "def"]
|
||||||
ruby << EOF
|
ruby << trim EOF
|
||||||
curline = $curbuf.line_number
|
curline = $curbuf.line_number
|
||||||
l = Vim.evaluate("l");
|
l = Vim.evaluate("l");
|
||||||
$curbuf.append(curline, l.join("\n"))
|
$curbuf.append(curline, l.join("\n"))
|
||||||
EOF
|
EOF
|
||||||
normal j
|
normal j
|
||||||
.rubydo $_ = $_.gsub(/\n/, '/')
|
.rubydo $_ = $_.gsub(/\n/, '/')
|
||||||
call assert_equal('abc/def', getline('$'))
|
call assert_equal('abc/def', getline('$'))
|
||||||
@@ -394,3 +394,22 @@ func Test_ruby_p()
|
|||||||
let messages = split(execute('message'), "\n")
|
let messages = split(execute('message'), "\n")
|
||||||
call assert_equal(0, len(messages))
|
call assert_equal(0, len(messages))
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for various heredoc syntax
|
||||||
|
func Test_ruby_heredoc()
|
||||||
|
ruby << END
|
||||||
|
Vim.command('let s = "A"')
|
||||||
|
END
|
||||||
|
ruby <<
|
||||||
|
Vim.command('let s ..= "B"')
|
||||||
|
.
|
||||||
|
ruby << trim END
|
||||||
|
Vim.command('let s ..= "C"')
|
||||||
|
END
|
||||||
|
ruby << trim
|
||||||
|
Vim.command('let s ..= "D"')
|
||||||
|
.
|
||||||
|
call assert_equal('ABCD', s)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -67,11 +67,11 @@ func Test_vim_buffer()
|
|||||||
" Test ::vim::buffer list
|
" Test ::vim::buffer list
|
||||||
call assert_equal('2', TclEval('llength [::vim::buffer list]'))
|
call assert_equal('2', TclEval('llength [::vim::buffer list]'))
|
||||||
call assert_equal(b1.' '.b2, TclEval('::vim::buffer list'))
|
call assert_equal(b1.' '.b2, TclEval('::vim::buffer list'))
|
||||||
tcl <<EOF
|
tcl << trim EOF
|
||||||
proc eachbuf { cmd } {
|
proc eachbuf { cmd } {
|
||||||
foreach b [::vim::buffer list] { $b command $cmd }
|
foreach b [::vim::buffer list] { $b command $cmd }
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
tcl eachbuf %s/foo/FOO/g
|
tcl eachbuf %s/foo/FOO/g
|
||||||
b! Xfoo1
|
b! Xfoo1
|
||||||
call assert_equal(['FOObar'], getline(1, '$'))
|
call assert_equal(['FOObar'], getline(1, '$'))
|
||||||
@@ -680,3 +680,22 @@ func Test_set_cursor()
|
|||||||
normal j
|
normal j
|
||||||
call assert_equal([2, 5], [line('.'), col('.')])
|
call assert_equal([2, 5], [line('.'), col('.')])
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for different syntax for ruby heredoc
|
||||||
|
func Test_tcl_heredoc()
|
||||||
|
tcl << END
|
||||||
|
::vim::command {let s = "A"}
|
||||||
|
END
|
||||||
|
tcl <<
|
||||||
|
::vim::command {let s ..= "B"}
|
||||||
|
.
|
||||||
|
tcl << trim END
|
||||||
|
::vim::command {let s ..= "C"}
|
||||||
|
END
|
||||||
|
tcl << trim
|
||||||
|
::vim::command {let s ..= "D"}
|
||||||
|
.
|
||||||
|
call assert_equal('ABCD', s)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -2830,10 +2830,19 @@ ex_function(exarg_T *eap)
|
|||||||
{
|
{
|
||||||
// ":python <<" continues until a dot, like ":append"
|
// ":python <<" continues until a dot, like ":append"
|
||||||
p = skipwhite(arg + 2);
|
p = skipwhite(arg + 2);
|
||||||
|
if (STRNCMP(p, "trim", 4) == 0)
|
||||||
|
{
|
||||||
|
// Ignore leading white space.
|
||||||
|
p = skipwhite(p + 4);
|
||||||
|
heredoc_trimmed = vim_strnsave(theline,
|
||||||
|
(int)(skipwhite(theline) - theline));
|
||||||
|
}
|
||||||
if (*p == NUL)
|
if (*p == NUL)
|
||||||
skip_until = vim_strsave((char_u *)".");
|
skip_until = vim_strsave((char_u *)".");
|
||||||
else
|
else
|
||||||
skip_until = vim_strsave(p);
|
skip_until = vim_strnsave(p, (int)(skiptowhite(p) - p));
|
||||||
|
do_concat = FALSE;
|
||||||
|
is_heredoc = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for ":let v =<< [trim] EOF"
|
// Check for ":let v =<< [trim] EOF"
|
||||||
|
@@ -746,6 +746,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 */
|
||||||
|
/**/
|
||||||
|
578,
|
||||||
/**/
|
/**/
|
||||||
577,
|
577,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -4207,7 +4207,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
|
|||||||
// [let] varname =<< [trim] {end}
|
// [let] varname =<< [trim] {end}
|
||||||
eap->getline = heredoc_getline;
|
eap->getline = heredoc_getline;
|
||||||
eap->cookie = cctx;
|
eap->cookie = cctx;
|
||||||
l = heredoc_get(eap, op + 3);
|
l = heredoc_get(eap, op + 3, FALSE);
|
||||||
|
|
||||||
// Push each line and the create the list.
|
// Push each line and the create the list.
|
||||||
FOR_ALL_LIST_ITEMS(l, li)
|
FOR_ALL_LIST_ITEMS(l, li)
|
||||||
|
Reference in New Issue
Block a user