Compare commits

..

10 Commits

Author SHA1 Message Date
Bram Moolenaar
447bfba24b patch 8.2.1237: changing 'completepopup' after opening popup has no effect
Problem:    Changing 'completepopup' after opening a popup has no effect. (Jay
            Sitter)
Solution:   Close the popup when the options are changed. (closes #6471)
2020-07-18 16:07:16 +02:00
Bram Moolenaar
e859312e74 patch 8.2.1236: Vim9: a few errors not caught by try/catch
Problem:    Vim9: a few errors not caught by try/catch.
Solution:   Do not bail out if an error is inside try/catch.  Fix that a not
            matching catch doesn't jump to :endtry.
2020-07-18 15:17:02 +02:00
Bram Moolenaar
2764d06ab7 patch 8.2.1235: Not all mouse codes covered by tests
Problem:    Not all mouse codes covered by tests.
Solution:   Add more tests for the mouse. (Yegappan Lakshmanan, closes #6472)
2020-07-18 12:59:19 +02:00
Bram Moolenaar
066e7da3cd patch 8.2.1234: Lua build problem with old compiler
Problem:    Lua build problem with old compiler.
Solution:   Move declarations to start of the block. (Taro Muraoka,
            closes #6477)
2020-07-18 12:50:35 +02:00
Bram Moolenaar
f0b9f43c31 patch 8.2.1233: Vim9: various errors not caught by try/catch
Problem:    Vim9: various errors not caught by try/catch.
Solution:   Do not bail out if an error is inside try/catch.
2020-07-17 23:03:17 +02:00
Bram Moolenaar
b68ced5f07 patch 8.2.1232: MS-Windows GUI: Snap cancelled by split command
Problem:    MS-Windows GUI: Snap cancelled by split command.
Solution:   Do not cancel Snap when splitting a window. (Ken Takata,
            closes #6467)
2020-07-17 22:26:53 +02:00
Bram Moolenaar
945c857844 patch 8.2.1231: MS-Windows: GUI code can be cleaned up
Problem:    MS-Windows: GUI code can be cleaned up.
Solution:   Do a bit of cleaning up. (Ken Takata, closes #6465)
2020-07-17 22:17:03 +02:00
Bram Moolenaar
68d130c618 patch 8.2.1230: Vim9: list index error not caught by try/catch
Problem:    Vim9: list index error not caught by try/catch.
Solution:   Do not bail out if an error is inside try/catch. (closes #6462)
2020-07-17 22:06:44 +02:00
Bram Moolenaar
6e36b1c18e patch 8.2.1229: build error without the eval feature
Problem:    Build error without the eval feature.
Solution:   Declare starts_with_colon. Make function local.
2020-07-17 20:47:51 +02:00
Bram Moolenaar
203ec7760d patch 8.2.1228: scrollbars not flush against the window edges when maximised
Problem:    Scrollbars not flush against the window edges when maximised.
Solution:   Add padding. (Ken Takata, closes #5602, closes #6466)
2020-07-17 20:43:43 +02:00
30 changed files with 715 additions and 79 deletions

View File

@@ -1951,9 +1951,11 @@ A jump table for the options with a short description can be found at |Q_op|.
{not available when compiled without the |+textprop|
or |+quickfix| feature}
When 'completeopt' contains "popup" then this option is used for the
properties of the info popup when it is created. You can also use
|popup_findinfo()| and then set properties for an existing info popup
with |popup_setoptions()|. See |complete-popup|.
properties of the info popup when it is created. If an info popup
window already exists it is closed, so that the option value is
applied when it is created again.
You can also use |popup_findinfo()| and then set properties for an
existing info popup with |popup_setoptions()|. See |complete-popup|.
*'concealcursor'* *'cocu'*

View File

@@ -1649,7 +1649,7 @@ current_tab_nr(tabpage_T *tab)
return nr;
}
int
static int
comment_start(char_u *p, int starts_with_colon UNUSED)
{
#ifdef FEAT_EVAL
@@ -1708,8 +1708,8 @@ do_one_cmd(
int save_reg_executing = reg_executing;
int ni; // set when Not Implemented
char_u *cmd;
int starts_with_colon = FALSE;
#ifdef FEAT_EVAL
int starts_with_colon;
int starts_with_quote;
int vim9script = in_vim9script();
#endif

View File

@@ -1418,11 +1418,13 @@ gui_position_components(int total_width UNUSED)
if (gui.which_scrollbars[SBAR_BOTTOM])
gui_mch_set_scrollbar_pos(&gui.bottom_sbar,
text_area_x,
text_area_y + text_area_height,
text_area_y + text_area_height
+ gui_mch_get_scrollbar_ypadding(),
text_area_width,
gui.scrollbar_height);
gui.left_sbar_x = 0;
gui.right_sbar_x = text_area_x + text_area_width;
gui.right_sbar_x = text_area_x + text_area_width
+ gui_mch_get_scrollbar_xpadding();
--hold_gui_events;
}

View File

@@ -1889,6 +1889,22 @@ gui_mch_set_scrollbar_pos(
XtManageChild(sb->id);
}
int
gui_mch_get_scrollbar_xpadding(void)
{
// TODO: Calculate the padding for adjust scrollbar position when the
// Window is maximized.
return 0;
}
int
gui_mch_get_scrollbar_ypadding(void)
{
// TODO: Calculate the padding for adjust scrollbar position when the
// Window is maximized.
return 0;
}
void
gui_mch_enable_scrollbar(scrollbar_T *sb, int flag)
{

View File

@@ -1008,6 +1008,22 @@ gui_mch_set_scrollbar_pos(scrollbar_T *sb, int x, int y, int w, int h)
gtk_form_move_resize(GTK_FORM(gui.formwin), sb->id, x, y, w, h);
}
int
gui_mch_get_scrollbar_xpadding(void)
{
// TODO: Calculate the padding for adjust scrollbar position when the
// Window is maximized.
return 0;
}
int
gui_mch_get_scrollbar_ypadding(void)
{
// TODO: Calculate the padding for adjust scrollbar position when the
// Window is maximized.
return 0;
}
/*
* Take action upon scrollbar dragging.
*/

View File

@@ -3665,6 +3665,22 @@ gui_mch_set_scrollbar_pos(
}
}
int
gui_mch_get_scrollbar_xpadding(void)
{
// TODO: Calculate the padding for adjust scrollbar position when the
// Window is maximized.
return 0;
}
int
gui_mch_get_scrollbar_ypadding(void)
{
// TODO: Calculate the padding for adjust scrollbar position when the
// Window is maximized.
return 0;
}
void
gui_mch_create_scrollbar(
scrollbar_T *sb,

View File

@@ -4992,6 +4992,22 @@ gui_mch_set_scrollbar_pos(
#endif
}
int
gui_mch_get_scrollbar_xpadding(void)
{
// TODO: Calculate the padding for adjust scrollbar position when the
// Window is maximized.
return 0;
}
int
gui_mch_get_scrollbar_ypadding(void)
{
// TODO: Calculate the padding for adjust scrollbar position when the
// Window is maximized.
return 0;
}
void
gui_mch_create_scrollbar(
scrollbar_T *sb,

View File

@@ -1743,6 +1743,22 @@ gui_mch_set_scrollbar_pos(
}
}
int
gui_mch_get_scrollbar_xpadding(void)
{
// TODO: Calculate the padding for adjust scrollbar position when the
// Window is maximized.
return 0;
}
int
gui_mch_get_scrollbar_ypadding(void)
{
// TODO: Calculate the padding for adjust scrollbar position when the
// Window is maximized.
return 0;
}
void
gui_mch_enable_scrollbar(scrollbar_T *sb, int flag)
{

View File

@@ -1758,6 +1758,22 @@ gui_mch_set_scrollbar_pos(scrollbar_T *sb, int x, int y, int w, int h)
PtSetResource(sb->id, Pt_ARG_AREA, &area, 0);
}
int
gui_mch_get_scrollbar_xpadding(void)
{
// TODO: Calculate the padding for adjust scrollbar position when the
// Window is maximized.
return 0;
}
int
gui_mch_get_scrollbar_ypadding(void)
{
// TODO: Calculate the padding for adjust scrollbar position when the
// Window is maximized.
return 0;
}
void
gui_mch_create_scrollbar(scrollbar_T *sb, int orient)
{

View File

@@ -240,6 +240,7 @@ gui_mch_set_rendering_options(char_u *s)
# define CONST
# define FAR
# define NEAR
# define WINAPI
# undef _cdecl
# define _cdecl
typedef int BOOL;
@@ -320,9 +321,6 @@ static int s_findrep_is_find; // TRUE for find dialog, FALSE
// for find/replace dialog
#endif
#if !defined(FEAT_GUI)
static
#endif
HWND s_hwnd = NULL;
static HDC s_hdc = NULL;
static HBRUSH s_brush = NULL;
@@ -389,7 +387,7 @@ directx_binddc(void)
#endif
// use of WindowProc depends on Global IME
#define MyWindowProc vim_WindowProc
static LRESULT WINAPI MyWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
extern int current_font_height; // this is in os_mswin.c
@@ -1259,12 +1257,8 @@ _TextAreaWndProc(
}
}
#ifdef PROTO
typedef int WINAPI;
#endif
LRESULT WINAPI
vim_WindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
static LRESULT WINAPI
MyWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
#ifdef GLOBAL_IME
return global_ime_DefWindowProc(hwnd, message, wParam, lParam);
@@ -1412,6 +1406,34 @@ gui_mch_set_scrollbar_pos(
SWP_NOZORDER | SWP_NOACTIVATE | SWP_SHOWWINDOW);
}
int
gui_mch_get_scrollbar_xpadding(void)
{
RECT rcTxt, rcWnd;
int xpad;
GetWindowRect(s_textArea, &rcTxt);
GetWindowRect(s_hwnd, &rcWnd);
xpad = rcWnd.right - rcTxt.right - gui.scrollbar_width
- GetSystemMetrics(SM_CXFRAME)
- GetSystemMetrics(SM_CXPADDEDBORDER);
return (xpad < 0) ? 0 : xpad;
}
int
gui_mch_get_scrollbar_ypadding(void)
{
RECT rcTxt, rcWnd;
int ypad;
GetWindowRect(s_textArea, &rcTxt);
GetWindowRect(s_hwnd, &rcWnd);
ypad = rcWnd.bottom - rcTxt.bottom - gui.scrollbar_height
- GetSystemMetrics(SM_CYFRAME)
- GetSystemMetrics(SM_CXPADDEDBORDER);
return (ypad < 0) ? 0 : ypad;
}
void
gui_mch_create_scrollbar(
scrollbar_T *sb,
@@ -3320,19 +3342,33 @@ gui_mch_init_font(char_u *font_name, int fontset UNUSED)
/*
* Return TRUE if the GUI window is maximized, filling the whole screen.
* Also return TRUE if the window is snapped.
*/
int
gui_mch_maximized(void)
{
WINDOWPLACEMENT wp;
RECT rc;
wp.length = sizeof(WINDOWPLACEMENT);
if (GetWindowPlacement(s_hwnd, &wp))
return wp.showCmd == SW_SHOWMAXIMIZED
{
if (wp.showCmd == SW_SHOWMAXIMIZED
|| (wp.showCmd == SW_SHOWMINIMIZED
&& wp.flags == WPF_RESTORETOMAXIMIZED);
&& wp.flags == WPF_RESTORETOMAXIMIZED))
return TRUE;
if (wp.showCmd == SW_SHOWMINIMIZED)
return FALSE;
return 0;
// Assume the window is snapped when the sizes from two APIs differ.
GetWindowRect(s_hwnd, &rc);
if ((rc.right - rc.left !=
wp.rcNormalPosition.right - wp.rcNormalPosition.left)
|| (rc.bottom - rc.top !=
wp.rcNormalPosition.bottom - wp.rcNormalPosition.top))
return TRUE;
}
return FALSE;
}
/*
@@ -3796,10 +3832,6 @@ _OnScroll(
# include "xpm_w32.h"
#endif
#ifdef PROTO
# define WINAPI
#endif
#ifdef __MINGW32__
/*
* Add a lot of missing defines.

View File

@@ -626,8 +626,10 @@ luaV_totypval(lua_State *L, int pos, typval_T *tv)
case LUA_TFUNCTION:
{
char_u *name;
luaV_CFuncState *state;
lua_pushvalue(L, pos);
luaV_CFuncState *state = ALLOC_CLEAR_ONE(luaV_CFuncState);
state = ALLOC_CLEAR_ONE(luaV_CFuncState);
state->lua_funcref = luaL_ref(L, LUA_REGISTRYINDEX);
state->L = L;
state->lua_tableref = LUA_NOREF;
@@ -639,14 +641,17 @@ luaV_totypval(lua_State *L, int pos, typval_T *tv)
}
case LUA_TTABLE:
{
int lua_tableref;
lua_pushvalue(L, pos);
int lua_tableref = luaL_ref(L, LUA_REGISTRYINDEX);
lua_tableref = luaL_ref(L, LUA_REGISTRYINDEX);
if (lua_getmetatable(L, pos)) {
lua_getfield(L, -1, LUA___CALL);
if (lua_isfunction(L, -1)) {
char_u *name;
int lua_funcref = luaL_ref(L, LUA_REGISTRYINDEX);
luaV_CFuncState *state = ALLOC_CLEAR_ONE(luaV_CFuncState);
state->lua_funcref = lua_funcref;
state->L = L;
state->lua_tableref = lua_tableref;
@@ -703,6 +708,7 @@ luaV_totypval(lua_State *L, int pos, typval_T *tv)
if (lua_rawequal(L, -1, -5))
{
luaV_Funcref *f = (luaV_Funcref *) p;
func_ref(f->name);
tv->v_type = VAR_FUNC;
tv->vval.v_string = vim_strsave(f->name);

View File

@@ -2249,6 +2249,8 @@ did_set_string_option(
{
if (parse_completepopup(NULL) == FAIL)
errmsg = e_invarg;
else
popup_close_info();
}
# endif
#endif

View File

@@ -4031,6 +4031,18 @@ popup_hide_info(void)
if (wp != NULL)
popup_hide(wp);
}
/*
* Close any info popup.
*/
void
popup_close_info(void)
{
win_T *wp = popup_find_info_window();
if (wp != NULL)
popup_close_with_retval(wp, -1);
}
#endif
/*

View File

@@ -5,7 +5,6 @@ int do_cmdline(char_u *cmdline, char_u *(*fgetline)(int, void *, int, int), void
int getline_equal(char_u *(*fgetline)(int, void *, int, int), void *cookie, char_u *(*func)(int, void *, int, int));
void *getline_cookie(char_u *(*fgetline)(int, void *, int, int), void *cookie);
char_u *getline_peek(char_u *(*fgetline)(int, void *, int, int), void *cookie);
int comment_start(char_u *p, int starts_with_colon);
int parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only);
void undo_cmdmod(exarg_T *eap, int save_msg_scroll);
int parse_cmd_address(exarg_T *eap, char **errormsg, int silent);

View File

@@ -21,6 +21,8 @@ void gui_mch_show_popupmenu(vimmenu_T *menu);
void gui_mch_def_colors(void);
void gui_mch_set_scrollbar_thumb(scrollbar_T *sb, long val, long size, long max);
void gui_mch_set_scrollbar_pos(scrollbar_T *sb, int x, int y, int w, int h);
int gui_mch_get_scrollbar_xpadding(void);
int gui_mch_get_scrollbar_ypadding(void);
void gui_mch_enable_scrollbar(scrollbar_T *sb, int flag);
void gui_mch_create_scrollbar(scrollbar_T *sb, int orient);
void gui_mch_destroy_scrollbar(scrollbar_T *sb);

View File

@@ -9,6 +9,8 @@ void gui_mch_menu_set_tip(vimmenu_T *menu);
void gui_mch_destroy_menu(vimmenu_T *menu);
void gui_mch_set_scrollbar_thumb(scrollbar_T *sb, long val, long size, long max);
void gui_mch_set_scrollbar_pos(scrollbar_T *sb, int x, int y, int w, int h);
int gui_mch_get_scrollbar_xpadding(void);
int gui_mch_get_scrollbar_ypadding(void);
void gui_mch_create_scrollbar(scrollbar_T *sb, int orient);
void gui_mch_destroy_scrollbar(scrollbar_T *sb);
char_u *gui_mch_browse(int saving, char_u *title, char_u *dflt, char_u *ext, char_u *initdir, char_u *filter);

View File

@@ -33,6 +33,8 @@ void gui_mch_enable_scrollbar(scrollbar_T *sb, int flag);
void gui_mch_set_scrollbar_thumb(scrollbar_T *sb, int val, int size, int max);
void gui_mch_set_scrollbar_pos(scrollbar_T *sb, int x, int y, int w, int h);
int gui_mch_get_scrollbar_xpadding(void);
int gui_mch_get_scrollbar_ypadding(void);
void gui_mch_create_scrollbar(scrollbar_T *sb, int orient);
void gui_mch_destroy_scrollbar(scrollbar_T *sb);

View File

@@ -36,6 +36,8 @@ void gui_mch_set_text_area_pos(int x, int y, int w, int h);
void gui_mch_enable_scrollbar(scrollbar_T *sb, int flag);
void gui_mch_set_scrollbar_thumb(scrollbar_T *sb, long val, long size, long max);
void gui_mch_set_scrollbar_pos(scrollbar_T *sb, int x, int y, int w, int h);
int gui_mch_get_scrollbar_xpadding(void);
int gui_mch_get_scrollbar_ypadding(void);
void gui_mch_create_scrollbar(scrollbar_T *sb, int orient);
void gui_mch_destroy_scrollbar(scrollbar_T *sb);
int gui_mch_adjust_charheight(void);

View File

@@ -23,6 +23,8 @@ void gui_mch_show_popupmenu(vimmenu_T *menu);
void gui_mch_def_colors(void);
void gui_mch_set_scrollbar_thumb(scrollbar_T *sb, long val, long size, long max);
void gui_mch_set_scrollbar_pos(scrollbar_T *sb, int x, int y, int w, int h);
int gui_mch_get_scrollbar_xpadding(void);
int gui_mch_get_scrollbar_ypadding(void);
void gui_mch_enable_scrollbar(scrollbar_T *sb, int flag);
void gui_mch_create_scrollbar(scrollbar_T *sb, int orient);
void gui_mch_destroy_scrollbar(scrollbar_T *sb);

View File

@@ -18,6 +18,8 @@ void gui_mch_set_foreground(void);
void gui_mch_settitle(char_u *title, char_u *icon);
void gui_mch_set_scrollbar_thumb(scrollbar_T *sb, int val, int size, int max);
void gui_mch_set_scrollbar_pos(scrollbar_T *sb, int x, int y, int w, int h);
int gui_mch_get_scrollbar_xpadding(void);
int gui_mch_get_scrollbar_ypadding(void);
void gui_mch_create_scrollbar(scrollbar_T *sb, int orient);
void gui_mch_enable_scrollbar(scrollbar_T *sb, int flag);
void gui_mch_destroy_scrollbar(scrollbar_T *sb);

View File

@@ -5,7 +5,6 @@ int gui_mch_is_blink_off(void);
void gui_mch_set_blinking(long wait, long on, long off);
void gui_mch_stop_blink(int may_call_gui_update_cursor);
void gui_mch_start_blink(void);
LRESULT WINAPI vim_WindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
void gui_mch_new_colors(void);
void gui_mch_def_colors(void);
int gui_mch_open(void);
@@ -14,6 +13,8 @@ void gui_mch_set_winpos(int x, int y);
void gui_mch_set_text_area_pos(int x, int y, int w, int h);
void gui_mch_enable_scrollbar(scrollbar_T *sb, int flag);
void gui_mch_set_scrollbar_pos(scrollbar_T *sb, int x, int y, int w, int h);
int gui_mch_get_scrollbar_xpadding(void);
int gui_mch_get_scrollbar_ypadding(void);
void gui_mch_create_scrollbar(scrollbar_T *sb, int orient);
int gui_mch_adjust_charheight(void);
GuiFont gui_mch_get_font(char_u *name, int giveErrorIfMissing);

View File

@@ -60,6 +60,7 @@ void f_popup_findpreview(typval_T *argvars, typval_T *rettv);
int popup_create_preview_window(int info);
void popup_close_preview(void);
void popup_hide_info(void);
void popup_close_info(void);
int popup_win_closed(win_T *win);
void popup_set_title(win_T *wp);
void popup_update_preview_title(void);

View File

@@ -0,0 +1,14 @@
|a+0&#ffffff0|w|o|r|d| @69
|t|e|s|t| |t|a|w|o|r|d> @63
|~+0#4040ff13&| @3| +0#0000001#e0e0e08|w|r|d| @4|W| |e|x|t|r|a| |t|e|x|t| @1| +0#0000000#0000001| +0#0000001#e0e0e08|w|o|r|d|s| |a|r|e| |c|o@1|l| | +0#4040ff13#ffffff0@29
|~| @3| +0#0000001#ffd7ff255|a|n|o|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| @1| +0#0000000#0000001| +0#4040ff13#ffffff0@45
|~| @3| +0#0000001#ffd7ff255|n|o|a|w|r|d| @1|W| |e|x|t|r|a| |t|e|x|t| @1| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@45
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
|-+2#0000000&@1| |U|s|e|r| |d|e|f|i|n|e|d| |c|o|m|p|l|e|t|i|o|n| |(|^|U|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |1| |o|f| |4| +0#0000000&@26

View File

@@ -103,6 +103,24 @@ func MouseCtrlRightClick(row, col)
call feedkeys(MouseCtrlRightClickCode(a:row, a:col), 'Lx!')
endfunc
func MouseAltLeftClickCode(row, col)
let alt = 0x8
return TerminalEscapeCode(0 + alt, a:row, a:col, 'M')
endfunc
func MouseAltLeftClick(row, col)
call feedkeys(MouseAltLeftClickCode(a:row, a:col), 'Lx!')
endfunc
func MouseAltRightClickCode(row, col)
let alt = 0x8
return TerminalEscapeCode(2 + alt, a:row, a:col, 'M')
endfunc
func MouseAltRightClick(row, col)
call feedkeys(MouseAltRightClickCode(a:row, a:col), 'Lx!')
endfunc
func MouseLeftReleaseCode(row, col)
if &ttymouse ==# 'dec'
return DecEscapeCode(3, 0, a:row, a:col)

View File

@@ -3109,6 +3109,12 @@ func Test_popupmenu_info_border()
call term_sendkeys(buf, "otest text test text\<C-X>\<C-U>")
call VerifyScreenDump(buf, 'Test_popupwin_infopopup_7', {})
" Test that when the option is changed the popup changes.
call term_sendkeys(buf, "\<Esc>")
call term_sendkeys(buf, ":set completepopup=border:off\<CR>")
call term_sendkeys(buf, "a\<C-X>\<C-U>")
call VerifyScreenDump(buf, 'Test_popupwin_infopopup_8', {})
call term_sendkeys(buf, "\<Esc>")
call StopVimInTerminal(buf)
call delete('XtestInfoPopup')

View File

@@ -147,13 +147,13 @@ func Test_xterm_mouse_tagjump()
new
let str = 'iHello' .. MouseCtrlRightClickCode(row, col)
\ .. MouseRightReleaseCode(row, col) .. "\<C-C>"
call assert_fails('call feedkeys(str, "Lx!")', 'E37:')
call assert_fails('call feedkeys(str, "Lx!")', 'E37:', msg)
close!
" CTRL-right click with a count
let str = "4" .. MouseCtrlRightClickCode(row, col)
\ .. MouseRightReleaseCode(row, col)
call assert_fails('call feedkeys(str, "Lx!")', 'E555:')
call assert_fails('call feedkeys(str, "Lx!")', 'E555:', msg)
call assert_match('help.txt$', bufname('%'), msg)
call assert_equal(1, line('.'), msg)
@@ -230,7 +230,7 @@ func Test_term_mouse_middle_click()
\ MouseMiddleClickCode(2, 7) .. MouseMiddleReleaseCode(2, 7), 'Lx!')
call assert_equal(['12345abc6789abc', '12abc3abc456789'],
\ getline(1, '$'), msg)
call assert_equal('1234', @")
call assert_equal('1234', @", msg)
let &clipboard = save_clipboard
" Clicking middle mouse in select mode, replaces the selected text with
@@ -240,6 +240,18 @@ func Test_term_mouse_middle_click()
exe "normal gh\<Right>\<Right>\<MiddleMouse>"
call assert_equal(['12xyzabc6789abc', '12abc3abc456789'],
\ getline(1, '$'), msg)
" Prefixing middle click with [ or ] fixes the indent after pasting.
%d
call setline(1, " one two")
call setreg('r', 'red blue', 'l')
call test_setmouse(1, 5)
exe "normal \"r[\<MiddleMouse>"
call assert_equal(' red blue', getline(1), msg)
call test_setmouse(2, 5)
exe "normal \"r]\<MiddleMouse>"
call assert_equal(' red blue', getline(3), msg)
%d
endfor
let &mouse = save_mouse
@@ -309,7 +321,7 @@ func Test_term_mouse_middle_click_insert_mode()
\ "\<C-C>", 'Lx!')
call assert_equal(['123abc456789', '123456789'],
\ getline(1, '$'), msg)
call assert_equal([1, 6], [line('.'), col('.')])
call assert_equal([1, 6], [line('.'), col('.')], msg)
" Middle-click in replace mode
call cursor(1, 1)
@@ -318,7 +330,7 @@ func Test_term_mouse_middle_click_insert_mode()
\ "\<C-C>", 'Lx!')
call assert_equal(['123abc45678abc', '123456789'],
\ getline(1, '$'), msg)
call assert_equal([1, 14], [line('.'), col('.')])
call assert_equal([1, 14], [line('.'), col('.')], msg)
endfor
let &mouse = save_mouse
@@ -899,6 +911,53 @@ func Test_term_mouse_multiple_clicks_to_visually_select()
call assert_equal("\<c-v>", mode(), msg)
norm! r4
call assert_equal(['34333333333333333', 'foo'], getline(1, '$'), msg)
" Double-click on a space character should visually select all the
" consecutive space characters.
%d
call setline(1, ' one two')
call MouseLeftClick(1, 2)
call MouseLeftRelease(1, 2)
call MouseLeftClick(1, 2)
call MouseLeftRelease(1, 2)
call assert_equal('v', mode(), msg)
norm! r1
call assert_equal(['1111one two'], getline(1, '$'), msg)
" Double-click on a word with exclusive selection
set selection=exclusive
let @" = ''
call MouseLeftClick(1, 10)
call MouseLeftRelease(1, 10)
call MouseLeftClick(1, 10)
call MouseLeftRelease(1, 10)
norm! y
call assert_equal('two', @", msg)
" Double click to select a block of text with exclusive selection
%d
call setline(1, 'one (two) three')
call MouseLeftClick(1, 5)
call MouseLeftRelease(1, 5)
call MouseLeftClick(1, 5)
call MouseLeftRelease(1, 5)
norm! y
call assert_equal(5, col("'<"), msg)
call assert_equal(10, col("'>"), msg)
call MouseLeftClick(1, 9)
call MouseLeftRelease(1, 9)
call MouseLeftClick(1, 9)
call MouseLeftRelease(1, 9)
norm! y
call assert_equal(5, col("'<"), msg)
call assert_equal(10, col("'>"), msg)
set selection&
" Click somewhere else so that the clicks above is not combined with the
" clicks in the next iteration.
call MouseRightClick(3, 10)
call MouseRightRelease(3, 10)
endfor
let &mouse = save_mouse
@@ -909,6 +968,41 @@ func Test_term_mouse_multiple_clicks_to_visually_select()
bwipe!
endfunc
" Test for selecting text in visual blockwise mode using Alt-LeftClick
func Test_mouse_alt_leftclick()
let save_mouse = &mouse
let save_term = &term
let save_ttymouse = &ttymouse
call test_override('no_query_mouse', 1)
set mouse=a term=xterm mousetime=200
set mousemodel=popup
new
call setline(1, 'one (two) three')
for ttymouse_val in g:Ttymouse_values
let msg = 'ttymouse=' .. ttymouse_val
exe 'set ttymouse=' .. ttymouse_val
" Left click with the Alt modifier key should extend the selection in
" blockwise visual mode.
let @" = ''
call MouseLeftClick(1, 3)
call MouseLeftRelease(1, 3)
call MouseAltLeftClick(1, 11)
call MouseLeftRelease(1, 11)
call assert_equal("\<C-V>", mode(), msg)
normal! y
call assert_equal('e (two) t', @")
endfor
let &mouse = save_mouse
let &term = save_term
let &ttymouse = save_ttymouse
set mousetime& mousemodel&
call test_override('no_query_mouse', 0)
close!
endfunc
func Test_xterm_mouse_click_in_fold_columns()
new
let save_mouse = &mouse
@@ -1086,13 +1180,37 @@ func Test_term_mouse_visual_mode()
call assert_equal('three four', @")
call assert_equal(9, col('.'))
" Multi-line selection. Right click in the middle of thse selection
call setline(1, ["one", "two", "three", "four", "five", "six"])
" Right click inside the selection closer to the start of the selection
call test_setmouse(1, 7)
exe "normal 5|vee\<RightMouse>lly"
call assert_equal('three', @")
call assert_equal(9, col('.'))
call assert_equal(9, col("'<"))
call assert_equal(13, col("'>"))
" Right click inside the selection closer to the end of the selection
call test_setmouse(1, 11)
exe "normal 5|vee\<RightMouse>ly"
call assert_equal('two thre', @")
call assert_equal(5, col('.'))
call assert_equal(5, col("'<"))
call assert_equal(12, col("'>"))
" Multi-line selection. Right click inside thse selection.
call setline(1, repeat(['aaaaaa'], 7))
call test_setmouse(3, 1)
exe "normal ggVG\<RightMouse>y"
call assert_equal(3, line("'<"))
call test_setmouse(4, 1)
call test_setmouse(5, 1)
exe "normal ggVG\<RightMouse>y"
call assert_equal(5, line("'>"))
" Click right in the middle line of the selection
call test_setmouse(4, 3)
exe "normal ggVG$\<RightMouse>y"
call assert_equal(4, line("'<"))
call test_setmouse(4, 4)
exe "normal ggVG$\<RightMouse>y"
call assert_equal(4, line("'>"))
set mousemodel&
@@ -1120,11 +1238,12 @@ func Test_term_mouse_popup_menu()
menu PopUp.baz :let g:menustr = 'baz'<CR>
for ttymouse_val in g:Ttymouse_values
let msg = 'ttymouse=' .. ttymouse_val
exe 'set ttymouse=' .. ttymouse_val
let g:menustr = ''
call feedkeys(MouseRightClickCode(1, 4)
\ .. MouseRightReleaseCode(1, 4) .. "\<Down>\<Down>\<CR>", "x")
call assert_equal('bar', g:menustr)
call assert_equal('bar', g:menustr, msg)
endfor
unmenu PopUp
@@ -1158,70 +1277,71 @@ func Test_term_mouse_popup_menu_setpos()
vmenu PopUp.baz y:<C-U>let g:menustr = 'baz'<CR>
for ttymouse_val in g:Ttymouse_values
let msg = 'ttymouse=' .. ttymouse_val
exe 'set ttymouse=' .. ttymouse_val
let g:menustr = ''
call cursor(1, 1)
call feedkeys(MouseRightClickCode(1, 5)
\ .. MouseRightReleaseCode(1, 5) .. "\<Down>\<Down>\<CR>", "x")
call assert_equal('bar', g:menustr)
call assert_equal([1, 5], [line('.'), col('.')])
call assert_equal('bar', g:menustr, msg)
call assert_equal([1, 5], [line('.'), col('.')], msg)
" Test for right click in visual mode inside the selection
let @" = ''
call cursor(1, 10)
call feedkeys('vee' .. MouseRightClickCode(1, 12)
\ .. MouseRightReleaseCode(1, 12) .. "\<Down>\<CR>", "x")
call assert_equal([1, 10], [line('.'), col('.')])
call assert_equal('ran away', @")
call assert_equal([1, 10], [line('.'), col('.')], msg)
call assert_equal('ran away', @", msg)
" Test for right click in visual mode before the selection
let @" = ''
call cursor(1, 10)
call feedkeys('vee' .. MouseRightClickCode(1, 2)
\ .. MouseRightReleaseCode(1, 2) .. "\<Down>\<CR>", "x")
call assert_equal([1, 2], [line('.'), col('.')])
call assert_equal('', @")
call assert_equal([1, 2], [line('.'), col('.')], msg)
call assert_equal('', @", msg)
" Test for right click in visual mode after the selection
let @" = ''
call cursor(1, 10)
call feedkeys('vee' .. MouseRightClickCode(1, 20)
\ .. MouseRightReleaseCode(1, 20) .. "\<Down>\<CR>", "x")
call assert_equal([1, 20], [line('.'), col('.')])
call assert_equal('', @")
call assert_equal([1, 20], [line('.'), col('.')], msg)
call assert_equal('', @", msg)
" Test for right click in block-wise visual mode inside the selection
let @" = ''
call cursor(1, 16)
call feedkeys("\<C-V>j3l" .. MouseRightClickCode(2, 17)
\ .. MouseRightReleaseCode(2, 17) .. "\<Down>\<CR>", "x")
call assert_equal([1, 16], [line('.'), col('.')])
call assert_equal("\<C-V>4", getregtype('"'))
call assert_equal([1, 16], [line('.'), col('.')], msg)
call assert_equal("\<C-V>4", getregtype('"'), msg)
" Test for right click in block-wise visual mode outside the selection
let @" = ''
call cursor(1, 16)
call feedkeys("\<C-V>j3l" .. MouseRightClickCode(2, 2)
\ .. MouseRightReleaseCode(2, 2) .. "\<Down>\<CR>", "x")
call assert_equal([2, 2], [line('.'), col('.')])
call assert_equal('v', getregtype('"'))
call assert_equal('', @")
call assert_equal([2, 2], [line('.'), col('.')], msg)
call assert_equal('v', getregtype('"'), msg)
call assert_equal('', @", msg)
" Try clicking on the status line
let @" = ''
call cursor(1, 10)
call feedkeys('vee' .. MouseRightClickCode(6, 2)
\ .. MouseRightReleaseCode(6, 2) .. "\<Down>\<CR>", "x")
call assert_equal([1, 10], [line('.'), col('.')])
call assert_equal('ran away', @")
call assert_equal([1, 10], [line('.'), col('.')], msg)
call assert_equal('ran away', @", msg)
" Try clicking outside the window
let @" = ''
call cursor(7, 2)
call feedkeys('vee' .. MouseRightClickCode(7, 2)
\ .. MouseRightReleaseCode(7, 2) .. "\<Down>\<CR>", "x")
call assert_equal(2, winnr())
call assert_equal('', @")
call assert_equal(2, winnr(), msg)
call assert_equal('', @", msg)
wincmd w
endfor
@@ -1303,6 +1423,111 @@ func Test_term_mouse_quickfix_window()
call test_override('no_query_mouse', 0)
endfunc
" Test for the 'h' flag in the 'mouse' option. Using mouse in the help window.
func Test_term_mouse_help_window()
let save_mouse = &mouse
let save_term = &term
let save_ttymouse = &ttymouse
call test_override('no_query_mouse', 1)
set mouse=h term=xterm mousetime=200
for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec
let msg = 'ttymouse=' .. ttymouse_val
exe 'set ttymouse=' .. ttymouse_val
help
let @" = ''
call MouseLeftClick(2, 5)
call MouseLeftRelease(2, 5)
call MouseLeftClick(1, 1)
call MouseLeftDrag(1, 10)
call MouseLeftRelease(1, 10)
norm! y
call assert_equal('*help.txt*', @", msg)
helpclose
" Click somewhere else to make sure the left click above is not combined
" with the next left click and treated as a double click
call MouseRightClick(5, 10)
call MouseRightRelease(5, 10)
endfor
let &mouse = save_mouse
let &term = save_term
let &ttymouse = save_ttymouse
set mousetime&
call test_override('no_query_mouse', 0)
%bw!
endfunc
" Test for the translation of various mouse terminal codes
func Test_mouse_termcodes()
let save_mouse = &mouse
let save_term = &term
let save_ttymouse = &ttymouse
call test_override('no_query_mouse', 1)
set mouse=a term=xterm mousetime=200
new
for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec + g:Ttymouse_netterm
let msg = 'ttymouse=' .. ttymouse_val
exe 'set ttymouse=' .. ttymouse_val
let mouse_codes = [
\ ["\<LeftMouse>", "<LeftMouse>"],
\ ["\<MiddleMouse>", "<MiddleMouse>"],
\ ["\<RightMouse>", "<RightMouse>"],
\ ["\<S-LeftMouse>", "<S-LeftMouse>"],
\ ["\<S-MiddleMouse>", "<S-MiddleMouse>"],
\ ["\<S-RightMouse>", "<S-RightMouse>"],
\ ["\<C-LeftMouse>", "<C-LeftMouse>"],
\ ["\<C-MiddleMouse>", "<C-MiddleMouse>"],
\ ["\<C-RightMouse>", "<C-RightMouse>"],
\ ["\<M-LeftMouse>", "<M-LeftMouse>"],
\ ["\<M-MiddleMouse>", "<M-MiddleMouse>"],
\ ["\<M-RightMouse>", "<M-RightMouse>"],
\ ["\<2-LeftMouse>", "<2-LeftMouse>"],
\ ["\<2-MiddleMouse>", "<2-MiddleMouse>"],
\ ["\<2-RightMouse>", "<2-RightMouse>"],
\ ["\<3-LeftMouse>", "<3-LeftMouse>"],
\ ["\<3-MiddleMouse>", "<3-MiddleMouse>"],
\ ["\<3-RightMouse>", "<3-RightMouse>"],
\ ["\<4-LeftMouse>", "<4-LeftMouse>"],
\ ["\<4-MiddleMouse>", "<4-MiddleMouse>"],
\ ["\<4-RightMouse>", "<4-RightMouse>"],
\ ["\<LeftDrag>", "<LeftDrag>"],
\ ["\<MiddleDrag>", "<MiddleDrag>"],
\ ["\<RightDrag>", "<RightDrag>"],
\ ["\<LeftRelease>", "<LeftRelease>"],
\ ["\<MiddleRelease>", "<MiddleRelease>"],
\ ["\<RightRelease>", "<RightRelease>"],
\ ["\<ScrollWheelUp>", "<ScrollWheelUp>"],
\ ["\<S-ScrollWheelUp>", "<S-ScrollWheelUp>"],
\ ["\<C-ScrollWheelUp>", "<C-ScrollWheelUp>"],
\ ["\<ScrollWheelDown>", "<ScrollWheelDown>"],
\ ["\<S-ScrollWheelDown>", "<S-ScrollWheelDown>"],
\ ["\<C-ScrollWheelDown>", "<C-ScrollWheelDown>"],
\ ["\<ScrollWheelLeft>", "<ScrollWheelLeft>"],
\ ["\<S-ScrollWheelLeft>", "<S-ScrollWheelLeft>"],
\ ["\<C-ScrollWheelLeft>", "<C-ScrollWheelLeft>"],
\ ["\<ScrollWheelRight>", "<ScrollWheelRight>"],
\ ["\<S-ScrollWheelRight>", "<S-ScrollWheelRight>"],
\ ["\<C-ScrollWheelRight>", "<C-ScrollWheelRight>"]
\ ]
for [code, outstr] in mouse_codes
exe "normal ggC\<C-K>" . code
call assert_equal(outstr, getline(1), msg)
endfor
endfor
let &mouse = save_mouse
let &term = save_term
let &ttymouse = save_ttymouse
set mousetime&
call test_override('no_query_mouse', 0)
%bw!
endfunc
" This only checks if the sequence is recognized.
func Test_term_rgb_response()
set t_RF=x

View File

@@ -17,6 +17,7 @@ let g:inc_counter = 1
let $SOME_ENV_VAR = 'some'
let g:alist = [7]
let g:astring = 'text'
let g:anumber = 123
def Test_assignment()
let bool1: bool = true
@@ -509,8 +510,160 @@ def Test_try_catch()
add(l, '3')
endtry # comment
assert_equal(['1', 'wrong', '3'], l)
l = []
try
try
add(l, '1')
throw 'wrong'
add(l, '2')
catch /right/
add(l, v:exception)
endtry
catch /wrong/
add(l, 'caught')
finally
add(l, 'finally')
endtry
assert_equal(['1', 'caught', 'finally'], l)
let n: number
try
n = l[3]
catch /E684:/
n = 99
endtry
assert_equal(99, n)
try
n = g:astring[3]
catch /E714:/
n = 77
endtry
assert_equal(77, n)
try
n = l[g:astring]
catch /E39:/
n = 77
endtry
assert_equal(77, n)
try
n = s:does_not_exist
catch /E121:/
n = 111
endtry
assert_equal(111, n)
try
n = g:does_not_exist
catch /E121:/
n = 121
endtry
assert_equal(121, n)
let d = #{one: 1}
try
n = d[g:astring]
catch /E716:/
n = 222
endtry
assert_equal(222, n)
try
n = -g:astring
catch /E39:/
n = 233
endtry
assert_equal(233, n)
try
n = +g:astring
catch /E1030:/
n = 244
endtry
assert_equal(244, n)
try
n = +g:alist
catch /E745:/
n = 255
endtry
assert_equal(255, n)
let nd: dict<any>
try
nd = {g:anumber: 1}
catch /E1029:/
n = 266
endtry
assert_equal(266, n)
try
[n] = [1, 2, 3]
catch /E1093:/
n = 277
endtry
assert_equal(277, n)
try
&ts = g:astring
catch /E1029:/
n = 288
endtry
assert_equal(288, n)
try
&backspace = 'asdf'
catch /E474:/
n = 299
endtry
assert_equal(299, n)
l = [1]
try
l[3] = 3
catch /E684:/
n = 300
endtry
assert_equal(300, n)
try
d[''] = 3
catch /E713:/
n = 311
endtry
assert_equal(311, n)
try
unlet g:does_not_exist
catch /E108:/
n = 322
endtry
assert_equal(322, n)
try
d = {'text': 1, g:astring: 2}
catch /E721:/
n = 333
endtry
assert_equal(333, n)
try
l = DeletedFunc()
catch /E933:/
n = 344
endtry
assert_equal(344, n)
enddef
def DeletedFunc(): list<any>
return ['delete me']
enddef
defcompile
delfunc DeletedFunc
def ThrowFromDef()
throw "getout" # comment
enddef

View File

@@ -754,6 +754,26 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1237,
/**/
1236,
/**/
1235,
/**/
1234,
/**/
1233,
/**/
1232,
/**/
1231,
/**/
1230,
/**/
1229,
/**/
1228,
/**/
1227,
/**/

View File

@@ -4961,6 +4961,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
}
if (need_type(stacktype, &t_list_any, -1, cctx, FALSE) == FAIL)
goto theend;
// TODO: check the length of a constant list here
generate_CHECKLEN(cctx, semicolon ? var_count - 1 : var_count,
semicolon);
}
@@ -6539,6 +6540,7 @@ compile_finally(char_u *arg, cctx_T *cctx)
// Previous catch without match jumps here
isn = ((isn_T *)instr->ga_data) + scope->se_u.se_try.ts_catch_label;
isn->isn_arg.jump.jump_where = instr->ga_len;
scope->se_u.se_try.ts_catch_label = 0;
}
// TODO: set index in ts_finally_label jumps
@@ -6584,8 +6586,18 @@ compile_endtry(char_u *arg, cctx_T *cctx)
compile_fill_jump_to_end(&scope->se_u.se_try.ts_end_label, cctx);
// End :catch or :finally scope: set value in ISN_TRY instruction
if (isn->isn_arg.try.try_catch == 0)
isn->isn_arg.try.try_catch = instr->ga_len;
if (isn->isn_arg.try.try_finally == 0)
isn->isn_arg.try.try_finally = instr->ga_len;
if (scope->se_u.se_try.ts_catch_label != 0)
{
// Last catch without match jumps here
isn = ((isn_T *)instr->ga_data) + scope->se_u.se_try.ts_catch_label;
isn->isn_arg.jump.jump_where = instr->ga_len;
}
compile_endblock(cctx);
if (generate_instr(cctx, ISN_ENDTRY) == NULL)

View File

@@ -1065,7 +1065,7 @@ call_def_function(
if (di == NULL)
{
semsg(_(e_undefvar), name);
goto failed;
goto on_error;
}
else
{
@@ -1113,7 +1113,7 @@ call_def_function(
{
semsg(_("E121: Undefined variable: %c:%s"),
namespace, iptr->isn_arg.string);
goto failed;
goto on_error;
}
else
{
@@ -1241,7 +1241,7 @@ call_def_function(
if (msg != NULL)
{
emsg(_(msg));
goto failed;
goto on_error;
}
}
break;
@@ -1272,7 +1272,8 @@ call_def_function(
--ectx.ec_stack.ga_len;
if (set_vim_var_tv(iptr->isn_arg.number, STACK_TV_BOT(0))
== FAIL)
goto failed;
// should not happen, type is checked when compiling
goto on_error;
break;
// store g:/b:/w:/t: variable
@@ -1335,7 +1336,7 @@ call_def_function(
if (lidx < 0 || lidx > list->lv_len)
{
semsg(_(e_listidx), lidx);
goto failed;
goto on_error;
}
tv = STACK_TV_BOT(-3);
if (lidx < list->lv_len)
@@ -1348,7 +1349,7 @@ call_def_function(
}
else
{
// append to list
// append to list, only fails when out of memory
if (list_append_tv(list, tv) == FAIL)
goto failed;
clear_tv(tv);
@@ -1371,18 +1372,19 @@ call_def_function(
if (key == NULL || *key == NUL)
{
emsg(_(e_emptykey));
goto failed;
goto on_error;
}
tv = STACK_TV_BOT(-3);
di = dict_find(dict, key, -1);
if (di != NULL)
{
// overwrite existing value
clear_tv(&di->di_tv);
di->di_tv = *tv;
}
else
{
// add to dict
// add to dict, only fails when out of memory
if (dict_add_tv(dict, (char *)key, tv) == FAIL)
goto failed;
clear_tv(tv);
@@ -1465,7 +1467,7 @@ call_def_function(
case ISN_UNLET:
if (do_unlet(iptr->isn_arg.unlet.ul_name,
iptr->isn_arg.unlet.ul_forceit) == FAIL)
goto failed;
goto on_error;
break;
case ISN_UNLETENV:
vim_unsetenv(iptr->isn_arg.unlet.ul_name);
@@ -1481,24 +1483,38 @@ call_def_function(
// create a dict from items on the stack
case ISN_NEWDICT:
{
int count = iptr->isn_arg.number;
dict_T *dict = dict_alloc();
dictitem_T *item;
int count = iptr->isn_arg.number;
dict_T *dict = dict_alloc();
dictitem_T *item;
if (dict == NULL)
goto failed;
for (idx = 0; idx < count; ++idx)
{
// check key type is VAR_STRING
// have already checked key type is VAR_STRING
tv = STACK_TV_BOT(2 * (idx - count));
// check key is unique
item = dict_find(dict, tv->vval.v_string, -1);
if (item != NULL)
{
semsg(_(e_duplicate_key), tv->vval.v_string);
dict_unref(dict);
goto on_error;
}
item = dictitem_alloc(tv->vval.v_string);
clear_tv(tv);
if (item == NULL)
{
dict_unref(dict);
goto failed;
}
item->di_tv = *STACK_TV_BOT(2 * (idx - count) + 1);
item->di_tv.v_lock = 0;
if (dict_add(dict, item) == FAIL)
{
dict_unref(dict);
goto failed;
}
}
if (count > 0)
@@ -1519,7 +1535,7 @@ call_def_function(
if (call_dfunc(iptr->isn_arg.dfunc.cdf_idx,
iptr->isn_arg.dfunc.cdf_argcount,
&ectx) == FAIL)
goto failed;
goto on_error;
break;
// call a builtin function
@@ -1786,6 +1802,7 @@ call_def_function(
--trystack->ga_len;
--trylevel;
ectx.ec_in_catch = FALSE;
trycmd = ((trycmd_T *)trystack->ga_data)
+ trystack->ga_len;
if (trycmd->tcd_caught && current_exception != NULL)
@@ -2084,7 +2101,8 @@ call_def_function(
case EXPR_DIV: f1 = f1 / f2; break;
case EXPR_SUB: f1 = f1 - f2; break;
case EXPR_ADD: f1 = f1 + f2; break;
default: emsg(_(e_modulus)); goto failed;
default: emsg(_(e_modulus));
goto on_error;
}
clear_tv(tv1);
clear_tv(tv2);
@@ -2138,7 +2156,7 @@ call_def_function(
if (tv->v_type != VAR_LIST)
{
emsg(_(e_listreq));
goto failed;
goto on_error;
}
list = tv->vval.v_list;
@@ -2146,18 +2164,18 @@ call_def_function(
if (tv->v_type != VAR_NUMBER)
{
emsg(_(e_number_exp));
goto failed;
goto on_error;
}
n = tv->vval.v_number;
clear_tv(tv);
if ((li = list_find(list, n)) == NULL)
{
semsg(_(e_listidx), n);
goto failed;
goto on_error;
}
--ectx.ec_stack.ga_len;
// Clear the list after getting the item, to avoid that it
// make the item invalid.
// makes the item invalid.
tv = STACK_TV_BOT(-1);
temp_tv = *tv;
copy_tv(&li->li_tv, tv);
@@ -2226,7 +2244,7 @@ call_def_function(
if ((di = dict_find(dict, key, -1)) == NULL)
{
semsg(_(e_dictkey), key);
goto failed;
goto on_error;
}
clear_tv(tv);
--ectx.ec_stack.ga_len;
@@ -2277,7 +2295,7 @@ call_def_function(
)
{
emsg(_(e_number_exp));
goto failed;
goto on_error;
}
#ifdef FEAT_FLOAT
if (tv->v_type == VAR_FLOAT)
@@ -2293,10 +2311,10 @@ call_def_function(
tv = STACK_TV_BOT(-1);
if (check_not_string(tv) == FAIL)
goto failed;
goto on_error;
(void)tv_get_number_chk(tv, &error);
if (error)
goto failed;
goto on_error;
}
break;
@@ -2315,7 +2333,7 @@ call_def_function(
semsg(_("E1029: Expected %s but got %s"),
vartype_name(ct->ct_type),
vartype_name(tv->v_type));
goto failed;
goto on_error;
}
}
break;
@@ -2334,7 +2352,7 @@ call_def_function(
{
semsg(_("E1093: Expected %d items but got %d"),
min_len, list == NULL ? 0 : list->lv_len);
goto failed;
goto on_error;
}
}
break;
@@ -2389,6 +2407,11 @@ call_def_function(
clear_tv(STACK_TV_BOT(0));
break;
}
continue;
on_error:
if (trylevel == 0)
goto failed;
}
done: