Compare commits

...

4 Commits

Author SHA1 Message Date
Bram Moolenaar
327d3ee455 patch 8.2.3237: when a builtin function gives an error processing continues
Problem:    When a builtin function gives an error processing continues.
Solution:   In Vim9 script return FAIL in get_func_tv().
2021-07-28 19:34:14 +02:00
zeertzjq
eaf3f36168 patch 8.2.3236: mode() does not indicate using CTRL-O in Select mode
Problem:    mode() does not indicate using CTRL-O in Select mode.
Solution:   Use "vs" and similar. (closes #8640)
2021-07-28 16:51:53 +02:00
Bram Moolenaar
6868634abd patch 8.2.3235: cannot use lambda in {} block in user command
Problem:    Cannot use lambda in {} block in user command. (Martin Tournoij)
Solution:   Do not go over the end of the lambda.
2021-07-28 15:54:54 +02:00
Bram Moolenaar
78e006b9b0 patch 8.2.3234: crash when printing long string with Lua
Problem:    Crash when printing long string with Lua.
Solution:   Remove lua_pop(). (Martin Tournoij, closes #8648)
2021-07-28 15:07:01 +02:00
11 changed files with 77 additions and 5 deletions

View File

@@ -7978,6 +7978,10 @@ mode([expr]) Return a string that indicates the current mode.
s Select by character
S Select by line
CTRL-S Select blockwise
vs Visual by character using |v_CTRL-O| from
Select mode
Vs Visual by line using |v_CTRL-O| from Select mode
CTRL-Vs Visual blockwise using |v_CTRL-O| from Select mode
i Insert
ic Insert mode completion |compl-generic|
ix Insert mode |i_CTRL-X| completion

View File

@@ -882,6 +882,8 @@ EXTERN int VIsual_active INIT(= FALSE);
// whether Visual mode is active
EXTERN int VIsual_select INIT(= FALSE);
// whether Select mode is active
EXTERN int restart_VIsual_select INIT(= 0);
// restart Select mode when next cmd finished
EXTERN int VIsual_reselect;
// whether to restart the selection after a
// Select mode mapping or menu

View File

@@ -1734,9 +1734,9 @@ luaV_print(lua_State *L)
s = lua_tolstring(L, -1, &l);
if (s == NULL)
return luaL_error(L, "cannot convert to string");
if (i > 1) luaL_addchar(&b, ' '); // use space instead of tab
if (i > 1)
luaL_addchar(&b, ' '); // use space instead of tab
luaV_addlstring(&b, s, l, 0);
lua_pop(L, 1);
}
luaL_pushresult(&b);
if (!got_int)

View File

@@ -652,7 +652,11 @@ f_mode(typval_T *argvars, typval_T *rettv)
if (VIsual_select)
buf[0] = VIsual_mode + 's' - 'v';
else
{
buf[0] = VIsual_mode;
if (restart_VIsual_select)
buf[1] = 's';
}
}
else if (State == HITRETURN || State == ASKMORE || State == SETWSIZE
|| State == CONFIRM)

View File

@@ -15,7 +15,6 @@
#include "vim.h"
static int VIsual_mode_orig = NUL; // saved Visual mode
static int restart_VIsual_select = 0;
#ifdef FEAT_EVAL
static void set_vcount_ca(cmdarg_T *cap, int *set_prevcount);

View File

@@ -746,6 +746,7 @@ func Test_mode()
set complete=.
inoremap <F2> <C-R>=Save_mode()<CR>
xnoremap <F2> <Cmd>call Save_mode()<CR>
normal! 3G
exe "normal i\<F2>\<Esc>"
@@ -857,6 +858,14 @@ func Test_mode()
call assert_equal("\<C-S>", mode(1))
call feedkeys("\<Esc>", 'xt')
" v_CTRL-O
exe "normal gh\<C-O>\<F2>\<Esc>"
call assert_equal("v-vs", g:current_modes)
exe "normal gH\<C-O>\<F2>\<Esc>"
call assert_equal("V-Vs", g:current_modes)
exe "normal g\<C-H>\<C-O>\<F2>\<Esc>"
call assert_equal("\<C-V>-\<C-V>s", g:current_modes)
call feedkeys(":echo \<C-R>=Save_mode()\<C-U>\<CR>", 'xt')
call assert_equal('c-c', g:current_modes)
call feedkeys("gQecho \<C-R>=Save_mode()\<CR>\<CR>vi\<CR>", 'xt')
@@ -867,6 +876,7 @@ func Test_mode()
bwipe!
iunmap <F2>
xunmap <F2>
set complete&
endfunc

View File

@@ -850,6 +850,24 @@ func Test_luafile_error()
bwipe!
endfunc
" Test :luafile printing a long string
func Test_luafile_print()
new Xlua_file
let lines =<< trim END
local data = ''
for i = 1, 130 do
data = data .. 'xxxxx asd as as dad sad sad xz cxz czxcxzczxc ad ad asd asd asd asd asd'
end
print(data)
END
call setline(1, lines)
w
luafile %
call delete('Xlua_file')
bwipe!
endfunc
" Test for dealing with strings containing newlines and null character
func Test_lua_string_with_newline()
let x = execute('lua print("Hello\nWorld")')

View File

@@ -632,6 +632,13 @@ func Test_usercmd_with_block()
call assert_equal('more', g:didmore)
unlet g:didit
unlet g:didmore
delcommand DoSomething
command DoMap {
echo [1, 2, 3]->map((_, v) => v + 1)
}
DoMap
delcommand DoMap
let lines =<< trim END
command DoesNotEnd {

View File

@@ -2002,5 +2002,20 @@ def Test_inc_dec()
CheckDefAndScriptFailure(lines, "E1202: No white space allowed after '++': ++ nr")
enddef
def Test_abort_after_error()
# should abort after strpart() fails, not give another type error
var lines =<< trim END
vim9script
var x: string
x = strpart(1, 2)
END
writefile(lines, 'Xtestscript')
var expected = 'E1174: String required for argument 1'
assert_fails('so Xtestscript', [expected, expected], 3)
delete('Xtestscript')
enddef
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker

View File

@@ -1398,7 +1398,7 @@ get_lambda_tv(
// If there are line breaks, we need to split up the string.
line_end = vim_strchr(start, '\n');
if (line_end == NULL)
if (line_end == NULL || line_end > end)
line_end = end;
// Add "return " before the expression (or the first line).
@@ -1674,7 +1674,8 @@ get_func_tv(
if (ret == OK)
{
int i = 0;
int i = 0;
int did_emsg_before = did_emsg;
if (get_vim_var_nr(VV_TESTING))
{
@@ -1689,6 +1690,10 @@ get_func_tv(
}
ret = call_func(name, len, rettv, argcount, argvars, funcexe);
if (in_vim9script() && did_emsg > did_emsg_before)
// An error in a builtin function does not return FAIL, but we do
// want to abort further processing if an error was given.
ret = FAIL;
funcargs.ga_len -= i;
}

View File

@@ -755,6 +755,14 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3237,
/**/
3236,
/**/
3235,
/**/
3234,
/**/
3233,
/**/