Compare commits

...

21 Commits

Author SHA1 Message Date
Bram Moolenaar
1efefda623 patch 8.2.2003: build error with +conceal but without +popupwin
Problem:    Build error with +conceal but without +popupwin.
Solution:   Add #ifdef. (Tom Ryder, closes #7316)
2020-11-17 19:22:06 +01:00
Bram Moolenaar
52bf81c2d5 patch 8.2.2002: Vim9: lambda argument shadowed by function name
Problem:    Vim9: lambda argument shadowed by function name.
Solution:   Let function name be shadowed by lambda argument. (closes #7313)
2020-11-17 18:50:44 +01:00
Bram Moolenaar
0ba48e8c27 patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Problem:    Vim9: :def function does not apply 'maxfuncdepth'.
Solution:   Use 'maxfuncdepth'. (issue #7313)
2020-11-17 18:23:19 +01:00
Bram Moolenaar
fc74d03e76 patch 8.2.2000: Vim9: dict.key assignment not implemented yet
Problem:    Vim9: dict.key assignment not implemented yet.
Solution:   Implement dict.key assignment. (closes #7312)
2020-11-16 22:11:49 +01:00
Bram Moolenaar
e6329e4c55 patch 8.2.1999: terminal popup test sometimes fails
Problem:    Terminal popup test sometimes fails.
Solution:   Wait for the popup to close.
2020-11-16 21:10:34 +01:00
Bram Moolenaar
27f4f6baee patch 8.2.1998: terminal Cmd test sometimes fails to close popup
Problem:    Terminal Cmd test sometimes fails to close popup.
Solution:   Add "term_finish" option.
2020-11-16 21:02:28 +01:00
Bram Moolenaar
8adc8d9b73 patch 8.2.1997: window changes when using bufload() while in a terminal popup
Problem:    Window changes when using bufload() while in a terminal popup.
Solution:   When searching for a window by ID also find a popup window.
            (closes #7307)
2020-11-16 20:47:31 +01:00
Bram Moolenaar
193f6201b4 patch 8.2.1996: Vim9: invalid error for argument of extend()
Problem:    Vim9: invalid error for argument of extend().
Solution:   Check if the type could match. (closes #7299)
2020-11-16 20:08:35 +01:00
Bram Moolenaar
714cbe5b21 patch 8.2.1995: the popup menu can cause too much redrawing
Problem:    The popup menu can cause too much redrawing.
Solution:   Reduce the length of the displayed text. (Yasuhiro Matsumoto,
            closes #7306)
2020-11-16 19:12:00 +01:00
Bram Moolenaar
c4390fe6c0 patch 8.2.1994: MS-Windows: MinGW always does a full build
Problem:    MS-Windows: MinGW always does a full build.
Solution:   Only check if $OUTDIR exists. (Masamichi Abe, closes #7311)
2020-11-16 18:49:47 +01:00
Bram Moolenaar
50dc3ecc64 patch 8.2.1993: occasional failure of the netbeans test
Problem:    Occasional failure of the netbeans test.
Solution:   Add "silent!". (Yegappan Lakshmanan, closes #7304)
2020-11-16 18:39:43 +01:00
Bram Moolenaar
4792a679f9 patch 8.2.1992: build fails with small features
Problem:    Build fails with small features.
Solution:   Add #ifdef.
2020-11-15 21:11:18 +01:00
Bram Moolenaar
ca359cbedd patch 8.2.1991: Coverity warns for not using the ga_grow() return value
Problem:    Coverity warns for not using the ga_grow() return value.
Solution:   Bail out if ga_grow() fails. (Yegappan Lakshmanan, closes #7303)
2020-11-15 20:49:41 +01:00
Bram Moolenaar
6a07644db3 patch 8.2.1990: cursor position wrong in terminal popup with finished job
Problem:    Cursor position wrong in terminal popup with finished job.
Solution:   Only add the top and left offset when not done already.
            (closes #7298)
2020-11-15 20:32:58 +01:00
Bram Moolenaar
2dfae04f37 patch 8.2.1989: info popup triggers WinEnter and WinLeave autocommands
Problem:    Info popup triggers WinEnter and WinLeave autocommands.
Solution:   Suppress autocommands for the info popup. (closes #7296)
2020-11-15 14:09:37 +01:00
Bram Moolenaar
e41decc892 patch 8.2.1988: still in Insert mode when opening terminal popup
Problem:    Still in Insert mode when opening terminal popup with a <Cmd>
            mapping in Insert mode.
Solution:   Exit Insert mode. (closes #7295)
2020-11-14 21:34:59 +01:00
Bram Moolenaar
6453cc8078 patch 8.2.1987: MS-Windows: Win32.mak is no longer needed
Problem:    MS-Windows: Win32.mak is no longer needed.
Solution:   Do not include Win32.mak. (Jason McHugh, closes #7290)
2020-11-14 21:04:33 +01:00
Bram Moolenaar
a065a14115 patch 8.2.1986: expression test is flaky on Appveyor
Problem:    Expression test is flaky on Appveyor.
Solution:   Temporarily disable the test in MS-Windows.
2020-11-14 20:57:20 +01:00
Bram Moolenaar
02764713a7 patch 8.2.1985: crash when closing terminal popup with <Cmd> mapping
Problem:    Crash when closing terminal popup with <Cmd> mapping.
Solution:   Check b_term is not NULL. (closes #7294)
2020-11-14 20:21:55 +01:00
Bram Moolenaar
33aecb1f2c patch 8.2.1984: cannot use :vimgrep in omni completion
Problem:    Cannot use :vimgrep in omni completion, causing C completion to
            fail.
Solution:   Add the EX_LOCK_OK flag to :vimgrep. (closes #7292)
2020-11-14 17:25:51 +01:00
Bram Moolenaar
f4d61bc559 patch 8.2.1983: ml_get error when using <Cmd> to open a terminal
Problem:    ml_get error when using <Cmd> to open a terminal.
Solution:   If the window changed reset the incsearch state. (closes #7289)
2020-11-14 14:22:28 +01:00
33 changed files with 506 additions and 105 deletions

View File

@@ -264,11 +264,6 @@ For building 64 bit binaries you also need to install the SDK:
"Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1"
You don't need the examples and documentation.
If you get an error that Win32.mak can't be found, you have to set the
variable SDK_INCLUDE_DIR. For example, on Windows 10, installation of MSVC
puts include files in the following directory:
set SDK_INCLUDE_DIR=C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include
2. MSYS2 with MinGW
===================

View File

@@ -1055,23 +1055,23 @@ install.exe: dosinst.c dosinst.h version.h
uninstall.exe: uninstall.c dosinst.h version.h
$(CC) $(CFLAGS) -o uninstall.exe uninstall.c $(LIB) -lole32
$(OBJ): $(OUTDIR)
$(OBJ): | $(OUTDIR)
$(EXEOBJG): $(OUTDIR)
$(EXEOBJG): | $(OUTDIR)
$(EXEOBJC): $(OUTDIR)
$(EXEOBJC): | $(OUTDIR)
ifeq ($(VIMDLL),yes)
$(TARGET): $(OUTDIR) $(OBJ)
$(TARGET): $(OBJ)
$(LINK) $(CFLAGS) $(LFLAGS) -o $@ $(OBJ) $(LIB) -lole32 -luuid -lgdi32 $(LUA_LIB) $(MZSCHEME_LIBDIR) $(MZSCHEME_LIB) $(PYTHONLIB) $(PYTHON3LIB) $(RUBYLIB)
$(GVIMEXE): $(OUTDIR) $(EXEOBJG) $(VIMDLLBASE).dll
$(GVIMEXE): $(EXEOBJG) $(VIMDLLBASE).dll
$(CC) -L. $(EXELFLAGS) -mwindows -o $@ $(EXEOBJG) -l$(VIMDLLBASE)
$(VIMEXE): $(OUTDIR) $(EXEOBJC) $(VIMDLLBASE).dll
$(VIMEXE): $(EXEOBJC) $(VIMDLLBASE).dll
$(CC) -L. $(EXELFLAGS) -o $@ $(EXEOBJC) -l$(VIMDLLBASE)
else
$(TARGET): $(OUTDIR) $(OBJ)
$(TARGET): $(OBJ)
$(LINK) $(CFLAGS) $(LFLAGS) -o $@ $(OBJ) $(LIB) -lole32 -luuid $(LUA_LIB) $(MZSCHEME_LIBDIR) $(MZSCHEME_LIB) $(PYTHONLIB) $(PYTHON3LIB) $(RUBYLIB)
endif
@@ -1286,7 +1286,7 @@ $(OUTDIR)/%.o : xdiff/%.c $(XDIFF_DEPS)
$(CC) -c $(CFLAGS) $< -o $@
$(PATHDEF_SRC): $(OUTDIR) Make_cyg_ming.mak Make_cyg.mak Make_ming.mak
$(PATHDEF_SRC): Make_cyg_ming.mak Make_cyg.mak Make_ming.mak | $(OUTDIR)
ifneq (sh.exe, $(SHELL))
@echo creating $(PATHDEF_SRC)
@echo '/* pathdef.c */' > $(PATHDEF_SRC)

View File

@@ -15,11 +15,7 @@
# This will build the console version of Vim with no additional interfaces.
# To add features, define any of the following:
#
# For MSVC 11, if you want to include Win32.mak, you need to specify
# where the file is, e.g.:
# SDK_INCLUDE_DIR="C:\Program Files\Microsoft SDKs\Windows\v7.1\Include"
#
# !!!! After changing features do "nmake clean" first !!!!
# !!!! After changing any features do "nmake clean" first !!!!
#
# Feature Set: FEATURES=[TINY, SMALL, NORMAL, BIG, HUGE] (default is HUGE)
#
@@ -209,9 +205,6 @@ OBJDIR = $(OBJDIR)V
OBJDIR = $(OBJDIR)d
!endif
# If you include Win32.mak, it requires that CPU be set appropriately.
# To cross-compile for Win64, set CPU=AMD64 or CPU=IA64.
!ifdef PROCESSOR_ARCHITECTURE
# We're on Windows NT or using VC 6+
! ifdef CPU
@@ -251,18 +244,7 @@ NODEBUG = 1
MAKEFLAGS_GVIMEXT = DEBUG=yes
!endif
# Get all sorts of useful, standard macros from the Platform SDK,
# if SDK_INCLUDE_DIR is set or USE_WIN32MAK is set to "yes".
!ifdef SDK_INCLUDE_DIR
! include $(SDK_INCLUDE_DIR)\Win32.mak
!elseif "$(USE_WIN32MAK)"=="yes"
! include <Win32.mak>
!else
link = link
!endif
# Check VC version.
!if [echo MSVCVER=_MSC_VER> msvcver.c && $(CC) /EP msvcver.c > msvcver.~ 2> nul]

View File

@@ -2446,15 +2446,18 @@ win_line(
&& conceal_cursor_line(wp)
&& (int)wp->w_virtcol <= vcol + n_skip)
{
# ifdef FEAT_RIGHTLEFT
# ifdef FEAT_RIGHTLEFT
if (wp->w_p_rl)
wp->w_wcol = wp->w_width - col + boguscols - 1;
else
# endif
# endif
wp->w_wcol = col - boguscols;
wp->w_wrow = row;
did_wcol = TRUE;
curwin->w_valid |= VALID_WCOL|VALID_WROW|VALID_VIRTCOL;
# ifdef FEAT_PROP_POPUP
curwin->w_flags &= ~(WFLAG_WCOL_OFF_ADDED | WFLAG_WROW_OFF_ADDED);
# endif
}
#endif

View File

@@ -1033,6 +1033,11 @@ doESCkey:
case K_COMMAND: // <Cmd>command<CR>
do_cmdline(NULL, getcmdkeycmd, NULL, 0);
#ifdef FEAT_TERMINAL
if (term_use_loop())
// Started a terminal that gets the input, exit Insert mode.
goto doESCkey;
#endif
break;
case K_CURSORHOLD: // Didn't type something for a while.

View File

@@ -295,7 +295,7 @@ arg_float_or_nr(type_T *type, argcontext_T *context)
static int
arg_number(type_T *type, argcontext_T *context)
{
return check_type(&t_number, type, TRUE, context->arg_idx + 1);
return check_arg_type(&t_number, type, context->arg_idx + 1);
}
/*
@@ -304,7 +304,7 @@ arg_number(type_T *type, argcontext_T *context)
static int
arg_string(type_T *type, argcontext_T *context)
{
return check_type(&t_string, type, TRUE, context->arg_idx + 1);
return check_arg_type(&t_string, type, context->arg_idx + 1);
}
/*
@@ -342,7 +342,7 @@ arg_same_as_prev(type_T *type, argcontext_T *context)
{
type_T *prev_type = context->arg_types[context->arg_idx - 1];
return check_type(prev_type, type, TRUE, context->arg_idx + 1);
return check_arg_type(prev_type, type, context->arg_idx + 1);
}
/*
@@ -363,7 +363,7 @@ arg_item_of_prev(type_T *type, argcontext_T *context)
// probably VAR_ANY, can't check
return OK;
return check_type(expected, type, TRUE, context->arg_idx + 1);
return check_arg_type(expected, type, context->arg_idx + 1);
}
/*

View File

@@ -929,10 +929,10 @@ EXCMD(CMD_luafile, "luafile", ex_luafile,
EX_RANGE|EX_FILE1|EX_NEEDARG|EX_CMDWIN|EX_LOCK_OK|EX_RESTRICT,
ADDR_LINES),
EXCMD(CMD_lvimgrep, "lvimgrep", ex_vimgrep,
EX_RANGE|EX_BANG|EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM|EX_TRLBAR|EX_XFILE,
EX_RANGE|EX_BANG|EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM|EX_TRLBAR|EX_XFILE|EX_LOCK_OK,
ADDR_OTHER),
EXCMD(CMD_lvimgrepadd, "lvimgrepadd", ex_vimgrep,
EX_RANGE|EX_BANG|EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM|EX_TRLBAR|EX_XFILE,
EX_RANGE|EX_BANG|EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM|EX_TRLBAR|EX_XFILE|EX_LOCK_OK,
ADDR_OTHER),
EXCMD(CMD_lwindow, "lwindow", ex_cwindow,
EX_RANGE|EX_COUNT|EX_TRLBAR,
@@ -1673,10 +1673,10 @@ EXCMD(CMD_view, "view", ex_edit,
EX_BANG|EX_FILE1|EX_CMDARG|EX_ARGOPT|EX_TRLBAR,
ADDR_NONE),
EXCMD(CMD_vimgrep, "vimgrep", ex_vimgrep,
EX_RANGE|EX_BANG|EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM|EX_TRLBAR|EX_XFILE,
EX_RANGE|EX_BANG|EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM|EX_TRLBAR|EX_XFILE|EX_LOCK_OK,
ADDR_OTHER),
EXCMD(CMD_vimgrepadd, "vimgrepadd", ex_vimgrep,
EX_RANGE|EX_BANG|EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM|EX_TRLBAR|EX_XFILE,
EX_RANGE|EX_BANG|EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM|EX_TRLBAR|EX_XFILE|EX_LOCK_OK,
ADDR_OTHER),
EXCMD(CMD_vim9script, "vim9script", ex_vim9script,
EX_CMDWIN|EX_LOCK_OK,

View File

@@ -142,6 +142,7 @@ restore_viewstate(viewstate_T *vs)
typedef struct {
pos_T search_start; // where 'incsearch' starts searching
pos_T save_cursor;
int winid; // window where this state is valid
viewstate_T init_viewstate;
viewstate_T old_viewstate;
pos_T match_start;
@@ -154,6 +155,7 @@ typedef struct {
static void
init_incsearch_state(incsearch_state_T *is_state)
{
is_state->winid = curwin->w_id;
is_state->match_start = curwin->w_cursor;
is_state->did_incsearch = FALSE;
is_state->incsearch_postponed = FALSE;
@@ -1703,13 +1705,13 @@ getcmdline_int(
// Trigger SafeState if nothing is pending.
may_trigger_safestate(xpc.xp_numfiles <= 0);
cursorcmd(); // set the cursor on the right spot
// Get a character. Ignore K_IGNORE and K_NOP, they should not do
// anything, such as stop completion.
do
{
cursorcmd(); // set the cursor on the right spot
c = safe_vgetc();
while (c == K_IGNORE || c == K_NOP);
} while (c == K_IGNORE || c == K_NOP);
if (c == K_COMMAND
&& do_cmdline(NULL, getcmdkeycmd, NULL, DOCMD_NOWAIT) == OK)
@@ -2327,6 +2329,11 @@ cmdline_not_changed:
#endif
cmdline_changed:
#ifdef FEAT_SEARCH_EXTRA
// If the window changed incremental search state is not valid.
if (is_state.winid != curwin->w_id)
init_incsearch_state(&is_state);
#endif
// Trigger CmdlineChanged autocommands.
trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINECHANGED);

View File

@@ -3645,7 +3645,11 @@ getcmdkeycmd(
got_int = FALSE;
while (c1 != NUL && !aborted)
{
ga_grow(&line_ga, 32);
if (ga_grow(&line_ga, 32) != OK)
{
aborted = TRUE;
break;
}
if (vgetorpeek(FALSE) == NUL)
{

View File

@@ -868,6 +868,9 @@ validate_cursor_col(void)
curwin->w_wcol = col;
curwin->w_valid |= VALID_WCOL;
#ifdef FEAT_PROP_POPUP
curwin->w_flags &= ~WFLAG_WCOL_OFF_ADDED;
#endif
}
}
@@ -1180,7 +1183,10 @@ curs_columns(
{
curwin->w_wrow += popup_top_extra(curwin);
curwin->w_wcol += popup_left_extra(curwin);
curwin->w_flags |= WFLAG_WCOL_OFF_ADDED + WFLAG_WROW_OFF_ADDED;
}
else
curwin->w_flags &= ~(WFLAG_WCOL_OFF_ADDED + WFLAG_WROW_OFF_ADDED);
#endif
// now w_leftcol is valid, avoid check_cursor_moved() thinking otherwise

View File

@@ -361,6 +361,8 @@ pum_display(
// redo the positioning. Limit this to two times, when there is not
// much room the window size will keep changing.
} while (pum_set_selected(selected, redo_count) && ++redo_count <= 2);
pum_redraw();
}
/*
@@ -541,8 +543,23 @@ pum_redraw(void)
{
if (st != NULL)
{
screen_puts_len(st, (int)STRLEN(st), row, col,
attr);
int size = (int)STRLEN(st);
int cells = (*mb_string2cells)(st, size);
// only draw the text that fits
while (size > 0
&& col + cells > pum_width + pum_col)
{
--size;
if (has_mbyte)
{
size -= (*mb_head_off)(st, st + size);
cells -= (*mb_ptr2cells)(st + size);
}
else
--cells;
}
screen_puts_len(st, size, row, col, attr);
vim_free(st);
}
col += width;
@@ -795,6 +812,10 @@ pum_set_selected(int n, int repeat UNUSED)
use_popup = USEPOPUP_NORMAL;
else
use_popup = USEPOPUP_NONE;
if (use_popup != USEPOPUP_NONE)
// don't use WinEnter or WinLeave autocommands for the info
// popup
block_autocmds();
# endif
// Open a preview window and set "curwin" to it.
// 3 lines by default, prefer 'previewheight' if set and smaller.
@@ -972,6 +993,10 @@ pum_set_selected(int n, int repeat UNUSED)
if (WIN_IS_POPUP(curwin))
// can't keep focus in a popup window
win_enter(firstwin, TRUE);
# endif
# ifdef FEAT_PROP_POPUP
if (use_popup != USEPOPUP_NONE)
unblock_autocmds();
# endif
}
#endif
@@ -982,9 +1007,6 @@ pum_set_selected(int n, int repeat UNUSED)
popup_hide_info();
#endif
if (!resized)
pum_redraw();
return resized;
}

View File

@@ -3743,13 +3743,17 @@ update_popups(void (*win_update)(win_T *wp))
wp->w_winrow -= top_off;
wp->w_wincol -= left_extra;
// cursor position matters in terminal in job mode
#ifdef FEAT_TERMINAL
if (wp != curwin || !term_in_normal_mode())
#endif
// Add offset for border and padding if not done already.
if ((wp->w_flags & WFLAG_WCOL_OFF_ADDED) == 0)
{
wp->w_wcol += left_extra;
wp->w_flags |= WFLAG_WCOL_OFF_ADDED;
}
if ((wp->w_flags & WFLAG_WROW_OFF_ADDED) == 0)
{
wp->w_wrow += top_off;
wp->w_wcol += left_extra;
wp->w_flags |= WFLAG_WROW_OFF_ADDED;
}
total_width = popup_width(wp);

View File

@@ -14,6 +14,10 @@ ufunc_T *find_func(char_u *name, int is_global, cctx_T *cctx);
int func_is_global(ufunc_T *ufunc);
int func_name_refcount(char_u *name);
void copy_func(char_u *lambda, char_u *global);
int funcdepth_increment(void);
void funcdepth_decrement(void);
int funcdepth_get(void);
void funcdepth_restore(int depth);
int call_user_func_check(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rettv, funcexe_T *funcexe, dict_T *selfdict);
void save_funccal(funccal_entry_T *entry);
void restore_funccal(void);

View File

@@ -1,6 +1,7 @@
/* vim9compile.c */
int check_defined(char_u *p, size_t len, cctx_T *cctx);
int check_compare_types(exptype_T type, typval_T *tv1, typval_T *tv2);
int use_typecheck(type_T *actual, type_T *expected);
int get_script_item_idx(int sid, char_u *name, int check_writable, cctx_T *cctx);
imported_T *find_imported(char_u *name, size_t len, cctx_T *cctx);
imported_T *find_imported_in_script(char_u *name, size_t len, int sid);

View File

@@ -15,6 +15,7 @@ int check_typval_type(type_T *expected, typval_T *actual_tv, int argidx);
void type_mismatch(type_T *expected, type_T *actual);
void arg_type_mismatch(type_T *expected, type_T *actual, int argidx);
int check_type(type_T *expected, type_T *actual, int give_msg, int argidx);
int check_arg_type(type_T *expected, type_T *actual, int argidx);
char_u *skip_type(char_u *start, int optional);
type_T *parse_type(char_u **arg, garray_T *type_gap);
void common_type(type_T *type1, type_T *type2, type_T **dest, garray_T *type_gap);

View File

@@ -3348,6 +3348,10 @@ struct window_S
// top of the window
char w_topline_was_set; // flag set to TRUE when topline is set,
// e.g. by winrestview()
linenr_T w_botline; // number of the line below the bottom of
// the window
#ifdef FEAT_DIFF
int w_topfill; // number of filler lines above w_topline
int w_old_topfill; // w_topfill at last redraw
@@ -3361,6 +3365,12 @@ struct window_S
colnr_T w_skipcol; // starting column when a single line
// doesn't fit in the window
int w_empty_rows; // number of ~ rows in window
#ifdef FEAT_DIFF
int w_filler_rows; // number of filler rows at the end of the
// window
#endif
/*
* Layout of the window in the screen.
* May need to add "msg_scrolled" to "w_winrow" in rare situations.
@@ -3368,11 +3378,14 @@ struct window_S
int w_winrow; // first row of window in screen
int w_height; // number of rows in window, excluding
// status/command/winbar line(s)
int w_status_height; // number of status lines (0 or 1)
int w_wincol; // Leftmost column of window in screen.
int w_width; // Width of window, excluding separation.
int w_vsep_width; // Number of separator columns (0 or 1).
pos_save_T w_save_cursor; // backup of cursor pos and topline
#ifdef FEAT_PROP_POPUP
int w_popup_flags; // POPF_ values
int w_popup_handled; // POPUP_HANDLE[0-9] flags
@@ -3433,8 +3446,14 @@ struct window_S
# if defined(FEAT_TIMERS)
timer_T *w_popup_timer; // timer for closing popup window
# endif
#endif
int w_flags; // WFLAG_ flags
# define WFLAG_WCOL_OFF_ADDED 1 // popup border and padding were added to
// w_wcol
# define WFLAG_WROW_OFF_ADDED 2 // popup border and padding were added to
// w_wrow
#endif
/*
* === start of cached values ====
@@ -3475,14 +3494,6 @@ struct window_S
*/
int w_wrow, w_wcol; // cursor position in window
linenr_T w_botline; // number of the line below the bottom of
// the window
int w_empty_rows; // number of ~ rows in window
#ifdef FEAT_DIFF
int w_filler_rows; // number of filler rows at the end of the
// window
#endif
/*
* Info about the lines currently in the window is remembered to avoid
* recomputing it every time. The allocated size of w_lines[] is Rows.

View File

@@ -2208,7 +2208,10 @@ position_cursor(win_T *wp, VTermPos *pos, int add_off UNUSED)
{
wp->w_wrow += popup_top_extra(curwin);
wp->w_wcol += popup_left_extra(curwin);
wp->w_flags |= WFLAG_WCOL_OFF_ADDED | WFLAG_WROW_OFF_ADDED;
}
else
wp->w_flags &= ~(WFLAG_WCOL_OFF_ADDED | WFLAG_WROW_OFF_ADDED);
#endif
wp->w_valid |= (VALID_WCOL|VALID_WROW);
}
@@ -2527,7 +2530,7 @@ terminal_loop(int blocking)
while (blocking || vpeekc_nomap() != NUL)
{
#ifdef FEAT_GUI
if (!curbuf->b_term->tl_system)
if (curbuf->b_term != NULL && !curbuf->b_term->tl_system)
#endif
// TODO: skip screen update when handling a sequence of keys.
// Repeat redrawing in case a message is received while redrawing.
@@ -2542,8 +2545,6 @@ terminal_loop(int blocking)
restore_cursor = TRUE;
raw_c = term_vgetc();
if (raw_c > 0)
ch_log(NULL, "terminal_loop() got %d", raw_c);
if (!term_use_loop_check(TRUE) || in_terminal_loop != curbuf->b_term)
{
// Job finished while waiting for a character. Push back the

View File

@@ -0,0 +1,20 @@
| +0&#ffffff0@74
@75
@75
@75
@75
@75
@75
@75
@75
|!+2#ffffff16#00e0003|/|b|i|n|/|s|h| |[|f|i|n|i|s|h|e|d|]| @37|0|,|0|-|1| @9|A|l@1
|a+0#0000000#ffffff0| @73
|b| @73
|c| @73
|~+0#4040ff13&| @73
|~| @73
|~| @73
|~| @73
|~| @73
|[+1#0000000&|N|o| |N|a|m|e|]| |[|+|]| @43|3|,|1| @11|A|l@1
|/+0&&> @73

View File

@@ -5,8 +5,8 @@
|4| @24|╔+0#0000001#ffd7ff255|═@19|╗| +0#0000000#ffffff0@26
|5| @24|║+0#0000001#ffd7ff255|a|n|o|t|h|e|r| |t|e|x|t| @7|║| +0#0000000#ffffff0@26
|6| @24|║+0#0000001#ffd7ff255|t|o| |s|h|o|w| @12|║| +0#0000000#ffffff0@26
|7| @24|║+0#0000001#ffd7ff255|i|n| |a| |p|o|p|u|p| |w|i|n|d|o|w| @2|║| +0#0000000#ffffff0@26
|8| @24|║+0#0000001#ffd7ff255| +0#4040ff13&> @18|║+0#0000001&| +0#0000000#ffffff0@26
|7| @24|║+0#0000001#ffd7ff255>i|n| |a| |p|o|p|u|p| |w|i|n|d|o|w| @2|║| +0#0000000#ffffff0@26
|8| @24|║+0#0000001#ffd7ff255| +0#4040ff13&@19|║+0#0000001&| +0#0000000#ffffff0@26
|9| @24|║+0#0000001#ffd7ff255| +0#4040ff13&@19|║+0#0000001&| +0#0000000#ffffff0@26
|1|0| @23|╚+0#0000001#ffd7ff255|═@19|╝| +0#0000000#ffffff0@26
|1@1| @72

View File

@@ -36,7 +36,7 @@ func ReadXnetbeans()
let l = readfile("Xnetbeans")
" Xnetbeans may include '0:geometry=' messages in the GUI Vim if the window
" position, size, or z order are changed. Remove these messages because
" these message will break the assert for the output.
" these messages will break the assert for the output.
return filter(l, 'v:val !~ "^0:geometry="')
endfunc
@@ -927,7 +927,7 @@ endfunc
" error.
func Test_nb_bwipe_buffer()
call s:run_server('Nb_bwipe_buffer')
%bwipe!
silent! %bwipe!
sleep 100m
nbclose
endfunc

View File

@@ -3243,6 +3243,10 @@ func Get_popupmenu_lines()
call popup_show(id)
endif
endfunc
" Check that no autocommands are triggered for the info popup
au WinEnter * if win_gettype() == 'popup' | call setline(2, 'WinEnter') | endif
au WinLeave * if win_gettype() == 'popup' | call setline(2, 'WinLeave') | endif
END
return lines
endfunc

View File

@@ -3091,6 +3091,66 @@ func Test_resize_from_copen()
endtry
endfunc
func Test_vimgrep_with_textlock()
new
" Simple way to execute something with "textwinlock" set.
" Check that vimgrep without jumping can be executed.
au InsertCharPre * vimgrep /RunTheTest/j runtest.vim
normal ax
let qflist = getqflist()
call assert_true(len(qflist) > 0)
call assert_match('RunTheTest', qflist[0].text)
call setqflist([], 'r')
au! InsertCharPre
" Check that vimgrepadd without jumping can be executed.
au InsertCharPre * vimgrepadd /RunTheTest/j runtest.vim
normal ax
let qflist = getqflist()
call assert_true(len(qflist) > 0)
call assert_match('RunTheTest', qflist[0].text)
call setqflist([], 'r')
au! InsertCharPre
" Check that lvimgrep without jumping can be executed.
au InsertCharPre * lvimgrep /RunTheTest/j runtest.vim
normal ax
let qflist = getloclist(0)
call assert_true(len(qflist) > 0)
call assert_match('RunTheTest', qflist[0].text)
call setloclist(0, [], 'r')
au! InsertCharPre
" Check that lvimgrepadd without jumping can be executed.
au InsertCharPre * lvimgrepadd /RunTheTest/j runtest.vim
normal ax
let qflist = getloclist(0)
call assert_true(len(qflist) > 0)
call assert_match('RunTheTest', qflist[0].text)
call setloclist(0, [], 'r')
au! InsertCharPre
" trying to jump will give an error
au InsertCharPre * vimgrep /RunTheTest/ runtest.vim
call assert_fails('normal ax', 'E565:')
au! InsertCharPre
au InsertCharPre * vimgrepadd /RunTheTest/ runtest.vim
call assert_fails('normal ax', 'E565:')
au! InsertCharPre
au InsertCharPre * lvimgrep /RunTheTest/ runtest.vim
call assert_fails('normal ax', 'E565:')
au! InsertCharPre
au InsertCharPre * lvimgrepadd /RunTheTest/ runtest.vim
call assert_fails('normal ax', 'E565:')
au! InsertCharPre
bwipe!
endfunc
" Tests for the quickfix buffer b:changedtick variable
func Xchangedtick_tests(cchar)
call s:setup_commands(a:cchar)

View File

@@ -1200,7 +1200,76 @@ func Test_terminal_open_autocmd()
unlet s:called
au! repro
endfunction
endfunc
func Test_open_term_from_cmd()
CheckUnix
CheckRunVimInTerminal
let lines =<< trim END
call setline(1, ['a', 'b', 'c'])
3
set incsearch
cnoremap <F3> <Cmd>call term_start(['/bin/sh', '-c', ':'])<CR>
END
call writefile(lines, 'Xopenterm')
let buf = RunVimInTerminal('-S Xopenterm', {})
" this opens a window, incsearch should not use the old cursor position
call term_sendkeys(buf, "/\<F3>")
call VerifyScreenDump(buf, 'Test_terminal_from_cmd', {})
call term_sendkeys(buf, "\<Esc>")
call term_sendkeys(buf, ":q\<CR>")
call StopVimInTerminal(buf)
call delete('Xopenterm')
endfunc
func Test_terminal_popup_with_cmd()
" this was crashing
let buf = term_start(&shell, #{hidden: v:true})
let s:winid = popup_create(buf, {})
tnoremap <F3> <Cmd>call popup_close(s:winid)<CR>
call feedkeys("\<F3>", 'xt')
tunmap <F3>
exe 'bwipe! ' .. buf
unlet s:winid
endfunc
func Test_terminal_popup_bufload()
let termbuf = term_start(&shell, #{hidden: v:true, term_finish: 'close'})
let winid = popup_create(termbuf, {})
sleep 50m
let newbuf = bufadd('')
call bufload(newbuf)
call setbufline(newbuf, 1, 'foobar')
" must not have switched to another window
call assert_equal(winid, win_getid())
call StopShellInTerminal(termbuf)
call WaitFor({-> win_getid() != winid})
exe 'bwipe! ' .. newbuf
endfunc
func Test_terminal_popup_insert_cmd()
CheckUnix
inoremap <F3> <Cmd>call StartTermInPopup()<CR>
func StartTermInPopup()
call term_start(['/bin/sh', '-c', 'cat'], #{hidden: v:true, term_finish: 'close'})->popup_create(#{highlight: 'Pmenu'})
endfunc
call feedkeys("i\<F3>")
sleep 10m
call assert_equal('n', mode())
call feedkeys("\<C-D>", 'xt')
sleep 50m
delfunc StartTermInPopup
iunmap <F3>
endfunc
func Check_dump01(off)
call assert_equal('one two three four five', trim(getline(a:off + 1)))

View File

@@ -408,6 +408,15 @@ def Test_assignment_dict()
# overwrite
dict3['key'] = 'another'
assert_equal(dict3, #{key: 'another'})
dict3.key = 'yet another'
assert_equal(dict3, #{key: 'yet another'})
var lines =<< trim END
var dd = #{one: 1}
dd.one) = 2
END
CheckDefFailure(lines, 'E15:', 2)
# empty key can be used
var dd = {}
@@ -418,7 +427,7 @@ def Test_assignment_dict()
var somedict = rand() > 0 ? #{a: 1, b: 2} : #{a: 'a', b: 'b'}
# assignment to script-local dict
var lines =<< trim END
lines =<< trim END
vim9script
var test: dict<any> = {}
def FillDict(): dict<any>

View File

@@ -195,10 +195,16 @@ def Test_extend_arg_types()
assert_equal([1, 2, 3], extend([1, 2], [3]))
assert_equal([3, 1, 2], extend([1, 2], [3], 0))
assert_equal([1, 3, 2], extend([1, 2], [3], 1))
assert_equal([1, 3, 2], extend([1, 2], [3], s:number_one))
assert_equal(#{a: 1, b: 2, c: 3}, extend(#{a: 1, b: 2}, #{c: 3}))
assert_equal(#{a: 1, b: 4}, extend(#{a: 1, b: 2}, #{b: 4}))
assert_equal(#{a: 1, b: 2}, extend(#{a: 1, b: 2}, #{b: 4}, 'keep'))
assert_equal(#{a: 1, b: 2}, extend(#{a: 1, b: 2}, #{b: 4}, s:string_keep))
var res: list<dict<any>>
extend(res, map([1, 2], {_, v -> {}}))
assert_equal([{}, {}], res)
CheckDefFailure(['extend([1, 2], 3)'], 'E1013: Argument 2: type mismatch, expected list<number> but got number')
CheckDefFailure(['extend([1, 2], ["x"])'], 'E1013: Argument 2: type mismatch, expected list<number> but got list<string>')
@@ -338,6 +344,10 @@ def Test_index()
index(['a', 'b', 'a', 'B'], 'b', 2, true)->assert_equal(3)
enddef
let s:number_one = 1
let s:number_two = 2
let s:string_keep = 'keep'
def Test_insert()
var l = insert([2, 1], 3)
var res = 0
@@ -347,9 +357,12 @@ def Test_insert()
res->assert_equal(6)
assert_equal([1, 2, 3], insert([2, 3], 1))
assert_equal([1, 2, 3], insert([2, 3], s:number_one))
assert_equal([1, 2, 3], insert([1, 2], 3, 2))
assert_equal([1, 2, 3], insert([1, 2], 3, s:number_two))
assert_equal(['a', 'b', 'c'], insert(['b', 'c'], 'a'))
assert_equal(0z1234, insert(0z34, 0x12))
CheckDefFailure(['insert([2, 3], "a")'], 'E1013: Argument 2: type mismatch, expected number but got string', 1)
CheckDefFailure(['insert([2, 3], 1, "x")'], 'E1013: Argument 3: type mismatch, expected number but got string', 1)
enddef

View File

@@ -567,11 +567,14 @@ def Test_expr4_equal()
assert_equal(false, function('g:Test_expr4_equal', [123]) == function('g:Test_expr4_is', [123]))
assert_equal(false, function('g:Test_expr4_equal', [123]) == function('g:Test_expr4_equal', [999]))
var OneFunc: func
var TwoFunc: func
OneFunc = function('len')
TwoFunc = function('len')
assert_equal(true, OneFunc('abc') == TwoFunc('123'))
# TODO: this unexpectedly sometimes fails on Appveyor
if !has('win32')
var OneFunc: func
var TwoFunc: func
OneFunc = function('len')
TwoFunc = function('len')
assert_equal(true, OneFunc('abc') == TwoFunc('123'))
endif
END
CheckDefAndScriptSuccess(lines)

View File

@@ -49,6 +49,36 @@ def TestCompilingError()
call delete('XTest_compile_error')
enddef
def CallRecursive(n: number): number
return CallRecursive(n + 1)
enddef
def CallMapRecursive(l: list<number>): number
return map(l, {_, v -> CallMapRecursive([v])})[0]
enddef
def Test_funcdepth_error()
set maxfuncdepth=10
var caught = false
try
CallRecursive(1)
catch /E132:/
caught = true
endtry
assert_true(caught)
caught = false
try
CallMapRecursive([1])
catch /E132:/
caught = true
endtry
assert_true(caught)
set maxfuncdepth&
enddef
def ReturnString(): string
return 'string'
enddef
@@ -1426,6 +1456,15 @@ def Test_nested_lambda()
CheckScriptSuccess(lines)
enddef
def Shadowed(): list<number>
var FuncList: list<func: number> = [{ -> 42}]
return FuncList->map({_, Shadowed -> Shadowed()})
enddef
def Test_lambda_arg_shadows_func()
assert_equal([42], Shadowed())
enddef
def Line_continuation_in_def(dir: string = ''): string
var path: string = empty(dir)
\ ? 'empty'

View File

@@ -1373,6 +1373,50 @@ failed:
func_clear_free(fp, TRUE);
}
static int funcdepth = 0;
/*
* Increment the function call depth count.
* Return FAIL when going over 'maxfuncdepth'.
* Otherwise return OK, must call funcdepth_decrement() later!
*/
int
funcdepth_increment(void)
{
if (funcdepth >= p_mfd)
{
emsg(_("E132: Function call depth is higher than 'maxfuncdepth'"));
return FAIL;
}
++funcdepth;
return OK;
}
void
funcdepth_decrement(void)
{
--funcdepth;
}
/*
* Get the current function call depth.
*/
int
funcdepth_get(void)
{
return funcdepth;
}
/*
* Restore the function call depth. This is for cases where there is no
* garantee funcdepth_decrement() can be called exactly the same number of
* times as funcdepth_increment().
*/
void
funcdepth_restore(int depth)
{
funcdepth = depth;
}
/*
* Call a user function.
@@ -1391,7 +1435,6 @@ call_user_func(
funccall_T *fc;
int save_did_emsg;
int default_arg_err = FALSE;
static int depth = 0;
dictitem_T *v;
int fixvar_idx = 0; // index in fixvar[]
int i;
@@ -1406,15 +1449,13 @@ call_user_func(
#endif
ESTACK_CHECK_DECLARATION
// If depth of calling is getting too high, don't execute the function
if (depth >= p_mfd)
// If depth of calling is getting too high, don't execute the function.
if (funcdepth_increment() == FAIL)
{
emsg(_("E132: Function call depth is higher than 'maxfuncdepth'"));
rettv->v_type = VAR_NUMBER;
rettv->vval.v_number = -1;
return;
}
++depth;
line_breakcheck(); // check for CTRL-C hit
@@ -1437,7 +1478,7 @@ call_user_func(
{
// Execute the function, possibly compiling it first.
call_def_function(fp, argcount, argvars, funcexe->partial, rettv);
--depth;
funcdepth_decrement();
current_funccal = fc->caller;
free_funccal(fc);
return;
@@ -1783,8 +1824,7 @@ call_user_func(
}
did_emsg |= save_did_emsg;
--depth;
funcdepth_decrement();
cleanup_function_call(fc);
}

View File

@@ -750,6 +750,48 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2003,
/**/
2002,
/**/
2001,
/**/
2000,
/**/
1999,
/**/
1998,
/**/
1997,
/**/
1996,
/**/
1995,
/**/
1994,
/**/
1993,
/**/
1992,
/**/
1991,
/**/
1990,
/**/
1989,
/**/
1988,
/**/
1987,
/**/
1986,
/**/
1985,
/**/
1984,
/**/
1983,
/**/
1982,
/**/

View File

@@ -820,7 +820,7 @@ generate_TYPECHECK(
* Return TRUE if "actual" could be "expected" and a runtime typecheck is to be
* used. Return FALSE if the types will never match.
*/
static int
int
use_typecheck(type_T *actual, type_T *expected)
{
if (actual->tt_type == VAR_ANY
@@ -2712,13 +2712,19 @@ compile_call(
goto theend;
}
// If we can find the function by name generate the right call.
// Skip global functions here, a local funcref takes precedence.
ufunc = find_func(name, FALSE, cctx);
if (ufunc != NULL && !func_is_global(ufunc))
// An argument or local variable can be a function reference, this
// overrules a function name.
if (lookup_local(namebuf, varlen, cctx) == NULL
&& arg_exists(namebuf, varlen, NULL, NULL, NULL, cctx) != OK)
{
res = generate_CALL(cctx, ufunc, argcount);
goto theend;
// If we can find the function by name generate the right call.
// Skip global functions here, a local funcref takes precedence.
ufunc = find_func(name, FALSE, cctx);
if (ufunc != NULL && !func_is_global(ufunc))
{
res = generate_CALL(cctx, ufunc, argcount);
goto theend;
}
}
// If the name is a variable, load it and use PCALL.
@@ -5384,14 +5390,14 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
member_type = type;
if (var_end > var_start + varlen)
{
// Something follows after the variable: "var[idx]".
// Something follows after the variable: "var[idx]" or "var.key".
if (is_decl)
{
emsg(_(e_cannot_use_index_when_declaring_variable));
goto theend;
}
if (var_start[varlen] == '[')
if (var_start[varlen] == '[' || var_start[varlen] == '.')
{
has_index = TRUE;
if (type->tt_member == NULL)
@@ -5635,21 +5641,33 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
{
int r;
// Compile the "idx" in "var[idx]".
// Compile the "idx" in "var[idx]" or "key" in "var.key".
if (new_local)
--cctx->ctx_locals.ga_len;
p = skipwhite(var_start + varlen + 1);
r = compile_expr0(&p, cctx);
p = var_start + varlen;
if (*p == '[')
{
p = skipwhite(p + 1);
r = compile_expr0(&p, cctx);
if (r == OK && *skipwhite(p) != ']')
{
// this should not happen
emsg(_(e_missbrac));
r = FAIL;
}
}
else // if (*p == '.')
{
char_u *key_end = to_name_end(p + 1, TRUE);
char_u *key = vim_strnsave(p + 1, key_end - p - 1);
r = generate_PUSHS(cctx, key);
}
if (new_local)
++cctx->ctx_locals.ga_len;
if (r == FAIL)
goto theend;
if (*skipwhite(p) != ']')
{
// this should not happen
emsg(_(e_missbrac));
goto theend;
}
if (type == &t_any)
{
type_T *idx_type = ((type_T **)stack->ga_data)[

View File

@@ -227,6 +227,10 @@ call_dfunc(int cdf_idx, int argcount_arg, ectx_T *ectx)
== FAIL)
return FAIL;
// If depth of calling is getting too high, don't execute the function.
if (funcdepth_increment() == FAIL)
return FAIL;
// Move the vararg-list to below the missing optional arguments.
if (vararg_count > 0 && arg_to_add > 0)
*STACK_TV_BOT(arg_to_add - 1) = *STACK_TV_BOT(-1);
@@ -503,6 +507,7 @@ func_return(ectx_T *ectx)
ectx->ec_stack.ga_len = top + 1;
*STACK_TV_BOT(-1) = *STACK_TV(idx);
funcdepth_decrement();
return OK;
}
@@ -835,6 +840,7 @@ call_def_function(
cmdmod_T save_cmdmod;
int restore_cmdmod = FALSE;
int trylevel_at_start = trylevel;
int orig_funcdepth;
// Get pointer to item in the stack.
#define STACK_TV(idx) (((typval_T *)ectx.ec_stack.ga_data) + idx)
@@ -870,11 +876,19 @@ call_def_function(
}
}
// If depth of calling is getting too high, don't execute the function.
orig_funcdepth = funcdepth_get();
if (funcdepth_increment() == FAIL)
return FAIL;
CLEAR_FIELD(ectx);
ectx.ec_dfunc_idx = ufunc->uf_dfunc_idx;
ga_init2(&ectx.ec_stack, sizeof(typval_T), 500);
if (ga_grow(&ectx.ec_stack, 20) == FAIL)
{
funcdepth_decrement();
return FAIL;
}
ga_init2(&ectx.ec_trystack, sizeof(trycmd_T), 10);
ga_init2(&ectx.ec_funcrefs, sizeof(partial_T *), 10);
@@ -2941,6 +2955,7 @@ failed_early:
if (ret != OK && did_emsg == did_emsg_before)
semsg(_(e_unknown_error_while_executing_str),
printable_func_name(ufunc));
funcdepth_restore(orig_funcdepth);
return ret;
}

View File

@@ -516,6 +516,20 @@ check_type(type_T *expected, type_T *actual, int give_msg, int argidx)
return ret;
}
/*
* Like check_type() but also allow for a runtime type check. E.g. "any" can be
* used for "number".
*/
int
check_arg_type(type_T *expected, type_T *actual, int argidx)
{
if (check_type(expected, actual, FALSE, 0) == OK
|| use_typecheck(actual, expected))
return OK;
// TODO: should generate a TYPECHECK instruction.
return check_type(expected, actual, TRUE, argidx);
}
/*
* Skip over a type definition and return a pointer to just after it.
* When "optional" is TRUE then a leading "?" is accepted.

View File

@@ -1462,6 +1462,7 @@ win_valid(win_T *win)
/*
* Find window "id" in the current tab page.
* Also find popup windows.
* Return NULL if not found.
*/
win_T *
@@ -1472,6 +1473,14 @@ win_find_by_id(int id)
FOR_ALL_WINDOWS(wp)
if (wp->w_id == id)
return wp;
#ifdef FEAT_PROP_POPUP
FOR_ALL_POPUPWINS(wp)
if (wp->w_id == id)
return wp;
FOR_ALL_POPUPWINS_IN_TAB(curtab, wp)
if (wp->w_id == id)
return wp;
#endif
return NULL;
}