Compare commits

...

12 Commits

Author SHA1 Message Date
Bram Moolenaar
6914e87d3c patch 8.2.2575: Vim9: a function name with "->" in the next line doesn't work
Problem:    Vim9: a function name with "->" in the next line doesn't work.
Solution:   Recognize a function name by itself. (closes #7770)
2021-03-06 21:01:09 +01:00
Bram Moolenaar
04947cc6ed patch 8.2.2574: Vim9: crash when calling partial with wrong function
Problem:    Vim9: crash when calling partial with wrong function.
Solution:   Check argument types of called function. (closes #7912)
2021-03-06 19:26:46 +01:00
Bram Moolenaar
a974953443 patch 8.2.2573: Vim9: using inalid pointer for error message
Problem:    Vim9: using inalid pointer for error message.
Solution:   Use the right pointer. (closes #7921)
2021-03-06 18:18:19 +01:00
Bram Moolenaar
18062fcad6 patch 8.2.2572: Vim9: crash when getting the types for a legacy function
Problem:    Vim9: crash when getting the types for a legacy function.
Solution:   Initialize the type list growarray. (closes #7929)
2021-03-05 21:35:47 +01:00
Bram Moolenaar
8c801b374b patch 8.2.2571: test may leave file behind
Problem:    Test may leave file behind.
Solution:   Delete the temporary file.  Don't profile in the running Vim
            instance.
2021-03-05 20:58:22 +01:00
Bram Moolenaar
f9a65505d1 patch 8.2.2570: tests fail when run as root
Problem:    Tests fail when run as root.
Solution:   Add a comment mentioning the expected failure. (issue #7919)
2021-03-05 20:47:44 +01:00
Bram Moolenaar
008bff967f patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Problem:    'fillchars' "stl" and "stlnc" items must be single byte.
Solution:   Accept multi-byte characters. (Christian Wellenbrock, Yegappan
            Lakshmanan, closes #7927)
2021-03-04 21:55:58 +01:00
Bram Moolenaar
6057748a1a patch 8.2.2568: second time a preview popup is opened highlight is not set
Problem:    Second time a preview popup is opened highlight is not set.
            (Gabriel Dupras)
Solution:   Apply 'previewpopup' after getting the file. (closes #7928)
2021-03-04 21:35:07 +01:00
Bram Moolenaar
6c3843ca8a patch 8.2.2567: Vim9: no error if variable is defined for existing function
Problem:    Vim9: no error if variable is defined for existing function.
Solution:   Check if name isn't already in use. (closes #7897)
2021-03-04 12:38:21 +01:00
Bram Moolenaar
2e2d758902 patch 8.2.2566: Vim9: Function name is not recognized
Problem:    Vim9: Function name is not recognized.
Solution:   Change lookup_scriptvar() to also find function names.
            (closes #7770)
2021-03-03 21:22:41 +01:00
Bram Moolenaar
f76ec1eeb5 patch 8.2.2565: Vim9: "..=" not always recognized
Problem:    Vim9: "..=" not always recognized.
Solution:   Do not consider "..=" to be string concatenation. (closes #7905)
2021-03-03 17:58:16 +01:00
Bram Moolenaar
51b477f74f patch 8.2.2564: focus events end Insert mode if 'esckeys' is not set
Problem:    Focus events end Insert mode if 'esckeys' is not set.
Solution:   Do not enable focus events when 'esckeys' is off. (closes #7926)
2021-03-03 15:24:28 +01:00
32 changed files with 397 additions and 72 deletions

View File

@@ -3262,7 +3262,8 @@ A jump table for the options with a short description can be found at |Q_op|.
< This is similar to the default, except that these characters will also
be used when there is highlighting.
for "stl" and "stlnc" only single-byte values are supported.
For "stl" and "stlnc" single-byte and multibyte characters are
supported. But double-width characters are not supported.
The highlighting used for these items:
item highlight group ~

View File

@@ -4157,9 +4157,6 @@ build_stl_str_hl(
if (fillchar == 0)
fillchar = ' ';
// Can't handle a multi-byte fill character yet.
else if (mb_char2len(fillchar) > 1)
fillchar = '-';
// The cursor in windows other than the current one isn't always
// up-to-date, esp. because of autocommands and timers.
@@ -4335,7 +4332,7 @@ build_stl_str_hl(
// Fill up space left over by half a double-wide char.
while (++l < stl_items[stl_groupitem[groupdepth]].stl_minwid)
*p++ = fillchar;
MB_CHAR2BYTES(fillchar, p);
// correct the start of the items for the truncation
for (l = stl_groupitem[groupdepth] + 1; l < curitem; l++)
@@ -4354,20 +4351,20 @@ build_stl_str_hl(
// fill by appending characters
n = 0 - n;
while (l++ < n && p + 1 < out + outlen)
*p++ = fillchar;
MB_CHAR2BYTES(fillchar, p);
}
else
{
// fill by inserting characters
mch_memmove(t + n - l, t, (size_t)(p - t));
l = n - l;
l = (n - l) * MB_CHAR2LEN(fillchar);
mch_memmove(t + l, t, (size_t)(p - t));
if (p + l >= out + outlen)
l = (long)((out + outlen) - p - 1);
p += l;
for (n = stl_groupitem[groupdepth] + 1; n < curitem; n++)
stl_items[n].stl_start += l;
for ( ; l > 0; l--)
*t++ = fillchar;
MB_CHAR2BYTES(fillchar, t);
}
}
continue;
@@ -4746,23 +4743,24 @@ build_stl_str_hl(
if (l + 1 == minwid && fillchar == '-' && VIM_ISDIGIT(*t))
*p++ = ' ';
else
*p++ = fillchar;
MB_CHAR2BYTES(fillchar, p);
}
minwid = 0;
}
else
minwid *= -1;
while (*t && p + 1 < out + outlen)
for (; *t && p + 1 < out + outlen; t++)
{
*p++ = *t++;
// Change a space by fillchar, unless fillchar is '-' and a
// digit follows.
if (fillable && p[-1] == ' '
&& (!VIM_ISDIGIT(*t) || fillchar != '-'))
p[-1] = fillchar;
if (fillable && *t == ' '
&& (!VIM_ISDIGIT(*(t + 1)) || fillchar != '-'))
MB_CHAR2BYTES(fillchar, p);
else
*p++ = *t;
}
for (; l < minwid && p + 1 < out + outlen; l++)
*p++ = fillchar;
MB_CHAR2BYTES(fillchar, p);
}
else if (num >= 0)
{
@@ -4865,7 +4863,7 @@ build_stl_str_hl(
}
// Fill up for half a double-wide character.
while (++width < maxwidth)
*s++ = fillchar;
MB_CHAR2BYTES(fillchar, s);
}
else
s = out + maxwidth - 1;
@@ -4897,7 +4895,7 @@ build_stl_str_hl(
while (++width < maxwidth)
{
s = s + STRLEN(s);
*s++ = fillchar;
MB_CHAR2BYTES(fillchar, s);
*s = NUL;
}
@@ -4920,12 +4918,13 @@ build_stl_str_hl(
break;
if (l < itemcnt)
{
p = stl_items[l].stl_start + maxwidth - width;
int middlelength = (maxwidth - width) * MB_CHAR2LEN(fillchar);
p = stl_items[l].stl_start + middlelength;
STRMOVE(p, stl_items[l].stl_start);
for (s = stl_items[l].stl_start; s < p; s++)
*s = fillchar;
for (s = stl_items[l].stl_start; s < p;)
MB_CHAR2BYTES(fillchar, s);
for (l++; l < itemcnt; l++)
stl_items[l].stl_start += maxwidth - width;
stl_items[l].stl_start += middlelength;
width = maxwidth;
}
}

View File

@@ -2849,11 +2849,12 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
int vim9script = in_vim9script();
// "." is only string concatenation when scriptversion is 1
// "+=" and "-=" are assignment
// "+=", "-=" and "..=" are assignments
p = eval_next_non_blank(*arg, evalarg, &getnext);
op = *p;
concat = op == '.' && (*(p + 1) == '.' || current_sctx.sc_version < 2);
if ((op != '+' && op != '-' && !concat) || p[1] == '=')
if ((op != '+' && op != '-' && !concat) || p[1] == '='
|| (p[1] == '.' && p[2] == '='))
break;
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
@@ -3080,9 +3081,10 @@ eval6(
#endif
int error;
// "*=", "/=" and "%=" are assignments
p = eval_next_non_blank(*arg, evalarg, &getnext);
op = *p;
if (op != '*' && op != '/' && op != '%')
if ((op != '*' && op != '/' && op != '%') || p[1] == '=')
break;
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
@@ -3128,7 +3130,7 @@ eval6(
*/
if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[1]))
{
error_white_both(p, 1);
error_white_both(*arg, 1);
clear_tv(rettv);
return FAIL;
}

View File

@@ -909,7 +909,7 @@ ex_let(exarg_T *eap)
}
/*
* Assign the typevalue "tv" to the variable or variables at "arg_start".
* Assign the typeval "tv" to the variable or variables at "arg_start".
* Handles both "var" with any type and "[var, var; var]" with a list type.
* When "op" is not NULL it points to a string with characters that
* must appear after the variable(s). Use "+", "-" or "." for add, subtract
@@ -2788,11 +2788,11 @@ get_script_local_ht(void)
}
/*
* Look for "name[len]" in script-local variables.
* Look for "name[len]" in script-local variables and functions.
* Return OK when found, FAIL when not found.
*/
int
lookup_scriptvar(
lookup_scriptitem(
char_u *name,
size_t len,
cctx_T *dummy UNUSED)
@@ -2802,6 +2802,8 @@ lookup_scriptvar(
char_u *p;
int res;
hashitem_T *hi;
int is_global = FALSE;
char_u *fname = name;
if (ht == NULL)
return FAIL;
@@ -2824,9 +2826,24 @@ lookup_scriptvar(
// if not script-local, then perhaps imported
if (res == FAIL && find_imported(p, 0, NULL) != NULL)
res = OK;
if (p != buffer)
vim_free(p);
if (res != OK)
{
// Find a function, so that a following "->" works. Skip "g:" before a
// function name.
// Do not check for an internal function, since it might also be a
// valid command, such as ":split" versuse "split()".
if (name[0] == 'g' && name[1] == ':')
{
is_global = TRUE;
fname = name + 2;
}
if (find_func(fname, is_global, NULL) != NULL)
res = OK;
}
return res;
}
@@ -3162,6 +3179,7 @@ set_var_const(
if (di != NULL)
{
// Item already exists. Allowed to replace when reloading.
if ((di->di_flags & DI_FLAGS_RELOAD) == 0)
{
if (flags & (ASSIGN_CONST | ASSIGN_FINAL))
@@ -3252,6 +3270,14 @@ set_var_const(
}
else
{
// Item not found, check if a function already exists.
if (is_script_local && (flags & (ASSIGN_NO_DECL | ASSIGN_DECL)) == 0
&& lookup_scriptitem(name, STRLEN(name), NULL) == OK)
{
semsg(_(e_redefining_script_item_str), name);
goto failed;
}
// add a new variable
if (vim9script && is_script_local && (flags & ASSIGN_NO_DECL))
{

View File

@@ -1829,7 +1829,7 @@ do_one_cmd(
if (ea.cmd == cmd + 1 && *cmd == '$')
// should be "$VAR = val"
--ea.cmd;
p = find_ex_command(&ea, NULL, lookup_scriptvar, NULL);
p = find_ex_command(&ea, NULL, lookup_scriptitem, NULL);
if (ea.cmdidx == CMD_SIZE)
{
char_u *ar = skip_range(ea.cmd, TRUE, NULL);

View File

@@ -252,6 +252,7 @@
#define MB_CHARLEN(p) (has_mbyte ? mb_charlen(p) : (int)STRLEN(p))
#define MB_CHAR2LEN(c) (has_mbyte ? mb_char2len(c) : 1)
#define PTR2CHAR(p) (has_mbyte ? mb_ptr2char(p) : (int)*(p))
#define MB_CHAR2BYTES(c, b) do { if (has_mbyte) (b) += (*mb_char2bytes)((c), (b)); else *(b)++ = (c); } while(0)
#ifdef FEAT_AUTOCHDIR
# define DO_AUTOCHDIR do { if (p_acd) do_autochdir(); } while (0)

View File

@@ -61,7 +61,7 @@ void check_vars(char_u *name, int len);
dictitem_T *find_var(char_u *name, hashtab_T **htp, int no_autoload);
dictitem_T *find_var_in_ht(hashtab_T *ht, int htname, char_u *varname, int no_autoload);
hashtab_T *get_script_local_ht(void);
int lookup_scriptvar(char_u *name, size_t len, cctx_T *dummy);
int lookup_scriptitem(char_u *name, size_t len, cctx_T *dummy);
hashtab_T *find_var_ht(char_u *name, char_u **varname);
char_u *get_var_value(char_u *name);
void new_script_vars(scid_T id);

View File

@@ -266,7 +266,7 @@ fill_foldcolumn(
empty = (fdc == 1) ? 0 : 1;
// If the column is too narrow, we start at the lowest level that
// fits and use numbers to indicated the depth.
// fits and use numbers to indicate the depth.
first_level = level - fdc - closed + 1 + empty;
if (first_level < 1)
first_level = 1;

View File

@@ -3510,6 +3510,11 @@ jumpto_tag(
// Save value of no_hlsearch, jumping to a tag is not a real search
save_no_hlsearch = no_hlsearch;
#endif
#ifdef FEAT_PROP_POPUP
// getfile() may have cleared options, apply 'previewpopup' again.
if (g_do_tagpreview != 0 && *p_pvp != NUL)
parse_previewpopup(curwin);
#endif
/*
* If 'cpoptions' contains 't', store the search pattern for the "n"

View File

@@ -2071,6 +2071,7 @@ set_termname(char_u *term)
focus_mode = TRUE;
focus_state = TRUE;
need_gather = TRUE;
}
#endif
@@ -3618,9 +3619,9 @@ starttermcap(void)
out_str(T_KS); // start "keypad transmit" mode
out_str(T_BE); // enable bracketed paste mode
#if (defined(UNIX) || defined(VMS))
// enable xterm's focus reporting mode
if (focus_mode && *T_FE != NUL)
#if defined(UNIX) || defined(VMS)
// Enable xterm's focus reporting mode when 'esckeys' is set.
if (focus_mode && p_ek && *T_FE != NUL)
out_str(T_FE);
#endif
@@ -3676,9 +3677,9 @@ stoptermcap(void)
ch_log_output = TRUE;
#endif
#if (defined(UNIX) || defined(VMS))
// disable xterm's focus reporting mode
if (focus_mode && *T_FD != NUL)
#if defined(UNIX) || defined(VMS)
// Disable xterm's focus reporting mode if 'esckeys' is set.
if (focus_mode && p_ek && *T_FD != NUL)
out_str(T_FD);
#endif

View File

@@ -1,12 +1,12 @@
|o+0&#ffffff0|n|e| @71
|#|i|n|c|l|u|d|e| |"|X|h|e|a|d|e|r|.|h|"| @54
|t|h|r|e@1| @69
|f|o|u|r| @3|╔+0#0000001#ffd7ff255| |X|t|a|g|f|i|l|e| |═@30|X| +0#0000000#ffffff0@23
|f|i|v|e| @3|║+0#0000001#ffd7ff255|2|7| @37| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@23
|s|i|x| @4|║+0#0000001#ffd7ff255|t|h|i|s| |i|s| |a|n|o|t|h|e|r| |p|l|a|c|e| @18| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@23
|s|e|v|e|n| @2|║+0#0000001#ffd7ff255|2|9| @37| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@23
|f|i|n|d| |t|h|e|║+0#0000001#ffd7ff255|3|0| @37| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@23
|n|i|n|e| @3|╚+0#0000001#ffd7ff255|═@40|⇲| +0#0000000#ffffff0@23
|f|o|u|r| @3|╔+0&#afffff255| |X|t|a|g|f|i|l|e| |═@30|X| +0&#ffffff0@23
|f|i|v|e| @3|║+0&#afffff255|2|7| @37| +0&#a8a8a8255|║+0&#afffff255| +0&#ffffff0@23
|s|i|x| @4|║+0&#afffff255|t|h|i|s| |i|s| |a|n|o|t|h|e|r| |p|l|a|c|e| @18| +0&#a8a8a8255|║+0&#afffff255| +0&#ffffff0@23
|s|e|v|e|n| @2|║+0&#afffff255|2|9| @37| +0&#0000001|║+0&#afffff255| +0&#ffffff0@23
|f|i|n|d| |t|h|e|║+0&#afffff255|3|0| @37| +0&#a8a8a8255|║+0&#afffff255| +0&#ffffff0@23
|n|i|n|e| @3|╚+0&#afffff255|═@40|⇲| +0&#ffffff0@23
|t|h|i|s| |i|s| >a|n|o|t|h|e|r| |w|o|r|d| @54
|v|e|r|y| |l|o|n|g| |l|i|n|e| |w|h|e|r|e| |t|h|e| |w|o|r|d| |i|s| |a|l|s|o| |a|n|o|t|h|e|r| @29
|~+0#4040ff13&| @73

View File

@@ -1,12 +1,12 @@
|o+0&#ffffff0|n|e| @71
|#|i|n|c|l|u|d|e| |"|X|h|e|a|d|e|r|.|h|"| @54
|t|h|r|e@1| @69
|f|o|u|r| @9|╔+0#0000001#ffd7ff255| |X|t|a|g|f|i|l|e| |═@30|X| +0#0000000#ffffff0@17
|f|i|v|e| @9|║+0#0000001#ffd7ff255|2|7| @37| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@17
|s|i|x| @10|║+0#0000001#ffd7ff255|t|h|i|s| |i|s| |a|n|o|t|h|e|r| |p|l|a|c|e| @18| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@17
|s|e|v|e|n| @8|║+0#0000001#ffd7ff255|2|9| @37| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@17
|f|i|n|d| |t|h|e|w|o|r|d| |s|║+0#0000001#ffd7ff255|3|0| @37| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@17
|n|i|n|e| @9|╚+0#0000001#ffd7ff255|═@40|⇲| +0#0000000#ffffff0@17
|f|o|u|r| @9|╔+0&#afffff255| |X|t|a|g|f|i|l|e| |═@30|X| +0&#ffffff0@17
|f|i|v|e| @9|║+0&#afffff255|2|7| @37| +0&#a8a8a8255|║+0&#afffff255| +0&#ffffff0@17
|s|i|x| @10|║+0&#afffff255|t|h|i|s| |i|s| |a|n|o|t|h|e|r| |p|l|a|c|e| @18| +0&#a8a8a8255|║+0&#afffff255| +0&#ffffff0@17
|s|e|v|e|n| @8|║+0&#afffff255|2|9| @37| +0&#0000001|║+0&#afffff255| +0&#ffffff0@17
|f|i|n|d| |t|h|e|w|o|r|d| |s|║+0&#afffff255|3|0| @37| +0&#a8a8a8255|║+0&#afffff255| +0&#ffffff0@17
|n|i|n|e| @9|╚+0&#afffff255|═@40|⇲| +0&#ffffff0@17
|t|h|i|s| |i|s| >a|n|o|t|h|e|r| |w|o|r|d| @54
|v|e|r|y| |l|o|n|g| |l|i|n|e| |w|h|e|r|e| |t|h|e| |w|o|r|d| |i|s| |a|l|s|o| |a|n|o|t|h|e|r| @29
|~+0#4040ff13&| @73

View File

@@ -2,13 +2,13 @@
|#|i|n|c|l|u|d|e| |"|X|h|e|a|d|e|r|.|h|"| @54
|t|h|r|e@1| @69
|f|o|u|r| @70
|f|i|v|e| @28|╔+0#0000001#ffd7ff255| |X|t|a|g|f|i|l|e| |═@29|X
|s+0#0000000#ffffff0|i|x| @29|║+0#0000001#ffd7ff255|2|7| @36| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
|s+0#0000000#ffffff0|e|v|e|n| @27|║+0#0000001#ffd7ff255|t|h|i|s| |i|s| |a|n|o|t|h|e|r| |p|l|a|c|e| @17| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
|f+0#0000000#ffffff0|i|n|d| |t|h|e|w|o|r|d| |s|o|m|e|w|h|e|r|e| @10|║+0#0000001#ffd7ff255|2|9| @36| +0#0000000#0000001|║+0#0000001#ffd7ff255
|n+0#0000000#ffffff0|i|n|e| @28|║+0#0000001#ffd7ff255|3|0| @36| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
|t+0#0000000#ffffff0|h|i|s| |i|s| |a|n|o|t|h|e|r| |w|o|r|d| @12|╚+0#0000001#ffd7ff255|═@39|⇲
|v+0#0000000#ffffff0|e|r|y| |l|o|n|g| |l|i|n|e| |w|h|e|r|e| |t|h|e| |w|o|r|d| |i|s| |a|l|s|o| >a|n|o|t|h|e|r| @29
|f|i|v|e| @28|╔+0&#afffff255| |X|t|a|g|f|i|l|e| |═@29|X
|s+0&#ffffff0|i|x| @29|║+0&#afffff255|2|7| @36| +0&#a8a8a8255|║+0&#afffff255
|s+0&#ffffff0|e|v|e|n| @27|║+0&#afffff255|t|h|i|s| |i|s| |a|n|o|t|h|e|r| |p|l|a|c|e| @17| +0&#a8a8a8255|║+0&#afffff255
|f+0&#ffffff0|i|n|d| |t|h|e|w|o|r|d| |s|o|m|e|w|h|e|r|e| @10|║+0&#afffff255|2|9| @36| +0&#0000001|║+0&#afffff255
|n+0&#ffffff0|i|n|e| @28|║+0&#afffff255|3|0| @36| +0&#a8a8a8255|║+0&#afffff255
|t+0&#ffffff0|h|i|s| |i|s| |a|n|o|t|h|e|r| |w|o|r|d| @12|╚+0&#afffff255|═@39|⇲
|v+0&#ffffff0|e|r|y| |l|o|n|g| |l|i|n|e| |w|h|e|r|e| |t|h|e| |w|o|r|d| |i|s| |a|l|s|o| >a|n|o|t|h|e|r| @29
|~+0#4040ff13&| @73
|~| @73
|/+0#0000000&|a|n|o|t|h|e|r| @48|1@1|,|3|9| @8|A|l@1|

View File

@@ -2,13 +2,13 @@
|#|i|n|c|l|u|d|e| |"|X|h|e|a|d|e|r|.|h|"| @54
|t|h|r|e@1| @69
|f|o|u|r| @70
|f|i|v|e| @28|╔+0#0000001#ffd7ff255| |t|e|s|t|d|i|r|/|X|t|a|g|f|i|l|e| |═@21|X
|s+0#0000000#ffffff0|i|x| @29|║+0#0000001#ffd7ff255|2|7| @36| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
|s+0#0000000#ffffff0|e|v|e|n| @27|║+0#0000001#ffd7ff255|t|h|i|s| |i|s| |a|n|o|t|h|e|r| |p|l|a|c|e| @17| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
|f+0#0000000#ffffff0|i|n|d| |t|h|e|w|o|r|d| |s|o|m|e|w|h|e|r|e| @10|║+0#0000001#ffd7ff255|2|9| @36| +0#0000000#0000001|║+0#0000001#ffd7ff255
|n+0#0000000#ffffff0|i|n|e| @28|║+0#0000001#ffd7ff255|3|0| @36| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
|t+0#0000000#ffffff0|h|i|s| |i|s| |a|n|o|t|h|e|r| |w|o|r|d| @12|╚+0#0000001#ffd7ff255|═@39|⇲
|v+0#0000000#ffffff0|e|r|y| |l|o|n|g| |l|i|n|e| |w|h|e|r|e| |t|h|e| |w|o|r|d| |i|s| |a|l|s|o| >a|n|o|t|h|e|r| @29
|f|i|v|e| @28|╔+0&#afffff255| |t|e|s|t|d|i|r|/|X|t|a|g|f|i|l|e| |═@21|X
|s+0&#ffffff0|i|x| @29|║+0&#afffff255|2|7| @36| +0&#a8a8a8255|║+0&#afffff255
|s+0&#ffffff0|e|v|e|n| @27|║+0&#afffff255|t|h|i|s| |i|s| |a|n|o|t|h|e|r| |p|l|a|c|e| @17| +0&#a8a8a8255|║+0&#afffff255
|f+0&#ffffff0|i|n|d| |t|h|e|w|o|r|d| |s|o|m|e|w|h|e|r|e| @10|║+0&#afffff255|2|9| @36| +0&#0000001|║+0&#afffff255
|n+0&#ffffff0|i|n|e| @28|║+0&#afffff255|3|0| @36| +0&#a8a8a8255|║+0&#afffff255
|t+0&#ffffff0|h|i|s| |i|s| |a|n|o|t|h|e|r| |w|o|r|d| @12|╚+0&#afffff255|═@39|⇲
|v+0&#ffffff0|e|r|y| |l|o|n|g| |l|i|n|e| |w|h|e|r|e| |t|h|e| |w|o|r|d| |i|s| |a|l|s|o| >a|n|o|t|h|e|r| @29
|~+0#4040ff13&| @73
|~| @73
|:+0#0000000&| @55|1@1|,|3|9| @8|A|l@1|

View File

@@ -1704,6 +1704,7 @@ func Test_edit_charconvert()
endfunc
" Test for editing a file without read permission
" NOTE: if you run tests as root this will fail. Don't run tests as root!
func Test_edit_file_no_read_perm()
CheckUnix
call writefile(['one', 'two'], 'Xfile')

View File

@@ -333,6 +333,7 @@ func Test_winsize_cmd()
endfunc
" Test for the :redir command
" NOTE: if you run tests as root this will fail. Don't run tests as root!
func Test_redir_cmd()
call assert_fails('redir @@', 'E475:')
call assert_fails('redir abc', 'E475:')

View File

@@ -987,7 +987,66 @@ func s:mbyte_fillchar_tests(fo, fc, fs)
\ a:fs .. 'six ',
\ ], ScreenLines([1, 6], 7))
setlocal foldcolumn&
" Enable number and sign columns and place some signs
setlocal fdc=3
setlocal number
setlocal signcolumn=auto
sign define S1 text=->
sign place 10 line=3 name=S1
call assert_equal([
\ a:fo .. ' 1 one ',
\ a:fs .. a:fo .. ' 2 two ',
\ '2' .. a:fo .. ' -> 3 three',
\ '23 4 four ',
\ a:fs .. a:fs .. ' 5 five ',
\ a:fs .. ' 6 six '
\ ], ScreenLines([1, 6], 14))
" Test with 'rightleft'
if has('rightleft')
setlocal rightleft
let lines = ScreenLines([1, 6], winwidth(0))
call assert_equal('o 1 ' .. a:fo,
\ strcharpart(lines[0], strchars(lines[0]) - 10, 10))
call assert_equal('t 2 ' .. a:fo .. a:fs,
\ strcharpart(lines[1], strchars(lines[1]) - 10, 10))
call assert_equal('t 3 >- ' .. a:fo .. '2',
\ strcharpart(lines[2], strchars(lines[2]) - 10, 10))
call assert_equal('f 4 32',
\ strcharpart(lines[3], strchars(lines[3]) - 10, 10))
call assert_equal('f 5 ' .. a:fs .. a:fs,
\ strcharpart(lines[4], strchars(lines[4]) - 10, 10))
call assert_equal('s 6 ' .. a:fs,
\ strcharpart(lines[5], strchars(lines[5]) - 10, 10))
setlocal norightleft
endif
sign unplace *
sign undefine S1
setlocal number& signcolumn&
" Add a test with more than 9 folds (and then delete some folds)
normal zE
for i in range(1, 10)
normal zfGzo
endfor
normal zR
call assert_equal([
\ a:fo .. a:fo .. ' one ',
\ '9> two '
\ ], ScreenLines([1, 2], 7))
normal 1Gzd
call assert_equal([
\ a:fo .. a:fo .. ' one ',
\ '89 two '
\ ], ScreenLines([1, 2], 7))
normal 1Gzdzdzdzdzdzdzd
call assert_equal([
\ a:fo .. a:fo .. ' one ',
\ a:fs .. a:fs .. ' two '
\ ], ScreenLines([1, 2], 7))
setlocal foldcolumn& number& signcolumn&
endfunc
func Test_foldcolumn_multibyte_char()

View File

@@ -74,6 +74,7 @@ func Test_help_completion()
endfunc
" Test for the :helptags command
" NOTE: if you run tests as root this will fail. Don't run tests as root!
func Test_helptag_cmd()
call mkdir('Xdir/a/doc', 'p')

View File

@@ -3159,6 +3159,7 @@ func Test_previewpopup()
\ 'this is another word',
\ 'very long line where the word is also another'])
set previewpopup=height:4,width:40
hi OtherColor ctermbg=lightcyan guibg=lightcyan
set path=.
END
call writefile(lines, 'XtestPreviewPopup')
@@ -3168,6 +3169,7 @@ func Test_previewpopup()
call term_sendkeys(buf, ":\<CR>")
call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_1', {})
call term_sendkeys(buf, ":set previewpopup+=highlight:OtherColor\<CR>")
call term_sendkeys(buf, "/another\<CR>\<C-W>}")
call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_2', {})
@@ -3182,6 +3184,7 @@ func Test_previewpopup()
call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_5', {})
call term_sendkeys(buf, ":silent cd testdir\<CR>")
call term_sendkeys(buf, ":set previewpopup-=highlight:OtherColor\<CR>")
call term_sendkeys(buf, ":pclose\<CR>")
call term_sendkeys(buf, ":\<BS>")
call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_6', {})

View File

@@ -600,7 +600,7 @@ func Test_vim9_profiling()
call writefile(lines, 'Xprofile_crash.vim')
call system(GetVimCommandClean() . ' -es -c "so Xprofile_crash.vim" -c q')
call assert_equal(0, v:shell_error)
call CheckScriptSuccess(lines)
call assert_true(readfile('Xprofile_crash.log')->len() > 10)
call delete('Xprofile_crash.vim')
call delete('Xprofile_crash.log')
endfunc

View File

@@ -5362,4 +5362,14 @@ func Test_qfbuf_update()
call Xqfbuf_update('l')
endfunc
func Test_vimgrep_noswapfile()
set noswapfile
call writefile(['one', 'two', 'three'], 'Xgreppie')
vimgrep two Xgreppie
call assert_equal('two', getline('.'))
call delete('Xgreppie')
set swapfile
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -464,5 +464,20 @@ func Test_statusline_after_split_vsplit()
set ls& stl&
endfunc
" Test using a multibyte character for 'stl' and 'stlnc' items in 'fillchars'
" with a custom 'statusline'
func Test_statusline_mbyte_fillchar()
only
set laststatus=2
set fillchars=vert:\|,fold:-,stl:━,stlnc:═
set statusline=a%=b
call assert_match('^a\+━\+b$', s:get_statusline())
vnew
call assert_match('^a\+━\+b━a\+═\+b$', s:get_statusline())
wincmd w
call assert_match('^a\+═\+b═a\+━\+b$', s:get_statusline())
set statusline& fillchars& laststatus&
%bw!
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -1099,6 +1099,44 @@ def Test_assign_dict_unknown_type()
CheckScriptSuccess(lines)
enddef
def Test_assign_dict_with_op()
var lines =<< trim END
vim9script
var ds: dict<string> = {a: 'x'}
ds['a'] ..= 'y'
ds.a ..= 'z'
assert_equal('xyz', ds.a)
var dn: dict<number> = {a: 9}
dn['a'] += 2
assert_equal(11, dn.a)
dn.a += 2
assert_equal(13, dn.a)
dn['a'] -= 3
assert_equal(10, dn.a)
dn.a -= 2
assert_equal(8, dn.a)
dn['a'] *= 2
assert_equal(16, dn.a)
dn.a *= 2
assert_equal(32, dn.a)
dn['a'] /= 3
assert_equal(10, dn.a)
dn.a /= 2
assert_equal(5, dn.a)
dn['a'] %= 3
assert_equal(2, dn.a)
dn.a %= 6
assert_equal(2, dn.a)
END
# TODO: this should also work with a :def function
CheckScriptSuccess(lines)
enddef
def Test_assign_lambda()
# check if assign a lambda to a variable which type is func or any.
var lines =<< trim END

View File

@@ -355,6 +355,25 @@ def Test_method_call_linebreak()
END
CheckDefAndScriptSuccess(lines)
lines =<< trim END
new
def Foo(): string
return 'the text'
enddef
def Bar(F: func): string
return F()
enddef
def Test()
Foo
->Bar()
->setline(1)
enddef
Test()
assert_equal('the text', getline(1))
bwipe!
END
CheckDefAndScriptSuccess(lines)
lines =<< trim END
new
g:shortlist
@@ -371,6 +390,24 @@ def Test_method_call_linebreak()
MethodAfterLinebreak('foobar')
assert_equal('foobar', getline(1))
bwipe!
lines =<< trim END
vim9script
def Foo(): string
return '# some text'
enddef
def Bar(F: func): string
return F()
enddef
Foo
->Bar()
->setline(1)
END
CheckScriptSuccess(lines)
assert_equal('# some text', getline(1))
bwipe!
enddef
def Test_method_call_whitespace()

View File

@@ -1254,6 +1254,17 @@ def Test_expr5_vim9script()
echo 'a' .. function('len')
END
CheckScriptFailure(lines, 'E729:', 2)
lines =<< trim END
vim9script
new
['']->setline(1)
/pattern
eval 0
bwipe!
END
CheckScriptFailure(lines, "E1004: White space required before and after '/' at \"/pattern")
enddef
def Test_expr5_vim9script_channel()

View File

@@ -739,6 +739,19 @@ def Test_lambda_uses_assigned_var()
'x = filter(["bbb"], (_, v) => v =~ x)'])
enddef
def Test_pass_legacy_lambda_to_def_func()
var lines =<< trim END
vim9script
func Foo()
eval s:Bar({x -> 0})
endfunc
def Bar(y: any)
enddef
Foo()
END
CheckScriptSuccess(lines)
enddef
" Default arg and varargs
def MyDefVarargs(one: string, two = 'foo', ...rest: list<string>): string
var res = one .. ',' .. two
@@ -2354,6 +2367,30 @@ def Test_nested_lambda_in_closure()
delete('XnestedDone')
enddef
def Test_check_func_arg_types()
var lines =<< trim END
vim9script
def F1(x: string): string
return x
enddef
def F2(x: number): number
return x + 1
enddef
def G(g: func): dict<func>
return {f: g}
enddef
def H(d: dict<func>): string
return d.f('a')
enddef
END
CheckScriptSuccess(lines + ['echo H(G(F1))'])
CheckScriptFailure(lines + ['echo H(G(F2))'], 'E1013:')
enddef
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker

View File

@@ -1515,6 +1515,17 @@ def Test_script_reload_change_type()
delete('Xreload.vim')
enddef
def Test_script_var_shadows_function()
var lines =<< trim END
vim9script
def Func(): number
return 123
enddef
var Func = 1
END
CheckScriptFailure(lines, 'E1041:', 5)
enddef
def s:RetSome(): string
return 'some'
enddef

View File

@@ -406,6 +406,7 @@ func Test_patchmode()
endfunc
" Test for writing to a file in a readonly directory
" NOTE: if you run tests as root this will fail. Don't run tests as root!
func Test_write_readonly_dir()
" On MS-Windows, modifying files in a read-only directory is allowed.
CheckUnix

View File

@@ -750,6 +750,30 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2575,
/**/
2574,
/**/
2573,
/**/
2572,
/**/
2571,
/**/
2570,
/**/
2569,
/**/
2568,
/**/
2567,
/**/
2566,
/**/
2565,
/**/
2564,
/**/
2563,
/**/

View File

@@ -274,7 +274,7 @@ arg_exists(
* Lookup a script-local variable in the current script, possibly defined in a
* block that contains the function "cctx->ctx_ufunc".
* "cctx" is NULL at the script level.
* if "len" is <= 0 "name" must be NUL terminated.
* If "len" is <= 0 "name" must be NUL terminated.
* Return NULL when not found.
*/
static sallvar_T *
@@ -386,6 +386,26 @@ variable_exists(char_u *name, size_t len, cctx_T *cctx)
|| find_imported(name, len, cctx) != NULL;
}
/*
* Return TRUE if "name" is a local variable, argument, script variable,
* imported or function.
*/
static int
item_exists(char_u *name, size_t len, cctx_T *cctx)
{
int is_global;
if (variable_exists(name, len, cctx))
return TRUE;
// Find a function, so that a following "->" works. Skip "g:" before a
// function name.
// Do not check for an internal function, since it might also be a
// valid command, such as ":split" versuse "split()".
is_global = (name[0] == 'g' && name[1] == ':');
return find_func(is_global ? name + 2 : name, is_global, cctx) != NULL;
}
/*
* Check if "p[len]" is already defined, either in script "import_sid" or in
* compilation context "cctx". "cctx" is NULL at the script level.
@@ -728,7 +748,7 @@ get_compare_isn(exprtype_T exprtype, vartype_T type1, vartype_T type2)
}
else if (type1 == VAR_ANY || type2 == VAR_ANY
|| ((type1 == VAR_NUMBER || type1 == VAR_FLOAT)
&& (type2 == VAR_NUMBER || type2 ==VAR_FLOAT)))
&& (type2 == VAR_NUMBER || type2 == VAR_FLOAT)))
isntype = ISN_COMPAREANY;
if ((exprtype == EXPR_IS || exprtype == EXPR_ISNOT)
@@ -8399,8 +8419,7 @@ compile_def_function(
}
}
p = find_ex_command(&ea, NULL, starts_with_colon ? NULL
: (int (*)(char_u *, size_t, cctx_T *))variable_exists,
&cctx);
: (int (*)(char_u *, size_t, cctx_T *))item_exists, &cctx);
if (p == NULL)
{
@@ -8730,6 +8749,8 @@ set_function_type(ufunc_T *ufunc)
// The type is included in "tt_args".
if (argcount > 0 || varargs)
{
if (ufunc->uf_type_list.ga_itemsize == 0)
ga_init2(&ufunc->uf_type_list, sizeof(type_T *), 10);
ufunc->uf_func_type = alloc_func_type(ufunc->uf_ret_type,
argcount, &ufunc->uf_type_list);
// Add argument types to the function type.

View File

@@ -797,7 +797,27 @@ call_by_name(char_u *name, int argcount, ectx_T *ectx, isn_T *iptr)
}
if (ufunc != NULL)
{
if (ufunc->uf_arg_types != NULL)
{
int i;
typval_T *argv = STACK_TV_BOT(0) - argcount;
// The function can change at runtime, check that the argument
// types are correct.
for (i = 0; i < argcount; ++i)
{
type_T *type = i < ufunc->uf_args.ga_len
? ufunc->uf_arg_types[i] : ufunc->uf_va_type;
if (type != NULL && check_typval_arg_type(type,
&argv[i], i + 1) == FAIL)
return FAIL;
}
}
return call_ufunc(ufunc, NULL, argcount, ectx, iptr);
}
return FAIL;
}

View File

@@ -138,7 +138,7 @@ ex_export(exarg_T *eap)
}
eap->cmd = eap->arg;
(void)find_ex_command(eap, NULL, lookup_scriptvar, NULL);
(void)find_ex_command(eap, NULL, lookup_scriptitem, NULL);
switch (eap->cmdidx)
{
case CMD_let: