Compare commits

..

16 Commits

Author SHA1 Message Date
Bram Moolenaar
e7a74d5375 patch 8.2.4591: cursor line not updated when a callback moves the cursor
Problem:    Cursor line not updated when a callback moves the cursor.
Solution:   Check if the cursor moved. (closes #9970)
2022-03-19 11:10:15 +00:00
Bram Moolenaar
2995e5cf4e patch 8.2.4590: Vim9: range type check has wrong offset
Problem:    Vim9: range type check has wrong offset.
Solution:   Adjust offset for CHECKTYPE.  Remove other type check.
2022-03-18 21:41:47 +00:00
Bram Moolenaar
2e17fef225 patch 8.2.4589: cannot index the g: dictionary
Problem:    Cannot index the g: dictionary.
Solution:   Recognize using "g:[key]". (closes #9969)
2022-03-18 19:44:48 +00:00
Bram Moolenaar
f35fd8e5d4 patch 8.2.4588: mapping with key after other matching mapping does not work
Problem:    Mapping with key code after other matching mapping does not work.
Solution:   Change ">" to ">=". (closes #9903)
2022-03-18 15:41:17 +00:00
Bram Moolenaar
61efa16932 patch 8.2.4587: Vim9: double free after unpacking a list
Problem:    Vim9: double free after unpacking a list.
Solution:   Make a copy of the value instead of moving it. (closes #9968)
2022-03-18 13:10:48 +00:00
Bram Moolenaar
1d9cef769d patch 8.2.4586: Vim9: no error for using lower case name for "func" argument
Problem:    Vim9: no error for using lower case name for "func" argument.
            (Ernie Rael)
Solution:   Check the name as soon as the type is known.
2022-03-17 16:30:03 +00:00
Yegappan Lakshmanan
155b088208 patch 8.2.4585: cannot use keypad page-up/down for completion menu
Problem:    Cannot use keypad page-up/down for completion menu.
Solution:   Recognize the keypad keys. (Yegappan Lakshmanan, closes #9963)
2022-03-17 13:03:09 +00:00
Bram Moolenaar
da6d42c35a patch 8.2.4584: error for using autoload function in custom completion
Problem:    Error for using autoload function in custom completion.
Solution:   Do not check for errors when using an autoload function.
            (closes #9962)
2022-03-17 11:46:55 +00:00
Bram Moolenaar
4f6e772c9c patch 8.2.4583: screendump test fails
Problem:    Screendump test fails.
Solution:   Check that making a screendump is possible.
2022-03-16 20:26:02 +00:00
Bram Moolenaar
4c8b546da2 patch 8.2.4582: useless code handling a type declaration
Problem:    Useless code handling a type declaration.
Solution:   Remove the code and give an error.
2022-03-16 20:01:39 +00:00
Bram Moolenaar
d597ab00d7 patch 8.2.4581: null types not fully tested
Problem:    Null types not fully tested.
Solution:   Add some more tests using null types.
2022-03-16 17:56:33 +00:00
Bram Moolenaar
21dc8f1527 patch 8.2.4580: Vim9: incorrect error for shadowing variable
Problem:    Vim9: incorrect error for shadowing variable.
Solution:   Do not pass the context when compiling a referenced function.
2022-03-16 17:54:17 +00:00
Yegappan Lakshmanan
5cffa8df7e patch 8.2.4579: cannot use page-up and page-down in the cmdline popup menu
Problem:    Cannot use page-up and page-down in the command line completion
            popup menu.
Solution:   Check for to page-up and page-down keys. (Yegappan Lakshmanan,
            closes #9960)
2022-03-16 13:33:53 +00:00
Bram Moolenaar
fe8e9f6740 patch 8.2.4578: no warning when autoload script for completion has an error
Problem:    No warning when an autoload script for completion function has an
            error.
Solution:   Do not ignore errors when a function name is given with a dot or
            '#' character. (closes #9958)
2022-03-16 13:09:15 +00:00
Bram Moolenaar
9323ca51c2 patch 8.2.4577: message test is flaky
Problem:    Message test is flaky. (Elimar Riesebieter)
Solution:   Trigger the autocommand event only after startup is finished.
2022-03-16 11:14:57 +00:00
Bram Moolenaar
056678184f patch 8.2.4576: Vim9: error for comparing with null can be annoying
Problem:    Vim9: error for comparing with null can be annoying.
Solution:   Allow comparing anything with null. (closes #9948)
2022-03-15 20:21:33 +00:00
37 changed files with 597 additions and 179 deletions

View File

@@ -224,7 +224,8 @@ nextwild(
i = (int)(xp->xp_pattern - ccline->cmdbuff);
xp->xp_pattern_len = ccline->cmdpos - i;
if (type == WILD_NEXT || type == WILD_PREV)
if (type == WILD_NEXT || type == WILD_PREV
|| type == WILD_PAGEUP || type == WILD_PAGEDOWN)
{
// Get next/previous match for a previous expanded pattern.
p2 = ExpandOne(xp, NULL, NULL, 0, type);
@@ -404,7 +405,7 @@ int cmdline_compl_startcol(void)
/*
* Get the next or prev cmdline completion match. The index of the match is set
* in 'p_findex'
* in "p_findex"
*/
static char_u *
get_next_or_prev_match(
@@ -414,6 +415,7 @@ get_next_or_prev_match(
char_u *orig_save)
{
int findex = *p_findex;
int ht;
if (xp->xp_numfiles <= 0)
return NULL;
@@ -424,11 +426,50 @@ get_next_or_prev_match(
findex = xp->xp_numfiles;
--findex;
}
else // mode == WILD_NEXT
else if (mode == WILD_NEXT)
++findex;
else if (mode == WILD_PAGEUP)
{
if (findex == 0)
// at the first entry, don't select any entries
findex = -1;
else if (findex == -1)
// no entry is selected. select the last entry
findex = xp->xp_numfiles - 1;
else
{
// go up by the pum height
ht = pum_get_height();
if (ht > 3)
ht -= 2;
findex -= ht;
if (findex < 0)
// few entries left, select the first entry
findex = 0;
}
}
else // mode == WILD_PAGEDOWN
{
if (findex == xp->xp_numfiles - 1)
// at the last entry, don't select any entries
findex = -1;
else if (findex == -1)
// no entry is selected. select the first entry
findex = 0;
else
{
// go down by the pum height
ht = pum_get_height();
if (ht > 3)
ht -= 2;
findex += ht;
if (findex >= xp->xp_numfiles)
// few entries left, select the last entry
findex = xp->xp_numfiles - 1;
}
}
// When wrapping around, return the original string, set findex to
// -1.
// When wrapping around, return the original string, set findex to -1.
if (findex < 0)
{
if (orig_save == NULL)
@@ -585,7 +626,7 @@ find_longest_match(expand_T *xp, int options)
}
/*
* Do wildcard expansion on the string 'str'.
* Do wildcard expansion on the string "str".
* Chars that should not be expanded must be preceded with a backslash.
* Return a pointer to allocated memory containing the new string.
* Return NULL for failure.
@@ -639,7 +680,8 @@ ExpandOne(
long_u len;
// first handle the case of using an old match
if (mode == WILD_NEXT || mode == WILD_PREV)
if (mode == WILD_NEXT || mode == WILD_PREV
|| mode == WILD_PAGEUP || mode == WILD_PAGEDOWN)
return get_next_or_prev_match(mode, xp, &findex, orig_save);
if (mode == WILD_CANCEL)

View File

@@ -1463,11 +1463,14 @@ win_update(win_T *wp)
#ifdef FEAT_SYN_HL
// remember what happened to the previous line, to know if
// check_visual_highlight() can be used
#define DID_NONE 1 // didn't update a line
#define DID_LINE 2 // updated a normal line
#define DID_FOLD 3 // updated a folded line
# define DID_NONE 1 // didn't update a line
# define DID_LINE 2 // updated a normal line
# define DID_FOLD 3 // updated a folded line
int did_update = DID_NONE;
linenr_T syntax_last_parsed = 0; // last parsed text line
// remember the current w_last_cursorline, it changes when drawing the new
// cursor line
linenr_T last_cursorline = wp->w_last_cursorline;
#endif
linenr_T mod_top = 0;
linenr_T mod_bot = 0;
@@ -2244,7 +2247,7 @@ win_update(win_T *wp)
))))
#ifdef FEAT_SYN_HL
|| (wp->w_p_cul && (lnum == wp->w_cursor.lnum
|| lnum == wp->w_last_cursorline))
|| lnum == last_cursorline))
#endif
)
{
@@ -3027,6 +3030,23 @@ redraw_asap(int type)
}
#endif
#if defined(FEAT_SYN_HL) || defined(PROTO)
/*
* Check if the cursor moved and 'cursorline' is set. Mark for a VALID redraw
* if needed.
*/
void
check_redraw_cursorline(void)
{
// When 'cursorlineopt' is "screenline" need to redraw always.
if (curwin->w_p_cul
&& (curwin->w_last_cursorline != curwin->w_cursor.lnum
|| (curwin->w_p_culopt_flags & CULOPT_SCRLINE))
&& !char_avail())
redraw_later(VALID);
}
#endif
/*
* Invoked after an asynchronous callback is called.
* If an echo command was used the cursor needs to be put back where
@@ -3071,6 +3091,10 @@ redraw_after_callback(int call_update_screen, int do_message)
}
else if (State & (NORMAL | INSERT | TERMINAL))
{
#ifdef FEAT_SYN_HL
// might need to update for 'cursorline'
check_redraw_cursorline();
#endif
// keep the command line if possible
update_screen(VALID_NO_UPDATE);
setcursor();

View File

@@ -3252,4 +3252,6 @@ EXTERN char e_cannot_use_s_backslash_in_vim9_script[]
#ifdef FEAT_EVAL
EXTERN char e_compiling_closure_without_context_str[]
INIT(= N_("E1271: compiling closure without context: %s"));
EXTERN char e_using_type_not_in_script_context_str[]
INIT(= N_("E1272: Using type not in a script context: %s"));
#endif

View File

@@ -695,6 +695,7 @@ call_vim_function(
char_u *arg;
char_u *name;
char_u *tofree = NULL;
int ignore_errors;
rettv->v_type = VAR_UNKNOWN; // clear_tv() uses this
CLEAR_FIELD(funcexe);
@@ -702,11 +703,17 @@ call_vim_function(
funcexe.fe_lastline = curwin->w_cursor.lnum;
funcexe.fe_evaluate = TRUE;
// The name might be "import.Func" or "Funcref".
// The name might be "import.Func" or "Funcref". We don't know, we need to
// ignore errors for an undefined name. But we do want errors when an
// autoload script has errors. Guess that when there is a dot in the name
// showing errors is the right choice.
ignore_errors = vim_strchr(func, '.') == NULL;
arg = func;
++emsg_off;
if (ignore_errors)
++emsg_off;
name = deref_function_name(&arg, &tofree, &EVALARG_EVALUATE, FALSE);
--emsg_off;
if (ignore_errors)
--emsg_off;
if (name == NULL)
name = func;
@@ -922,15 +929,14 @@ get_lval(
if (vim9script)
{
// "a: type" is declaring variable "a" with a type, not "a:".
if (p == name + 2 && p[-1] == ':')
// However, "g:[key]" is indexing a dictionary.
if (p == name + 2 && p[-1] == ':' && *p != '[')
{
--p;
lp->ll_name_end = p;
}
if (*p == ':')
{
garray_T tmp_type_list;
garray_T *type_list;
char_u *tp = skipwhite(p + 1);
if (tp == p + 1 && !quiet)
@@ -939,27 +945,19 @@ get_lval(
return NULL;
}
if (SCRIPT_ID_VALID(current_sctx.sc_sid))
type_list = &SCRIPT_ITEM(current_sctx.sc_sid)->sn_type_list;
else
if (!SCRIPT_ID_VALID(current_sctx.sc_sid))
{
// TODO: should we give an error here?
type_list = &tmp_type_list;
ga_init2(type_list, sizeof(type_T), 10);
semsg(_(e_using_type_not_in_script_context_str), p);
return NULL;
}
// parse the type after the name
lp->ll_type = parse_type(&tp, type_list, !quiet);
lp->ll_type = parse_type(&tp,
&SCRIPT_ITEM(current_sctx.sc_sid)->sn_type_list,
!quiet);
if (lp->ll_type == NULL && !quiet)
return NULL;
lp->ll_name_end = tp;
// drop the type when not in a script
if (type_list == &tmp_type_list)
{
lp->ll_type = NULL;
clear_type_list(type_list);
}
}
}
}

View File

@@ -3523,12 +3523,14 @@ find_ex_command(
return eap->cmd;
}
if (p != eap->cmd && (
if ((p != eap->cmd && (
// "varname[]" is an expression.
*p == '['
// "varname.key" is an expression.
|| (*p == '.' && (ASCII_ISALPHA(p[1])
|| p[1] == '_'))))
|| (*p == '.'
&& (ASCII_ISALPHA(p[1]) || p[1] == '_'))))
// g:[key] is an expression
|| STRNCMP(eap->cmd, "g:[", 3) == 0)
{
char_u *after = eap->cmd;

View File

@@ -1606,6 +1606,7 @@ getcmdline_int(
cmdline_info_T save_ccline;
int did_save_ccline = FALSE;
int cmdline_type;
int wild_type;
if (ccline.cmdbuff != NULL)
{
@@ -1757,6 +1758,7 @@ getcmdline_int(
for (;;)
{
int trigger_cmdlinechanged = TRUE;
int end_wildmenu;
redir_off = TRUE; // Don't redirect the typed command.
// Repeated, because a ":redir" inside
@@ -1866,10 +1868,7 @@ getcmdline_int(
// text.
if (c == Ctrl_E || c == Ctrl_Y)
{
int wild_type;
wild_type = (c == Ctrl_E) ? WILD_CANCEL : WILD_APPLY;
if (nextwild(&xpc, wild_type, WILD_NO_BEEP,
firstc != '@') == FAIL)
break;
@@ -1878,10 +1877,21 @@ getcmdline_int(
}
#endif
// The wildmenu is cleared if the pressed key is not used for
// navigating the wild menu (i.e. the key is not 'wildchar' or
// 'wildcharm' or Ctrl-N or Ctrl-P or Ctrl-A or Ctrl-L).
// If the popup menu is displayed, then PageDown and PageUp keys are
// also used to navigate the menu.
end_wildmenu = (!(c == p_wc && KeyTyped) && c != p_wcm
&& c != Ctrl_N && c != Ctrl_P && c != Ctrl_A && c != Ctrl_L);
#ifdef FEAT_WILDMENU
end_wildmenu = end_wildmenu && (!cmdline_pum_active() ||
(c != K_PAGEDOWN && c != K_PAGEUP
&& c != K_KPAGEDOWN && c != K_KPAGEUP));
#endif
// free expanded names when finished walking through matches
if (!(c == p_wc && KeyTyped) && c != p_wcm
&& c != Ctrl_N && c != Ctrl_P && c != Ctrl_A
&& c != Ctrl_L)
if (end_wildmenu)
{
#ifdef FEAT_WILDMENU
if (cmdline_pum_active())
@@ -2292,8 +2302,8 @@ getcmdline_int(
case Ctrl_P: // previous match
if (xpc.xp_numfiles > 0)
{
if (nextwild(&xpc, (c == Ctrl_P) ? WILD_PREV : WILD_NEXT,
0, firstc != '@') == FAIL)
wild_type = (c == Ctrl_P) ? WILD_PREV : WILD_NEXT;
if (nextwild(&xpc, wild_type, 0, firstc != '@') == FAIL)
break;
goto cmdline_not_changed;
}
@@ -2306,12 +2316,30 @@ getcmdline_int(
case K_KPAGEUP:
case K_PAGEDOWN:
case K_KPAGEDOWN:
res = cmdline_browse_history(c, firstc, &lookfor, histype,
&hiscnt, &xpc);
if (res == CMDLINE_CHANGED)
goto cmdline_changed;
else if (res == GOTO_NORMAL_MODE)
goto returncmd;
#ifdef FEAT_WILDMENU
if (cmdline_pum_active()
&& (c == K_PAGEUP || c == K_PAGEDOWN ||
c == K_KPAGEUP || c == K_KPAGEDOWN))
{
// If the popup menu is displayed, then PageUp and PageDown
// are used to scroll the menu.
wild_type = WILD_PAGEUP;
if (c == K_PAGEDOWN || c == K_KPAGEDOWN)
wild_type = WILD_PAGEDOWN;
if (nextwild(&xpc, wild_type, 0, firstc != '@') == FAIL)
break;
goto cmdline_not_changed;
}
else
#endif
{
res = cmdline_browse_history(c, firstc, &lookfor, histype,
&hiscnt, &xpc);
if (res == CMDLINE_CHANGED)
goto cmdline_changed;
else if (res == GOTO_NORMAL_MODE)
goto returncmd;
}
goto cmdline_not_changed;
#ifdef FEAT_SEARCH_EXTRA

View File

@@ -2416,6 +2416,7 @@ handle_mapping(
mapblock_T *mp_match;
int mp_match_len = 0;
int max_mlen = 0;
int want_termcode = 0; // 1 if termcode expected after max_mlen
int tb_c1;
int mlen;
#ifdef FEAT_LANGMAP
@@ -2591,9 +2592,16 @@ handle_mapping(
}
else
// No match; may have to check for termcode at next
// character.
// character. If the first character that didn't match is
// K_SPECIAL then check for a termcode. This isn't perfect
// but should work in most cases.
if (max_mlen < mlen)
{
max_mlen = mlen;
want_termcode = mp->m_keys[mlen] == K_SPECIAL;
}
else if (max_mlen == mlen && mp->m_keys[mlen] == K_SPECIAL)
want_termcode = 1;
}
}
@@ -2646,7 +2654,7 @@ handle_mapping(
// May check for a terminal code when there is no mapping or only a partial
// mapping. Also check if there is a full mapping with <Esc>, unless timed
// out, since that is nearly always a partial match with a terminal code.
if ((mp == NULL || max_mlen > mp_match_len
if ((mp == NULL || max_mlen + want_termcode > mp_match_len
|| (mp_match_len == 1 && *mp->m_keys == ESC && !*timedout))
&& keylen != KEYLEN_PART_MAP)
{

View File

@@ -1386,12 +1386,7 @@ main_loop(
#ifdef FEAT_SYN_HL
// Might need to update for 'cursorline'.
// When 'cursorlineopt' is "screenline" need to redraw always.
if (curwin->w_p_cul
&& (curwin->w_last_cursorline != curwin->w_cursor.lnum
|| (curwin->w_p_culopt_flags & CULOPT_SCRLINE))
&& !char_avail())
redraw_later(VALID);
check_redraw_cursorline();
#endif
if (VIsual_active)
update_curbuf(INVERTED); // update inverted part

View File

@@ -8,6 +8,7 @@ void update_curbuf(int type);
void update_debug_sign(buf_T *buf, linenr_T lnum);
void updateWindow(win_T *wp);
int redraw_asap(int type);
void check_redraw_cursorline(void);
void redraw_after_callback(int call_update_screen, int do_message);
void redraw_later(int type);
void redraw_win_later(win_T *wp, int type);

View File

@@ -509,7 +509,7 @@ spell_suggest(int count)
// make sure we don't include the NUL at the end of the line
line = ml_get_curline();
if (badlen > (int)STRLEN(line) - (int)curwin->w_cursor.col)
badlen = STRLEN(line) - curwin->w_cursor.col;
badlen = (int)STRLEN(line) - (int)curwin->w_cursor.col;
}
// Find the start of the badly spelled word.
else if (spell_move_to(curwin, FORWARD, TRUE, TRUE, NULL) == 0

View File

@@ -0,0 +1,8 @@
|a+0&#ffffff0@4| @69
>b+8&&@4| @69
|c+0&&@4| @69
|d@4| @69
|~+0#4040ff13&| @73
|~| @73
|~| @73
| +0#0000000&@56|4|,|1| @10|A|l@1|

View File

@@ -0,0 +1,6 @@
|~+0#4040ff13#ffffff0| @73
|~| @73
|~| @73
|~| @73
|E+0#ffffff16#e000002|1|2|7|2|:| |U|s|i|n|g| |t|y|p|e| |n|o|t| |i|n| |a| |s|c|r|i|p|t| |c|o|n|t|e|x|t|:| |:| |s|t|r|i|n|g| +0#0000000#ffffff0@23
|P+0#00e0003&|r|e|s@1| |E|N|T|E|R| |o|r| |t|y|p|e| |c|o|m@1|a|n|d| |t|o| |c|o|n|t|i|n|u|e> +0#0000000&@35

View File

@@ -0,0 +1,10 @@
| +0&#ffffff0@74
|~+0#4040ff13&| @73
|~| @73
|~| @3| +0#0000001#ffd7ff255|d|e|f|i|n|e| @8| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|j|u|m|p| @10| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|l|i|s|t| @10| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|p|l|a|c|e| @9| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#e0e0e08|u|n|d|e|f|i|n|e| @6| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|u|n|p|l|a|c|e| @7| +0#4040ff13#ffffff0@53
|:+0#0000000&|s|i|g|n| |u|n|d|e|f|i|n|e> @60

View File

@@ -0,0 +1,10 @@
| +0&#ffffff0@74
|~+0#4040ff13&| @73
|~| @73
|~| @3| +0#0000001#ffd7ff255|d|e|f|i|n|e| @8| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|j|u|m|p| @10| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|l|i|s|t| @10| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|p|l|a|c|e| @9| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|u|n|d|e|f|i|n|e| @6| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#e0e0e08|u|n|p|l|a|c|e| @7| +0#4040ff13#ffffff0@53
|:+0#0000000&|s|i|g|n| |u|n|p|l|a|c|e> @61

View File

@@ -0,0 +1,10 @@
| +0&#ffffff0@74
|~+0#4040ff13&| @73
|~| @73
|~| @3| +0#0000001#ffd7ff255|d|e|f|i|n|e| @8| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|j|u|m|p| @10| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|l|i|s|t| @10| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|p|l|a|c|e| @9| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|u|n|d|e|f|i|n|e| @6| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|u|n|p|l|a|c|e| @7| +0#4040ff13#ffffff0@53
|:+0#0000000&|s|i|g|n| > @68

View File

@@ -0,0 +1,10 @@
| +0&#ffffff0@74
|~+0#4040ff13&| @73
|~| @73
|~| @3| +0#0000001#e0e0e08|d|e|f|i|n|e| @8| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|j|u|m|p| @10| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|l|i|s|t| @10| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|p|l|a|c|e| @9| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|u|n|d|e|f|i|n|e| @6| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|u|n|p|l|a|c|e| @7| +0#4040ff13#ffffff0@53
|:+0#0000000&|s|i|g|n| |d|e|f|i|n|e> @62

View File

@@ -0,0 +1,10 @@
| +0&#ffffff0@74
|~+0#4040ff13&| @73
|~| @73
|~| @3| +0#0000001#ffd7ff255|d|e|f|i|n|e| @8| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|j|u|m|p| @10| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|l|i|s|t| @10| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|p|l|a|c|e| @9| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|u|n|d|e|f|i|n|e| @6| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#e0e0e08|u|n|p|l|a|c|e| @7| +0#4040ff13#ffffff0@53
|:+0#0000000&|s|i|g|n| |u|n|p|l|a|c|e> @61

View File

@@ -0,0 +1,10 @@
| +0&#ffffff0@74
|~+0#4040ff13&| @73
|~| @73
|~| @3| +0#0000001#ffd7ff255|d|e|f|i|n|e| @8| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|j|u|m|p| @10| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|l|i|s|t| @10| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|p|l|a|c|e| @9| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|u|n|d|e|f|i|n|e| @6| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|u|n|p|l|a|c|e| @7| +0#4040ff13#ffffff0@53
|:+0#0000000&|s|i|g|n| > @68

View File

@@ -0,0 +1,10 @@
| +0&#ffffff0@74
|~+0#4040ff13&| @73
|~| @73
|~| @3| +0#0000001#ffd7ff255|d|e|f|i|n|e| @8| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|j|u|m|p| @10| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|l|i|s|t| @10| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|p|l|a|c|e| @9| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|u|n|d|e|f|i|n|e| @6| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#e0e0e08|u|n|p|l|a|c|e| @7| +0#4040ff13#ffffff0@53
|:+0#0000000&|s|i|g|n| |u|n|p|l|a|c|e> @61

View File

@@ -0,0 +1,10 @@
| +0&#ffffff0@74
|~+0#4040ff13&| @73
|~| @73
|~| @3| +0#0000001#ffd7ff255|d|e|f|i|n|e| @8| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#e0e0e08|j|u|m|p| @10| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|l|i|s|t| @10| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|p|l|a|c|e| @9| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|u|n|d|e|f|i|n|e| @6| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|u|n|p|l|a|c|e| @7| +0#4040ff13#ffffff0@53
|:+0#0000000&|s|i|g|n| |j|u|m|p> @64

View File

@@ -0,0 +1,10 @@
| +0&#ffffff0@74
|~+0#4040ff13&| @73
|~| @73
|~| @3| +0#0000001#e0e0e08|d|e|f|i|n|e| @8| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|j|u|m|p| @10| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|l|i|s|t| @10| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|p|l|a|c|e| @9| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|u|n|d|e|f|i|n|e| @6| +0#4040ff13#ffffff0@53
|~| @3| +0#0000001#ffd7ff255|u|n|p|l|a|c|e| @7| +0#4040ff13#ffffff0@53
|:+0#0000000&|s|i|g|n| |d|e|f|i|n|e> @62

View File

@@ -4,6 +4,7 @@ source check.vim
source screendump.vim
source view_util.vim
source shared.vim
import './vim9.vim' as v9
func SetUp()
func SaveLastScreenLine()
@@ -151,6 +152,14 @@ func Test_complete_wildmenu()
call assert_equal('"e Xdir1/Xdir2/1', @:)
cunmap <F2>
" Test for canceling the wild menu by pressing <PageDown> or <PageUp>.
" After this pressing <Left> or <Right> should not change the selection.
call feedkeys(":sign \<Tab>\<PageDown>\<Left>\<Right>\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"sign define', @:)
call histadd('cmd', 'TestWildMenu')
call feedkeys(":sign \<Tab>\<PageUp>\<Left>\<Right>\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"TestWildMenu', @:)
" cleanup
%bwipe
call delete('Xdir1', 'rf')
@@ -543,6 +552,32 @@ func Test_getcompletion()
call assert_fails('call getcompletion("abc", [])', 'E475:')
endfunc
func Test_complete_autoload_error()
let save_rtp = &rtp
let lines =<< trim END
vim9script
export def Complete(..._): string
return 'match'
enddef
echo this will cause an error
END
call mkdir('Xdir/autoload', 'p')
call writefile(lines, 'Xdir/autoload/script.vim')
exe 'set rtp+=' .. getcwd() .. '/Xdir'
let lines =<< trim END
vim9script
import autoload 'script.vim'
command -nargs=* -complete=custom,script.Complete Cmd eval 0 + 0
&wildcharm = char2nr("\<Tab>")
feedkeys(":Cmd \<Tab>", 'xt')
END
call v9.CheckScriptFailure(lines, 'E121: Undefined variable: this')
let &rtp = save_rtp
call delete('Xdir', 'rf')
endfunc
func Test_fullcommand()
let tests = {
\ '': '',
@@ -1794,6 +1829,29 @@ func Test_wildmode()
let &encoding = save_encoding
endfunc
func Test_custom_complete_autoload()
call mkdir('Xdir/autoload', 'p')
let save_rtp = &rtp
exe 'set rtp=' .. getcwd() .. '/Xdir'
let lines =<< trim END
func vim8#Complete(a, c, p)
return "oneA\noneB\noneC"
endfunc
END
call writefile(lines, 'Xdir/autoload/vim8.vim')
command -nargs=1 -complete=custom,vim8#Complete MyCmd
set nowildmenu
set wildmode=full,list
call feedkeys(":MyCmd \<C-A>\<C-B>\"\<CR>", 'xt')
call assert_equal('"MyCmd oneA oneB oneC', @:)
let &rtp = save_rtp
set wildmode& wildmenu&
delcommand MyCmd
call delete('Xdir', 'rf')
endfunc
" Test for interrupting the command-line completion
func Test_interrupt_compl()
func F(lead, cmdl, p)
@@ -2048,7 +2106,8 @@ func Test_wildmenu_dirstack()
endfunc
" Test for recalling newer or older cmdline from history with <Up>, <Down>,
" <S-Up>, <S-Down>, <PageUp>, <PageDown>, <C-p>, or <C-n>.
" <S-Up>, <S-Down>, <PageUp>, <PageDown>, <kPageUp>, <kPageDown>, <C-p>, or
" <C-n>.
func Test_recalling_cmdline()
CheckFeature cmdline_hist
@@ -2056,17 +2115,18 @@ func Test_recalling_cmdline()
cnoremap <Plug>(save-cmdline) <Cmd>let g:cmdlines += [getcmdline()]<CR>
let histories = [
\ {'name': 'cmd', 'enter': ':', 'exit': "\<Esc>"},
\ {'name': 'search', 'enter': '/', 'exit': "\<Esc>"},
\ {'name': 'expr', 'enter': ":\<C-r>=", 'exit': "\<Esc>\<Esc>"},
\ {'name': 'input', 'enter': ":call input('')\<CR>", 'exit': "\<CR>"},
\ #{name: 'cmd', enter: ':', exit: "\<Esc>"},
\ #{name: 'search', enter: '/', exit: "\<Esc>"},
\ #{name: 'expr', enter: ":\<C-r>=", exit: "\<Esc>\<Esc>"},
\ #{name: 'input', enter: ":call input('')\<CR>", exit: "\<CR>"},
"\ TODO: {'name': 'debug', ...}
\]
let keypairs = [
\ {'older': "\<Up>", 'newer': "\<Down>", 'prefixmatch': v:true},
\ {'older': "\<S-Up>", 'newer': "\<S-Down>", 'prefixmatch': v:false},
\ {'older': "\<PageUp>", 'newer': "\<PageDown>", 'prefixmatch': v:false},
\ {'older': "\<C-p>", 'newer': "\<C-n>", 'prefixmatch': v:false},
\ #{older: "\<Up>", newer: "\<Down>", prefixmatch: v:true},
\ #{older: "\<S-Up>", newer: "\<S-Down>", prefixmatch: v:false},
\ #{older: "\<PageUp>", newer: "\<PageDown>", prefixmatch: v:false},
\ #{older: "\<kPageUp>", newer: "\<kPageDown>", prefixmatch: v:false},
\ #{older: "\<C-p>", newer: "\<C-n>", prefixmatch: v:false},
\]
let prefix = 'vi'
for h in histories
@@ -2389,6 +2449,28 @@ func Test_wildmenu_pum()
call VerifyScreenDump(buf, 'Test_wildmenu_pum_41', {})
call term_sendkeys(buf, "\<Esc>")
" Pressing <PageDown> should scroll the menu downward
call term_sendkeys(buf, ":sign \<Tab>\<PageDown>")
call VerifyScreenDump(buf, 'Test_wildmenu_pum_42', {})
call term_sendkeys(buf, "\<PageDown>")
call VerifyScreenDump(buf, 'Test_wildmenu_pum_43', {})
call term_sendkeys(buf, "\<PageDown>")
call VerifyScreenDump(buf, 'Test_wildmenu_pum_44', {})
call term_sendkeys(buf, "\<PageDown>")
call VerifyScreenDump(buf, 'Test_wildmenu_pum_45', {})
call term_sendkeys(buf, "\<C-U>sign \<Tab>\<Down>\<Down>\<PageDown>")
call VerifyScreenDump(buf, 'Test_wildmenu_pum_46', {})
" Pressing <PageUp> should scroll the menu upward
call term_sendkeys(buf, "\<C-U>sign \<Tab>\<PageUp>")
call VerifyScreenDump(buf, 'Test_wildmenu_pum_47', {})
call term_sendkeys(buf, "\<PageUp>")
call VerifyScreenDump(buf, 'Test_wildmenu_pum_48', {})
call term_sendkeys(buf, "\<PageUp>")
call VerifyScreenDump(buf, 'Test_wildmenu_pum_49', {})
call term_sendkeys(buf, "\<PageUp>")
call VerifyScreenDump(buf, 'Test_wildmenu_pum_50', {})
call term_sendkeys(buf, "\<C-U>\<CR>")
call StopVimInTerminal(buf)
call delete('Xtest')
@@ -2671,8 +2753,7 @@ func Test_fuzzy_completion_userdefined_snr_func()
endfunc
set wildoptions=fuzzy
call feedkeys(":call sendmail\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"call SendSomemail() S1e2n3dmail() '
\ .. expand("<SID>") .. 'Sendmail()', @:)
call assert_match('"call SendSomemail() S1e2n3dmail() <SNR>\d\+_Sendmail()', @:)
set wildoptions&
delfunc s:Sendmail
delfunc SendSomemail

View File

@@ -247,4 +247,30 @@ END
call delete('Xtextfile')
endfunc
func Test_cursorline_callback()
CheckScreendump
CheckFeature timers
let lines =<< trim END
call setline(1, ['aaaaa', 'bbbbb', 'ccccc', 'ddddd'])
set cursorline
call cursor(4, 1)
func Func(timer)
call cursor(2, 1)
endfunc
call timer_start(300, 'Func')
END
call writefile(lines, 'Xcul_timer')
let buf = RunVimInTerminal('-S Xcul_timer', #{rows: 8})
call TermWait(buf, 310)
call VerifyScreenDump(buf, 'Test_cursorline_callback_1', {})
call StopVimInTerminal(buf)
call delete('Xcul_timer')
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -360,12 +360,13 @@ func Test_fileinfo_after_echo()
hide buffer a.txt
set updatetime=1
autocmd CursorHold * b b.txt | w | echo "'b' written"
autocmd CursorHold * buf b.txt | w | echo "'b' written"
END
call writefile(content, 'Xtest_fileinfo_after_echo')
let buf = RunVimInTerminal('-S Xtest_fileinfo_after_echo', #{rows: 6})
call term_sendkeys(buf, ":set updatetime=50\<CR>")
call term_sendkeys(buf, "0$")
call VerifyScreenDump(buf, 'Test_fileinfo_after_echo', {})
call term_sendkeys(buf, ":q\<CR>")

View File

@@ -2111,6 +2111,15 @@ func Test_modifyOtherKeys_ambiguous_mapping()
unmap <C-J>
unmap <C-J>x
" if a special character is following there should be a check for a termcode
nnoremap s aX<Esc>
nnoremap s<BS> aY<Esc>
set t_kb=
call setline(1, 'x')
call feedkeys("s\x08", 'Lx!')
call assert_equal('xY', getline(1))
set timeoutlen&
bwipe!
endfunc

View File

@@ -1116,6 +1116,14 @@ def Test_assignment_dict()
END
v9.CheckDefAndScriptSuccess(lines)
lines =<< trim END
var key = 'foo'
g:[key] = 'value'
assert_equal('value', g:foo)
unlet g:foo
END
v9.CheckDefAndScriptSuccess(lines)
lines =<< trim END
var dd = {one: 1}
dd.one) = 2
@@ -1594,7 +1602,7 @@ def Test_assign_list()
l[g:idx : 1] = [0]
echo l
END
v9.CheckDefExecAndScriptFailure(lines, 'E1030: Using a String as a Number: "x"')
v9.CheckDefExecAndScriptFailure(lines, ['E1012: Type mismatch; expected number but got string', 'E1030: Using a String as a Number: "x"'])
lines =<< trim END
var l = [1, 2]

View File

@@ -716,6 +716,35 @@ def Test_expr4_compare_null()
g:null_dict = test_null_dict()
g:not_null_list = []
var lines =<< trim END
assert_false(true == null)
assert_false(false == null)
assert_false(null == true)
assert_false(null == false)
assert_true(true != null)
assert_true(false != null)
assert_true(null != true)
assert_true(null != false)
assert_false(123 == null)
assert_false(0 == null)
assert_false(null == 123)
assert_false(null == 0)
assert_true(123 != null)
assert_true(0 != null)
assert_true(null != 123)
assert_true(null != 0)
if has('float')
assert_false(12.3 == null)
assert_false(0.0 == null)
assert_false(null == 12.3)
assert_false(null == 0.0)
assert_true(12.3 != null)
assert_true(0.0 != null)
assert_true(null != 12.3)
assert_true(null != 0.0)
endif
assert_true(test_null_blob() == v:null)
assert_true(null_blob == null)
assert_true(v:null == test_null_blob())
@@ -818,16 +847,6 @@ def Test_expr4_compare_null()
assert_equal(null_function, d.f)
END
v9.CheckDefAndScriptSuccess(lines)
v9.CheckDefAndScriptFailure(['echo 123 == v:null'], 'E1072: Cannot compare number with special')
v9.CheckDefAndScriptFailure(['echo v:null == 123'], 'E1072: Cannot compare special with number')
v9.CheckDefAndScriptFailure(['echo 123 != v:null'], 'E1072: Cannot compare number with special')
v9.CheckDefAndScriptFailure(['echo v:null != 123'], 'E1072: Cannot compare special with number')
v9.CheckDefAndScriptFailure(['echo true == v:null'], 'E1072: Cannot compare bool with special')
v9.CheckDefAndScriptFailure(['echo v:null == true'], 'E1072: Cannot compare special with bool')
v9.CheckDefAndScriptFailure(['echo true != v:null'], 'E1072: Cannot compare bool with special')
v9.CheckDefAndScriptFailure(['echo v:null != true'], 'E1072: Cannot compare special with bool')
v9.CheckDefAndScriptFailure(['echo false == v:null'], 'E1072: Cannot compare bool with special')
enddef
def Test_expr4_compare_none()
@@ -2072,6 +2091,11 @@ def Test_expr8_list()
var llstring: list<list<string>> = [['text'], []]
llstring = [[], ['text']]
llstring = [[], []]
var ls = [null_string]
assert_equal('list<string>', typename(ls))
var lb = [null_blob]
assert_equal('list<blob>', typename(lb))
END
v9.CheckDefAndScriptSuccess(lines)
@@ -2589,6 +2613,11 @@ def Test_expr8_dict()
# comment to start fold is OK
var x1: number #{{ fold
var x2 = 9 #{{ fold
var ds = {k: null_string}
assert_equal('dict<string>', typename(ds))
var dl = {a: null_list}
assert_equal('dict<list<unknown>>', typename(dl))
END
v9.CheckDefAndScriptSuccess(lines)

View File

@@ -1479,12 +1479,12 @@ def Test_pass_legacy_lambda_to_def_func()
lines =<< trim END
vim9script
def g:TestFunc(f: func)
def g:TestFunc(F: func)
enddef
legacy call g:TestFunc({-> 0})
delfunc g:TestFunc
def g:TestFunc(f: func(number))
def g:TestFunc(F: func(number))
enddef
legacy call g:TestFunc({nr -> 0})
delfunc g:TestFunc
@@ -2999,6 +2999,24 @@ def Test_lambda_arg_shadows_func()
assert_equal([42], g:Shadowed())
enddef
def Test_compiling_referenced_func_no_shadow()
var lines =<< trim END
vim9script
def InitializeReply(lspserver: dict<any>)
enddef
def ProcessReply(lspserver: dict<any>)
var lsp_reply_handlers: dict<func> =
{ 'initialize': InitializeReply }
lsp_reply_handlers['initialize'](lspserver)
enddef
call ProcessReply({})
END
v9.CheckScriptSuccess(lines)
enddef
def s:Line_continuation_in_def(dir: string = ''): string
var path: string = empty(dir)
\ ? 'empty'
@@ -3770,8 +3788,8 @@ def Test_check_func_arg_types()
return x + 1
enddef
def G(g: func): dict<func>
return {f: g}
def G(Fg: func): dict<func>
return {f: Fg}
enddef
def H(d: dict<func>): string
@@ -3781,6 +3799,8 @@ def Test_check_func_arg_types()
v9.CheckScriptSuccess(lines + ['echo H(G(F1))'])
v9.CheckScriptFailure(lines + ['echo H(G(F2))'], 'E1013:')
v9.CheckScriptFailure(lines + ['def SomeFunc(ff: func)', 'enddef'], 'E704:')
enddef
def Test_call_func_with_null()

View File

@@ -2253,6 +2253,13 @@ def Test_for_loop_unpack()
res->add(n)
endfor
assert_equal([2, 5], res)
var text: list<string> = ["hello there", "goodbye now"]
var splitted = ''
for [first; next] in mapnew(text, (i, v) => split(v))
splitted ..= string(first) .. string(next) .. '/'
endfor
assert_equal("'hello'['there']/'goodbye'['now']/", splitted)
END
v9.CheckDefAndScriptSuccess(lines)
@@ -3942,10 +3949,6 @@ def Test_profile_with_lambda()
enddef
def Profile()
profile start Xprofile.log
profile func ProfiledWithLambda
# mark ProfiledNested for profiling to avoid E1271
profile func ProfiledNested
ProfiledWithLambda()
ProfiledNested()
@@ -3957,8 +3960,20 @@ def Test_profile_with_lambda()
profdel func *
profile pause
enddef
Profile()
writefile(['done'], 'Xdidprofile')
var result = 'done'
try
# mark functions for profiling now to avoid E1271
profile start Xprofile.log
profile func ProfiledWithLambda
profile func ProfiledNested
Profile()
catch
result = 'failed: ' .. v:exception
finally
writefile([result], 'Xdidprofile')
endtry
END
writefile(lines, 'Xprofile.vim')
call system(g:GetVimCommand()
@@ -3974,6 +3989,21 @@ def Test_profile_with_lambda()
delete('Xprofile.vim')
enddef
func Test_misplaced_type()
CheckRunVimInTerminal
call Run_Test_misplaced_type()
endfunc
def Run_Test_misplaced_type()
writefile(['let g:somevar = "asdf"'], 'XTest_misplaced_type')
var buf = g:RunVimInTerminal('-S XTest_misplaced_type', {'rows': 6})
term_sendkeys(buf, ":vim9cmd echo islocked('g:somevar: string')\<CR>")
g:VerifyScreenDump(buf, 'Test_misplaced_type', {})
g:StopVimInTerminal(buf)
delete('XTest_misplaced_type')
enddef
" Keep this last, it messes up highlighting.
def Test_substitute_cmd()
new

View File

@@ -1417,12 +1417,9 @@ typval_compare_null(typval_T *tv1, typval_T *tv2)
default: break;
}
}
if (!in_vim9script())
return FALSE; // backwards compatible
semsg(_(e_cannot_compare_str_with_str),
vartype_name(tv1->v_type), vartype_name(tv2->v_type));
return MAYBE;
// although comparing null with number, float or bool is not very usefule
// we won't give an error
return FALSE;
}
/*

View File

@@ -429,6 +429,12 @@ parse_argument_types(ufunc_T *fp, garray_T *argtypes, int varargs)
if (type == NULL)
return FAIL;
fp->uf_arg_types[i] = type;
if (i < fp->uf_args.ga_len
&& (type->tt_type == VAR_FUNC
|| type->tt_type == VAR_PARTIAL)
&& var_wrong_func_name(
((char_u **)fp->uf_args.ga_data)[i], TRUE))
return FAIL;
}
}
}

View File

@@ -750,6 +750,38 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4591,
/**/
4590,
/**/
4589,
/**/
4588,
/**/
4587,
/**/
4586,
/**/
4585,
/**/
4584,
/**/
4583,
/**/
4582,
/**/
4581,
/**/
4580,
/**/
4579,
/**/
4578,
/**/
4577,
/**/
4576,
/**/
4575,
/**/

View File

@@ -818,6 +818,8 @@ extern int (*dyn_libintl_wputenv)(const wchar_t *envstring);
#define WILD_ALL_KEEP 8
#define WILD_CANCEL 9
#define WILD_APPLY 10
#define WILD_PAGEUP 11
#define WILD_PAGEDOWN 12
#define WILD_LIST_NOTFOUND 0x01
#define WILD_HOME_REPLACE 0x02

View File

@@ -1000,7 +1000,12 @@ generate_loadvar(
break;
case dest_global:
if (vim_strchr(name, AUTOLOAD_CHAR) == NULL)
generate_LOAD(cctx, ISN_LOADG, 0, name + 2, type);
{
if (name[2] == NUL)
generate_instr_type(cctx, ISN_LOADGDICT, &t_dict_any);
else
generate_LOAD(cctx, ISN_LOADG, 0, name + 2, type);
}
else
generate_LOAD(cctx, ISN_LOADAUTO, 0, name, type);
break;
@@ -1797,7 +1802,7 @@ compile_assign_unlet(
{
type = get_type_on_stack(cctx, 1);
if (need_type(type, &t_number,
-1, 0, cctx, FALSE, FALSE) == FAIL)
-2, 0, cctx, FALSE, FALSE) == FAIL)
return FAIL;
}
type = get_type_on_stack(cctx, 0);
@@ -2413,17 +2418,19 @@ may_compile_assignment(exarg_T *eap, char_u **line, cctx_T *cctx)
// Recognize an assignment if we recognize the variable
// name:
// "g:var = expr"
// "local = expr" where "local" is a local var.
// "script = expr" where "script" is a script-local var.
// "import = expr" where "import" is an imported var
// "&opt = expr"
// "$ENV = expr"
// "@r = expr"
// "g:var = expr"
// "g:[key] = expr"
// "local = expr" where "local" is a local var.
// "script = expr" where "script" is a script-local var.
// "import = expr" where "import" is an imported var
if (*eap->cmd == '&'
|| *eap->cmd == '$'
|| *eap->cmd == '@'
|| ((len) > 2 && eap->cmd[1] == ':')
|| STRNCMP(eap->cmd, "g:[", 3) == 0
|| variable_exists(eap->cmd, len, cctx))
{
*line = compile_assignment(eap->cmd, eap, CMD_SIZE, cctx);

View File

@@ -1896,79 +1896,54 @@ execute_storerange(isn_T *iptr, ectx_T *ectx)
SOURCING_LNUM = iptr->isn_lnum;
if (tv_dest->v_type == VAR_LIST)
{
long n1;
long n2;
int error = FALSE;
long n1;
long n2;
listitem_T *li1;
n1 = (long)tv_get_number_chk(tv_idx1, &error);
if (error)
n1 = (long)tv_get_number_chk(tv_idx1, NULL);
if (tv_idx2->v_type == VAR_SPECIAL
&& tv_idx2->vval.v_number == VVAL_NONE)
n2 = list_len(tv_dest->vval.v_list) - 1;
else
n2 = (long)tv_get_number_chk(tv_idx2, NULL);
li1 = check_range_index_one(tv_dest->vval.v_list, &n1, FALSE);
if (li1 == NULL)
status = FAIL;
else
{
if (tv_idx2->v_type == VAR_SPECIAL
&& tv_idx2->vval.v_number == VVAL_NONE)
n2 = list_len(tv_dest->vval.v_list) - 1;
else
n2 = (long)tv_get_number_chk(tv_idx2, &error);
if (error)
status = FAIL; // cannot happen?
else
{
listitem_T *li1 = check_range_index_one(
tv_dest->vval.v_list, &n1, FALSE);
if (li1 == NULL)
status = FAIL;
else
{
status = check_range_index_two(
tv_dest->vval.v_list,
&n1, li1, &n2, FALSE);
if (status != FAIL)
status = list_assign_range(
tv_dest->vval.v_list,
tv->vval.v_list,
n1,
n2,
tv_idx2->v_type == VAR_SPECIAL,
(char_u *)"=",
(char_u *)"[unknown]");
}
}
status = check_range_index_two(tv_dest->vval.v_list,
&n1, li1, &n2, FALSE);
if (status != FAIL)
status = list_assign_range(
tv_dest->vval.v_list,
tv->vval.v_list,
n1,
n2,
tv_idx2->v_type == VAR_SPECIAL,
(char_u *)"=",
(char_u *)"[unknown]");
}
}
else if (tv_dest->v_type == VAR_BLOB)
{
varnumber_T n1;
varnumber_T n2;
int error = FALSE;
long bloblen;
n1 = tv_get_number_chk(tv_idx1, &error);
if (error)
n1 = tv_get_number_chk(tv_idx1, NULL);
if (tv_idx2->v_type == VAR_SPECIAL
&& tv_idx2->vval.v_number == VVAL_NONE)
n2 = blob_len(tv_dest->vval.v_blob) - 1;
else
n2 = tv_get_number_chk(tv_idx2, NULL);
bloblen = blob_len(tv_dest->vval.v_blob);
if (check_blob_index(bloblen, n1, FALSE) == FAIL
|| check_blob_range(bloblen, n1, n2, FALSE) == FAIL)
status = FAIL;
else
{
if (tv_idx2->v_type == VAR_SPECIAL
&& tv_idx2->vval.v_number == VVAL_NONE)
n2 = blob_len(tv_dest->vval.v_blob) - 1;
else
n2 = tv_get_number_chk(tv_idx2, &error);
if (error)
status = FAIL;
else
{
long bloblen = blob_len(tv_dest->vval.v_blob);
if (check_blob_index(bloblen,
n1, FALSE) == FAIL
|| check_blob_range(bloblen,
n1, n2, FALSE) == FAIL)
status = FAIL;
else
status = blob_set_range(
tv_dest->vval.v_blob, n1, n2, tv);
}
}
status = blob_set_range(tv_dest->vval.v_blob, n1, n2, tv);
}
else
{
@@ -4773,7 +4748,10 @@ exec_instructions(ectx_T *ectx)
li = li->li_next;
for (i = 0; li != NULL; ++i)
{
list_set_item(rem_list, i, &li->li_tv);
typval_T tvcopy;
copy_tv(&li->li_tv, &tvcopy);
list_set_item(rem_list, i, &tvcopy);
li = li->li_next;
}
--count;

View File

@@ -364,7 +364,7 @@ generate_funcref(cctx_T *cctx, char_u *name, int has_g_prefix)
// Need to compile any default values to get the argument types.
compile_type = get_compile_type(ufunc);
if (func_needs_compiling(ufunc, compile_type)
&& compile_def_function(ufunc, TRUE, compile_type, cctx) == FAIL)
&& compile_def_function(ufunc, TRUE, compile_type, NULL) == FAIL)
return FAIL;
return generate_PUSHFUNC(cctx, ufunc->uf_name, ufunc->uf_func_type);
}

View File

@@ -397,20 +397,8 @@ get_compare_isn(
vartype_name(vartype1), vartype_name(vartype2));
return ISN_DROP;
}
switch (vartype1 == VAR_SPECIAL ? vartype2 : vartype1)
{
case VAR_BLOB: break;
case VAR_CHANNEL: break;
case VAR_DICT: break;
case VAR_FUNC: break;
case VAR_JOB: break;
case VAR_LIST: break;
case VAR_PARTIAL: break;
case VAR_STRING: break;
default: semsg(_(e_cannot_compare_str_with_str),
vartype_name(vartype1), vartype_name(vartype2));
return ISN_DROP;
}
// although comparing null with number, float or bool is not useful, we
// allow it
isntype = ISN_COMPARENULL;
}