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)
|
||||||
{
|
{
|
||||||
@@ -597,10 +603,17 @@ heredoc_get(exarg_T *eap, char_u *cmd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
// When getting lines for an embedded script, if the marker is missing,
|
||||||
|
// accept '.' as the marker.
|
||||||
|
if (script_get)
|
||||||
|
marker = dot;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
emsg(_("E172: Missing marker"));
|
emsg(_("E172: Missing marker"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
l = list_alloc();
|
l = list_alloc();
|
||||||
if (l == NULL)
|
if (l == NULL)
|
||||||
@@ -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);
|
||||||
|
@@ -37,7 +37,7 @@ STARTTEST
|
|||||||
:fun d.f()
|
:fun d.f()
|
||||||
: return 1
|
: return 1
|
||||||
:endfun
|
:endfun
|
||||||
py << EOF
|
py << trim EOF
|
||||||
d=vim.bindeval('d')
|
d=vim.bindeval('d')
|
||||||
d['1']='asd'
|
d['1']='asd'
|
||||||
d.update() # Must not do anything, including throwing errors
|
d.update() # Must not do anything, including throwing errors
|
||||||
@@ -208,7 +208,7 @@ EOF
|
|||||||
:let l = [0, 1, 2, 3]
|
:let l = [0, 1, 2, 3]
|
||||||
:py l=vim.bindeval('l')
|
:py l=vim.bindeval('l')
|
||||||
:lockvar! l
|
:lockvar! l
|
||||||
py << EOF
|
py << trim EOF
|
||||||
def emsg(ei):
|
def emsg(ei):
|
||||||
return ei[0].__name__ + ':' + repr(ei[1].args)
|
return ei[0].__name__ + ':' + repr(ei[1].args)
|
||||||
|
|
||||||
@@ -221,7 +221,7 @@ EOF
|
|||||||
:unlockvar! l
|
:unlockvar! l
|
||||||
:"
|
:"
|
||||||
:" Function calls
|
:" Function calls
|
||||||
py << EOF
|
py << trim EOF
|
||||||
import sys
|
import sys
|
||||||
def ee(expr, g=globals(), l=locals()):
|
def ee(expr, g=globals(), l=locals()):
|
||||||
try:
|
try:
|
||||||
@@ -283,7 +283,7 @@ EOF
|
|||||||
:endif
|
:endif
|
||||||
:let messages=[]
|
:let messages=[]
|
||||||
:delfunction DictNew
|
:delfunction DictNew
|
||||||
py <<EOF
|
py << trim EOF
|
||||||
d=vim.bindeval('{}')
|
d=vim.bindeval('{}')
|
||||||
m=vim.bindeval('messages')
|
m=vim.bindeval('messages')
|
||||||
def em(expr, g=globals(), l=locals()):
|
def em(expr, g=globals(), l=locals()):
|
||||||
@@ -367,7 +367,7 @@ EOF
|
|||||||
:" threading
|
:" threading
|
||||||
:let l = [0]
|
:let l = [0]
|
||||||
:py l=vim.bindeval('l')
|
:py l=vim.bindeval('l')
|
||||||
py <<EOF
|
py << trim EOF
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@@ -400,7 +400,7 @@ EOF
|
|||||||
:" settrace
|
:" settrace
|
||||||
:let l = []
|
:let l = []
|
||||||
:py l=vim.bindeval('l')
|
:py l=vim.bindeval('l')
|
||||||
py <<EOF
|
py << trim EOF
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
def traceit(frame, event, arg):
|
def traceit(frame, event, arg):
|
||||||
@@ -497,7 +497,7 @@ EOF
|
|||||||
: put =' W: '.wvals
|
: put =' W: '.wvals
|
||||||
: put =' B: '.wvals
|
: put =' B: '.wvals
|
||||||
:endfun
|
:endfun
|
||||||
py << EOF
|
py << trim EOF
|
||||||
def e(s, g=globals(), l=locals()):
|
def e(s, g=globals(), l=locals()):
|
||||||
try:
|
try:
|
||||||
exec(s, g, l)
|
exec(s, g, l)
|
||||||
@@ -627,7 +627,7 @@ EOF
|
|||||||
: autocmd BufFilePost * python cb.append(vim.eval('expand("<abuf>")') + ':BufFilePost:' + vim.eval('bufnr("%")'))
|
: autocmd BufFilePost * python cb.append(vim.eval('expand("<abuf>")') + ':BufFilePost:' + vim.eval('bufnr("%")'))
|
||||||
: autocmd BufFilePre * python cb.append(vim.eval('expand("<abuf>")') + ':BufFilePre:' + vim.eval('bufnr("%")'))
|
: autocmd BufFilePre * python cb.append(vim.eval('expand("<abuf>")') + ':BufFilePre:' + vim.eval('bufnr("%")'))
|
||||||
:augroup END
|
:augroup END
|
||||||
py << EOF
|
py << trim EOF
|
||||||
# Tests BufferAppend and BufferItem
|
# Tests BufferAppend and BufferItem
|
||||||
cb.append(b[0])
|
cb.append(b[0])
|
||||||
# Tests BufferSlice and BufferAssSlice
|
# Tests BufferSlice and BufferAssSlice
|
||||||
@@ -687,7 +687,7 @@ EOF
|
|||||||
:buffer #
|
:buffer #
|
||||||
:edit c
|
:edit c
|
||||||
:buffer #
|
:buffer #
|
||||||
py << EOF
|
py << trim EOF
|
||||||
try:
|
try:
|
||||||
from __builtin__ import next
|
from __builtin__ import next
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@@ -750,7 +750,7 @@ EOF
|
|||||||
:vnew a.2
|
:vnew a.2
|
||||||
:vnew b.2
|
:vnew b.2
|
||||||
:vnew c.2
|
:vnew c.2
|
||||||
py << EOF
|
py << trim EOF
|
||||||
cb.append('Number of tabs: ' + str(len(vim.tabpages)))
|
cb.append('Number of tabs: ' + str(len(vim.tabpages)))
|
||||||
cb.append('Current tab pages:')
|
cb.append('Current tab pages:')
|
||||||
def W(w):
|
def W(w):
|
||||||
@@ -793,7 +793,7 @@ if list(vim.windows) != list(vim.current.tabpage.windows):
|
|||||||
EOF
|
EOF
|
||||||
:"
|
:"
|
||||||
:" Test vim.current
|
:" Test vim.current
|
||||||
py << EOF
|
py << trim EOF
|
||||||
def H(o):
|
def H(o):
|
||||||
return repr(o)
|
return repr(o)
|
||||||
cb.append('Current tab page: ' + repr(vim.current.tabpage))
|
cb.append('Current tab page: ' + repr(vim.current.tabpage))
|
||||||
@@ -839,7 +839,7 @@ EOF
|
|||||||
:only!
|
:only!
|
||||||
:"
|
:"
|
||||||
:" Test types
|
:" Test types
|
||||||
py << EOF
|
py << trim EOF
|
||||||
for expr, attr in (
|
for expr, attr in (
|
||||||
('vim.vars', 'Dictionary'),
|
('vim.vars', 'Dictionary'),
|
||||||
('vim.options', 'Options'),
|
('vim.options', 'Options'),
|
||||||
@@ -857,7 +857,7 @@ del attr
|
|||||||
EOF
|
EOF
|
||||||
:"
|
:"
|
||||||
:" Test __dir__() method
|
:" Test __dir__() method
|
||||||
py << EOF
|
py << trim EOF
|
||||||
for name, o in (
|
for name, o in (
|
||||||
('current', vim.current),
|
('current', vim.current),
|
||||||
('buffer', vim.current.buffer),
|
('buffer', vim.current.buffer),
|
||||||
@@ -904,7 +904,7 @@ EOF
|
|||||||
:py Pt = vim.bindeval('Pt')
|
:py Pt = vim.bindeval('Pt')
|
||||||
:unlet Pt
|
:unlet Pt
|
||||||
:py del Pt
|
:py del Pt
|
||||||
py << EOF
|
py << trim EOF
|
||||||
def ecall(out_prefix, func, *args, **kwargs):
|
def ecall(out_prefix, func, *args, **kwargs):
|
||||||
line = out_prefix + ': '
|
line = out_prefix + ': '
|
||||||
try:
|
try:
|
||||||
@@ -1029,7 +1029,7 @@ EOF
|
|||||||
:py ecall('psa2(self={"20": 1})', psa2, self={'20': 1})
|
:py ecall('psa2(self={"20": 1})', psa2, self={'20': 1})
|
||||||
:py ecall('psa3(self={"20": 1})', psa3, self={'20': 1})
|
:py ecall('psa3(self={"20": 1})', psa3, self={'20': 1})
|
||||||
:py ecall('psa4(self={"20": 1})', psa4, self={'20': 1})
|
:py ecall('psa4(self={"20": 1})', psa4, self={'20': 1})
|
||||||
py << EOF
|
py << trim EOF
|
||||||
def s(v):
|
def s(v):
|
||||||
if v is None:
|
if v is None:
|
||||||
return repr(v)
|
return repr(v)
|
||||||
@@ -1126,7 +1126,7 @@ EOF
|
|||||||
: $put =string(a:000)
|
: $put =string(a:000)
|
||||||
: return a:000
|
: return a:000
|
||||||
:endfun
|
:endfun
|
||||||
py << EOF
|
py << trim EOF
|
||||||
class DupDict(vim.Dictionary):
|
class DupDict(vim.Dictionary):
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
super(DupDict, self).__setitem__(key, value)
|
super(DupDict, self).__setitem__(key, value)
|
||||||
@@ -1156,7 +1156,7 @@ EOF
|
|||||||
:$put =string(pyeval('dd') is# pyeval('dd'))
|
:$put =string(pyeval('dd') is# pyeval('dd'))
|
||||||
:$put =string(pyeval('df'))
|
:$put =string(pyeval('df'))
|
||||||
:delfunction Put
|
:delfunction Put
|
||||||
py <<
|
py << trim
|
||||||
del DupDict
|
del DupDict
|
||||||
del DupList
|
del DupList
|
||||||
del DupFun
|
del DupFun
|
||||||
@@ -1167,7 +1167,7 @@ del df
|
|||||||
.
|
.
|
||||||
:"
|
:"
|
||||||
:" Test chdir
|
:" Test chdir
|
||||||
py << EOF
|
py << trim EOF
|
||||||
import os
|
import os
|
||||||
fnamemodify = vim.Function('fnamemodify')
|
fnamemodify = vim.Function('fnamemodify')
|
||||||
cb.append(fnamemodify('.', ':p:h:t'))
|
cb.append(fnamemodify('.', ':p:h:t'))
|
||||||
@@ -1197,7 +1197,7 @@ EOF
|
|||||||
:endfun
|
:endfun
|
||||||
:fun D()
|
:fun D()
|
||||||
:endfun
|
:endfun
|
||||||
py << EOF
|
py << trim EOF
|
||||||
d = vim.Dictionary()
|
d = vim.Dictionary()
|
||||||
ned = vim.Dictionary(foo='bar', baz='abcD')
|
ned = vim.Dictionary(foo='bar', baz='abcD')
|
||||||
dl = vim.Dictionary(a=1)
|
dl = vim.Dictionary(a=1)
|
||||||
@@ -1583,7 +1583,7 @@ EOF
|
|||||||
:delfunction F
|
:delfunction F
|
||||||
:"
|
:"
|
||||||
:" Test import
|
:" Test import
|
||||||
py << EOF
|
py << trim EOF
|
||||||
sys.path.insert(0, os.path.join(os.getcwd(), 'python_before'))
|
sys.path.insert(0, os.path.join(os.getcwd(), 'python_before'))
|
||||||
sys.path.append(os.path.join(os.getcwd(), 'python_after'))
|
sys.path.append(os.path.join(os.getcwd(), 'python_after'))
|
||||||
vim.options['rtp'] = os.getcwd().replace(',', '\\,').replace('\\', '\\\\')
|
vim.options['rtp'] = os.getcwd().replace(',', '\\,').replace('\\', '\\\\')
|
||||||
@@ -1623,7 +1623,7 @@ EOF
|
|||||||
:fun Exe(e)
|
:fun Exe(e)
|
||||||
: execute a:e
|
: execute a:e
|
||||||
:endfun
|
:endfun
|
||||||
py << EOF
|
py << trim EOF
|
||||||
Exe = vim.bindeval('function("Exe")')
|
Exe = vim.bindeval('function("Exe")')
|
||||||
ee('vim.command("throw \'abcN\'")')
|
ee('vim.command("throw \'abcN\'")')
|
||||||
ee('Exe("throw \'def\'")')
|
ee('Exe("throw \'def\'")')
|
||||||
@@ -1637,7 +1637,7 @@ EOF
|
|||||||
:delfunction Exe
|
:delfunction Exe
|
||||||
:"
|
:"
|
||||||
:" Regression: interrupting vim.command propagates to next vim.command
|
:" Regression: interrupting vim.command propagates to next vim.command
|
||||||
py << EOF
|
py << trim EOF
|
||||||
def test_keyboard_interrupt():
|
def test_keyboard_interrupt():
|
||||||
try:
|
try:
|
||||||
vim.command('while 1 | endwhile')
|
vim.command('while 1 | endwhile')
|
||||||
@@ -1669,7 +1669,7 @@ EOF
|
|||||||
:py del test_keyboard_interrupt
|
:py del test_keyboard_interrupt
|
||||||
:"
|
:"
|
||||||
:" Cleanup
|
:" Cleanup
|
||||||
py << EOF
|
py << trim EOF
|
||||||
del cb
|
del cb
|
||||||
del ee
|
del ee
|
||||||
del emsg
|
del emsg
|
||||||
|
@@ -31,7 +31,7 @@ STARTTEST
|
|||||||
:fun d.f()
|
:fun d.f()
|
||||||
: return 1
|
: return 1
|
||||||
:endfun
|
:endfun
|
||||||
py3 << EOF
|
py3 << trim EOF
|
||||||
d=vim.bindeval('d')
|
d=vim.bindeval('d')
|
||||||
d['1']='asd'
|
d['1']='asd'
|
||||||
d.update() # Must not do anything, including throwing errors
|
d.update() # Must not do anything, including throwing errors
|
||||||
@@ -201,7 +201,7 @@ EOF
|
|||||||
:let l = [0, 1, 2, 3]
|
:let l = [0, 1, 2, 3]
|
||||||
:py3 l=vim.bindeval('l')
|
:py3 l=vim.bindeval('l')
|
||||||
:lockvar! l
|
:lockvar! l
|
||||||
py3 << EOF
|
py3 << trim EOF
|
||||||
def emsg(ei):
|
def emsg(ei):
|
||||||
return ei[0].__name__ + ':' + repr(ei[1].args)
|
return ei[0].__name__ + ':' + repr(ei[1].args)
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ EOF
|
|||||||
:unlockvar! l
|
:unlockvar! l
|
||||||
:"
|
:"
|
||||||
:" Function calls
|
:" Function calls
|
||||||
py3 << EOF
|
py3 << trim EOF
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@@ -301,7 +301,7 @@ EOF
|
|||||||
:endif
|
:endif
|
||||||
:let messages=[]
|
:let messages=[]
|
||||||
:delfunction DictNew
|
:delfunction DictNew
|
||||||
py3 <<EOF
|
py3 << trim EOF
|
||||||
import sys
|
import sys
|
||||||
d=vim.bindeval('{}')
|
d=vim.bindeval('{}')
|
||||||
m=vim.bindeval('messages')
|
m=vim.bindeval('messages')
|
||||||
@@ -389,7 +389,7 @@ EOF
|
|||||||
:" threading
|
:" threading
|
||||||
:let l = [0]
|
:let l = [0]
|
||||||
:py3 l=vim.bindeval('l')
|
:py3 l=vim.bindeval('l')
|
||||||
py3 <<EOF
|
py3 << trim EOF
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@@ -422,7 +422,7 @@ EOF
|
|||||||
:" settrace
|
:" settrace
|
||||||
:let l = []
|
:let l = []
|
||||||
:py3 l=vim.bindeval('l')
|
:py3 l=vim.bindeval('l')
|
||||||
py3 <<EOF
|
py3 << trim EOF
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
def traceit(frame, event, arg):
|
def traceit(frame, event, arg):
|
||||||
@@ -519,7 +519,7 @@ EOF
|
|||||||
: put =' W: '.wvals
|
: put =' W: '.wvals
|
||||||
: put =' B: '.wvals
|
: put =' B: '.wvals
|
||||||
:endfun
|
:endfun
|
||||||
py3 << EOF
|
py3 << trim EOF
|
||||||
def e(s, g=globals(), l=locals()):
|
def e(s, g=globals(), l=locals()):
|
||||||
try:
|
try:
|
||||||
exec(s, g, l)
|
exec(s, g, l)
|
||||||
@@ -649,7 +649,7 @@ EOF
|
|||||||
: autocmd BufFilePost * python3 cb.append(vim.eval('expand("<abuf>")') + ':BufFilePost:' + vim.eval('bufnr("%")'))
|
: autocmd BufFilePost * python3 cb.append(vim.eval('expand("<abuf>")') + ':BufFilePost:' + vim.eval('bufnr("%")'))
|
||||||
: autocmd BufFilePre * python3 cb.append(vim.eval('expand("<abuf>")') + ':BufFilePre:' + vim.eval('bufnr("%")'))
|
: autocmd BufFilePre * python3 cb.append(vim.eval('expand("<abuf>")') + ':BufFilePre:' + vim.eval('bufnr("%")'))
|
||||||
:augroup END
|
:augroup END
|
||||||
py3 << EOF
|
py3 << trim EOF
|
||||||
# Tests BufferAppend and BufferItem
|
# Tests BufferAppend and BufferItem
|
||||||
cb.append(b[0])
|
cb.append(b[0])
|
||||||
# Tests BufferSlice and BufferAssSlice
|
# Tests BufferSlice and BufferAssSlice
|
||||||
@@ -705,7 +705,7 @@ EOF
|
|||||||
:buffer #
|
:buffer #
|
||||||
:edit c
|
:edit c
|
||||||
:buffer #
|
:buffer #
|
||||||
py3 << EOF
|
py3 << trim EOF
|
||||||
# Check GCing iterator that was not fully exhausted
|
# Check GCing iterator that was not fully exhausted
|
||||||
i = iter(vim.buffers)
|
i = iter(vim.buffers)
|
||||||
cb.append('i:' + str(next(i)))
|
cb.append('i:' + str(next(i)))
|
||||||
@@ -764,7 +764,7 @@ EOF
|
|||||||
:vnew a.2
|
:vnew a.2
|
||||||
:vnew b.2
|
:vnew b.2
|
||||||
:vnew c.2
|
:vnew c.2
|
||||||
py3 << EOF
|
py3 << trim EOF
|
||||||
cb.append('Number of tabs: ' + str(len(vim.tabpages)))
|
cb.append('Number of tabs: ' + str(len(vim.tabpages)))
|
||||||
cb.append('Current tab pages:')
|
cb.append('Current tab pages:')
|
||||||
|
|
||||||
@@ -806,7 +806,7 @@ if list(vim.windows) != list(vim.current.tabpage.windows):
|
|||||||
EOF
|
EOF
|
||||||
:"
|
:"
|
||||||
:" Test vim.current
|
:" Test vim.current
|
||||||
py3 << EOF
|
py3 << trim EOF
|
||||||
def H(o):
|
def H(o):
|
||||||
return repr(o)
|
return repr(o)
|
||||||
cb.append('Current tab page: ' + repr(vim.current.tabpage))
|
cb.append('Current tab page: ' + repr(vim.current.tabpage))
|
||||||
@@ -852,7 +852,7 @@ EOF
|
|||||||
:only!
|
:only!
|
||||||
:"
|
:"
|
||||||
:" Test types
|
:" Test types
|
||||||
py3 << EOF
|
py3 << trim EOF
|
||||||
for expr, attr in (
|
for expr, attr in (
|
||||||
('vim.vars', 'Dictionary'),
|
('vim.vars', 'Dictionary'),
|
||||||
('vim.options', 'Options'),
|
('vim.options', 'Options'),
|
||||||
@@ -870,7 +870,7 @@ del attr
|
|||||||
EOF
|
EOF
|
||||||
:"
|
:"
|
||||||
:" Test __dir__() method
|
:" Test __dir__() method
|
||||||
py3 << EOF
|
py3 << trim EOF
|
||||||
for name, o in (
|
for name, o in (
|
||||||
('current', vim.current),
|
('current', vim.current),
|
||||||
('buffer', vim.current.buffer),
|
('buffer', vim.current.buffer),
|
||||||
@@ -917,7 +917,7 @@ EOF
|
|||||||
:py3 Pt = vim.bindeval('Pt')
|
:py3 Pt = vim.bindeval('Pt')
|
||||||
:unlet Pt
|
:unlet Pt
|
||||||
:py3 del Pt
|
:py3 del Pt
|
||||||
py3 << EOF
|
py3 << trim EOF
|
||||||
def ecall(out_prefix, func, *args, **kwargs):
|
def ecall(out_prefix, func, *args, **kwargs):
|
||||||
line = out_prefix + ': '
|
line = out_prefix + ': '
|
||||||
try:
|
try:
|
||||||
@@ -1042,7 +1042,7 @@ EOF
|
|||||||
:py3 ecall('psa2(self={"20": 1})', psa2, self={'20': 1})
|
:py3 ecall('psa2(self={"20": 1})', psa2, self={'20': 1})
|
||||||
:py3 ecall('psa3(self={"20": 1})', psa3, self={'20': 1})
|
:py3 ecall('psa3(self={"20": 1})', psa3, self={'20': 1})
|
||||||
:py3 ecall('psa4(self={"20": 1})', psa4, self={'20': 1})
|
:py3 ecall('psa4(self={"20": 1})', psa4, self={'20': 1})
|
||||||
py3 << EOF
|
py3 << trim EOF
|
||||||
def s(v):
|
def s(v):
|
||||||
if v is None:
|
if v is None:
|
||||||
return repr(v)
|
return repr(v)
|
||||||
@@ -1139,7 +1139,7 @@ EOF
|
|||||||
: $put =string(a:000)
|
: $put =string(a:000)
|
||||||
: return a:000
|
: return a:000
|
||||||
:endfun
|
:endfun
|
||||||
py3 << EOF
|
py3 << trim EOF
|
||||||
class DupDict(vim.Dictionary):
|
class DupDict(vim.Dictionary):
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
super(DupDict, self).__setitem__(key, value)
|
super(DupDict, self).__setitem__(key, value)
|
||||||
@@ -1169,7 +1169,7 @@ EOF
|
|||||||
:$put =string(py3eval('dd') is# py3eval('dd'))
|
:$put =string(py3eval('dd') is# py3eval('dd'))
|
||||||
:$put =string(py3eval('df'))
|
:$put =string(py3eval('df'))
|
||||||
:delfunction Put
|
:delfunction Put
|
||||||
py3 << EOF
|
py3 << trim EOF
|
||||||
del DupDict
|
del DupDict
|
||||||
del DupList
|
del DupList
|
||||||
del DupFun
|
del DupFun
|
||||||
@@ -1180,7 +1180,7 @@ del df
|
|||||||
EOF
|
EOF
|
||||||
:"
|
:"
|
||||||
:" Test chdir
|
:" Test chdir
|
||||||
py3 << EOF
|
py3 << trim EOF
|
||||||
import os
|
import os
|
||||||
fnamemodify = vim.Function('fnamemodify')
|
fnamemodify = vim.Function('fnamemodify')
|
||||||
cb.append(str(fnamemodify('.', ':p:h:t')))
|
cb.append(str(fnamemodify('.', ':p:h:t')))
|
||||||
@@ -1210,7 +1210,7 @@ EOF
|
|||||||
:endfun
|
:endfun
|
||||||
:fun D()
|
:fun D()
|
||||||
:endfun
|
:endfun
|
||||||
py3 << EOF
|
py3 << trim EOF
|
||||||
d = vim.Dictionary()
|
d = vim.Dictionary()
|
||||||
ned = vim.Dictionary(foo='bar', baz='abcD')
|
ned = vim.Dictionary(foo='bar', baz='abcD')
|
||||||
dl = vim.Dictionary(a=1)
|
dl = vim.Dictionary(a=1)
|
||||||
@@ -1596,7 +1596,7 @@ EOF
|
|||||||
:delfunction F
|
:delfunction F
|
||||||
:"
|
:"
|
||||||
:" Test import
|
:" Test import
|
||||||
py3 << EOF
|
py3 << trim EOF
|
||||||
sys.path.insert(0, os.path.join(os.getcwd(), 'python_before'))
|
sys.path.insert(0, os.path.join(os.getcwd(), 'python_before'))
|
||||||
sys.path.append(os.path.join(os.getcwd(), 'python_after'))
|
sys.path.append(os.path.join(os.getcwd(), 'python_after'))
|
||||||
vim.options['rtp'] = os.getcwd().replace(',', '\\,').replace('\\', '\\\\')
|
vim.options['rtp'] = os.getcwd().replace(',', '\\,').replace('\\', '\\\\')
|
||||||
@@ -1636,7 +1636,7 @@ EOF
|
|||||||
:fun Exe(e)
|
:fun Exe(e)
|
||||||
: execute a:e
|
: execute a:e
|
||||||
:endfun
|
:endfun
|
||||||
py3 << EOF
|
py3 << trim EOF
|
||||||
Exe = vim.bindeval('function("Exe")')
|
Exe = vim.bindeval('function("Exe")')
|
||||||
ee('vim.command("throw \'abcN\'")')
|
ee('vim.command("throw \'abcN\'")')
|
||||||
ee('Exe("throw \'def\'")')
|
ee('Exe("throw \'def\'")')
|
||||||
@@ -1650,7 +1650,7 @@ EOF
|
|||||||
:delfunction Exe
|
:delfunction Exe
|
||||||
:"
|
:"
|
||||||
:" Regression: interrupting vim.command propagates to next vim.command
|
:" Regression: interrupting vim.command propagates to next vim.command
|
||||||
py3 << EOF
|
py3 << trim EOF
|
||||||
def test_keyboard_interrupt():
|
def test_keyboard_interrupt():
|
||||||
try:
|
try:
|
||||||
vim.command('while 1 | endwhile')
|
vim.command('while 1 | endwhile')
|
||||||
@@ -1682,7 +1682,7 @@ EOF
|
|||||||
:py3 del test_keyboard_interrupt
|
:py3 del test_keyboard_interrupt
|
||||||
:"
|
:"
|
||||||
:" Cleanup
|
:" Cleanup
|
||||||
py3 << EOF
|
py3 << trim EOF
|
||||||
del cb
|
del cb
|
||||||
del ee
|
del ee
|
||||||
del emsg
|
del emsg
|
||||||
|
@@ -597,7 +597,7 @@ 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
|
||||||
@@ -608,3 +608,22 @@ EOF
|
|||||||
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,7 +219,7 @@ 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";
|
||||||
@@ -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,7 +15,7 @@ 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
|
||||||
@@ -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,7 +15,7 @@ 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
|
||||||
@@ -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,7 +332,7 @@ 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"))
|
||||||
@@ -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,7 +67,7 @@ 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 }
|
||||||
}
|
}
|
||||||
@@ -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