summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-01-30 14:55:42 +0100
committerBram Moolenaar <Bram@vim.org>2020-01-30 14:55:42 +0100
commitb09920203a0f2b202497ef9632f8447f73d0f1fb (patch)
tree2103a2423c7222e61f77a9138331d5444fa18de3 /src
parentdf54382eacdbfa10291adb80ad6b89ad83bd7c9b (diff)
downloadvim-git-b09920203a0f2b202497ef9632f8447f73d0f1fb.tar.gz
patch 8.2.0179: still a few places where range() does not workv8.2.0179
Problem: Still a few places where range() does not work. Solution: Fix using range() causing problems.
Diffstat (limited to 'src')
-rw-r--r--src/globals.h2
-rw-r--r--src/popupwin.c18
-rw-r--r--src/tag.c1
-rw-r--r--src/terminal.c13
-rw-r--r--src/testdir/dumps/Test_popup_settext_07.dump10
-rw-r--r--src/testdir/dumps/Test_popupwin_20.dump10
-rw-r--r--src/testdir/dumps/Test_popupwin_21.dump10
-rw-r--r--src/testdir/test_functions.vim37
-rw-r--r--src/testdir/test_popupwin.vim23
-rw-r--r--src/version.c2
10 files changed, 107 insertions, 19 deletions
diff --git a/src/globals.h b/src/globals.h
index b40eb2a85..562d956eb 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -1798,7 +1798,7 @@ EXTERN int *eval_lavars_used INIT(= NULL);
// Only filled for Win32.
EXTERN char windowsVersion[20] INIT(= {0});
-// Used for a non-materialized range() list.
+// Used for lv_first in a non-materialized range() list.
EXTERN listitem_T range_list_item;
#endif
diff --git a/src/popupwin.c b/src/popupwin.c
index 47e9238ba..8a3f500d2 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -97,6 +97,8 @@ set_padding_border(dict_T *dict, int *array, char *name, int max_val)
for (i = 0; i < 4; ++i)
array[i] = 1;
if (list != NULL)
+ {
+ range_list_materialize(list);
for (i = 0, li = list->lv_first; i < 4 && i < list->lv_len;
++i, li = li->li_next)
{
@@ -104,6 +106,7 @@ set_padding_border(dict_T *dict, int *array, char *name, int max_val)
if (nr >= 0)
array[i] = nr > max_val ? max_val : nr;
}
+ }
}
}
}
@@ -476,6 +479,9 @@ apply_move_options(win_T *wp, dict_T *d)
wp->w_popup_prop_id = dict_get_number(d, (char_u *)"textpropid");
}
+/*
+ * Handle "moved" and "mousemoved" arguments.
+ */
static void
handle_moved_argument(win_T *wp, dictitem_T *di, int mousemoved)
{
@@ -506,11 +512,13 @@ handle_moved_argument(win_T *wp, dictitem_T *di, int mousemoved)
|| di->di_tv.vval.v_list->lv_len == 3))
{
list_T *l = di->di_tv.vval.v_list;
- listitem_T *li = l->lv_first;
+ listitem_T *li;
int mincol;
int maxcol;
- if (di->di_tv.vval.v_list->lv_len == 3)
+ range_list_materialize(l);
+ li = l->lv_first;
+ if (l->lv_len == 3)
{
varnumber_T nr = tv_get_number(&l->lv_first->li_tv);
@@ -748,6 +756,7 @@ apply_general_options(win_T *wp, dict_T *dict)
listitem_T *li;
int i;
+ range_list_materialize(list);
for (i = 0, li = list->lv_first; i < 4 && i < list->lv_len;
++i, li = li->li_next)
{
@@ -780,6 +789,8 @@ apply_general_options(win_T *wp, dict_T *dict)
int i;
if (list != NULL)
+ {
+ range_list_materialize(list);
for (i = 0, li = list->lv_first; i < 8 && i < list->lv_len;
++i, li = li->li_next)
{
@@ -787,6 +798,7 @@ apply_general_options(win_T *wp, dict_T *dict)
if (*str != NUL)
wp->w_border_char[i] = mb_ptr2char(str);
}
+ }
if (list->lv_len == 1)
for (i = 1; i < 8; ++i)
wp->w_border_char[i] = wp->w_border_char[0];
@@ -833,6 +845,8 @@ apply_general_options(win_T *wp, dict_T *dict)
ok = FALSE;
break;
}
+ else
+ range_list_materialize(li->li_tv.vval.v_list);
}
}
if (ok)
diff --git a/src/tag.c b/src/tag.c
index cfc300e46..148a5a013 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -4267,6 +4267,7 @@ set_tagstack(win_T *wp, dict_T *d, int action)
taggy_T *tagstack = wp->w_tagstack;
int tagstackidx = wp->w_tagstackidx;
int tagstacklen = wp->w_tagstacklen;
+
// delete all the tag stack entries above the current entry
while (tagstackidx < tagstacklen)
tagstack_clear_entry(&tagstack[--tagstacklen]);
diff --git a/src/terminal.c b/src/terminal.c
index da27a9c17..3bf914ae9 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -417,7 +417,11 @@ term_start(
if ((opt->jo_set & (JO_IN_IO + JO_OUT_IO + JO_ERR_IO))
== (JO_IN_IO + JO_OUT_IO + JO_ERR_IO)
|| (!(opt->jo_set & JO_OUT_IO) && (opt->jo_set & JO_OUT_BUF))
- || (!(opt->jo_set & JO_ERR_IO) && (opt->jo_set & JO_ERR_BUF)))
+ || (!(opt->jo_set & JO_ERR_IO) && (opt->jo_set & JO_ERR_BUF))
+ || (argvar != NULL
+ && argvar->v_type == VAR_LIST
+ && argvar->vval.v_list != NULL
+ && argvar->vval.v_list->lv_first == &range_list_item))
{
emsg(_(e_invarg));
return NULL;
@@ -538,7 +542,7 @@ term_start(
}
else if (argvar->v_type != VAR_LIST
|| argvar->vval.v_list == NULL
- || argvar->vval.v_list->lv_len < 1
+ || argvar->vval.v_list->lv_len == 0
|| (cmd = tv_get_string_chk(
&argvar->vval.v_list->lv_first->li_tv)) == NULL)
cmd = (char_u*)"";
@@ -3763,9 +3767,9 @@ set_ansi_colors_list(VTerm *vterm, list_T *list)
{
int n = 0;
long_u rgb[16];
- listitem_T *li = list->lv_first;
+ listitem_T *li;
- for (; li != NULL && n < 16; li = li->li_next, n++)
+ for (li = list->lv_first; li != NULL && n < 16; li = li->li_next, n++)
{
char_u *color_name;
guicolor_T guicolor;
@@ -3800,6 +3804,7 @@ init_vterm_ansi_colors(VTerm *vterm)
if (var != NULL
&& (var->di_tv.v_type != VAR_LIST
|| var->di_tv.vval.v_list == NULL
+ || var->di_tv.vval.v_list->lv_first == &range_list_item
|| set_ansi_colors_list(vterm, var->di_tv.vval.v_list) == FAIL))
semsg(_(e_invarg2), "g:terminal_ansi_colors");
}
diff --git a/src/testdir/dumps/Test_popup_settext_07.dump b/src/testdir/dumps/Test_popup_settext_07.dump
new file mode 100644
index 000000000..146dec677
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_settext_07.dump
@@ -0,0 +1,10 @@
+> +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @35| +0#0000001#ffd7ff255| +0#4040ff13#ffffff0@36
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|E+0#ffffff16#e000002|7|1|5|:| |D|i|c|t|i|o|n|a|r|y| |r|e|q|u|i|r|e|d| +0#0000000#ffffff0@31|0|,|0|-|1| @8|A|l@1|
diff --git a/src/testdir/dumps/Test_popupwin_20.dump b/src/testdir/dumps/Test_popupwin_20.dump
index 707db58dd..692708beb 100644
--- a/src/testdir/dumps/Test_popupwin_20.dump
+++ b/src/testdir/dumps/Test_popupwin_20.dump
@@ -3,11 +3,11 @@
|3| ||+0#0000001#ffd7ff255|h|e|l@1|o| |b|o|r|d|e|r||| +0#0000000#ffffff0@5| +0#0000001#ffd7ff255|h|e|l@1|o| |p|a|d@1|i|n|g| | +0#0000000#ffffff0@4||| @11||| @16|X+0#0000001#ffd7ff255| +0#0000000#ffffff0
|4| |++0#0000001#ffd7ff255|-@11|+| +0#0000000#ffffff0@5| +0#0000001#ffd7ff255@14| +0#0000000#ffffff0@4||| |h|e|l@1|o| |b|o|t|h| ||| @17|X+0#0000001#ffd7ff255
|5+0#0000000#ffffff0| @40||| @11||| @17|X+0#0000001#ffd7ff255
-|6+0#0000000#ffffff0| |++0#0000001#ffd7ff255|-@8| +0#0000000#ffffff0@9| +0#0000001#ffd7ff255@14| +0#0000000#ffffff0@4|+|-@11|+| @18
-|7| ||+0#0000001#ffd7ff255|b|o|r|d|e|r| |T|L| +0#0000000#ffffff0@9| +0#0000001#ffd7ff255@3|p|a|d@1|i|n|g|s| @2| +0#0000000#ffffff0@37
-|8| @20| +0#0000001#ffd7ff255@14| +0#0000000#ffffff0@12||+0#0000001#ffd7ff255| @2|w|r|a|p@1|e|d| |l|o|n|g|e|r| |t|e| @2||
-|9+0#0000000#ffffff0| @20| +0#0000001#ffd7ff255@14| +0#0000000#ffffff0@12||+0#0000001#ffd7ff255| @2|x|t| @17||
-|1+0#0000000#ffffff0|0| @72
+|6+0#0000000#ffffff0| |++0#0000001#ffd7ff255|-@8| +0#0000000#ffffff0@9| +0#0000001#ffd7ff255@13| +0#0000000#ffffff0@5|+|-@11|+| @18
+|7| ||+0#0000001#ffd7ff255|b|o|r|d|e|r| |T|L| +0#0000000#ffffff0@9| +0#0000001#ffd7ff255@3|p|a|d@1|i|n|g|s| @1| +0#0000000#ffffff0@38
+|8| @20| +0#0000001#ffd7ff255@13| +0#0000000#ffffff0@13||+0#0000001#ffd7ff255| @2|w|r|a|p@1|e|d| |l|o|n|g|e|r| |t|e| @2||
+|9+0#0000000#ffffff0| @20| +0#0000001#ffd7ff255@13| +0#0000000#ffffff0@13||+0#0000001#ffd7ff255| @2|x|t| @17||
+|1+0#0000000#ffffff0|0| @19| +0#0000001#ffd7ff255@13| +0#0000000#ffffff0@38
|1@1| @46||+0#0000001#ffd7ff255| @2|r|i|g|h|t| |a|l|i|g|n|e|d| |t|e|x|t| @2||
|1+0#0000000#ffffff0|2| @72
|1|3| @72
diff --git a/src/testdir/dumps/Test_popupwin_21.dump b/src/testdir/dumps/Test_popupwin_21.dump
index 9b6f4d000..6398549db 100644
--- a/src/testdir/dumps/Test_popupwin_21.dump
+++ b/src/testdir/dumps/Test_popupwin_21.dump
@@ -3,11 +3,11 @@
|3| |║+0#0000001#ffd7ff255|h|e|l@1|o| |b|o|r|d|e|r|║| +0#0000000#ffffff0@5| +0#0000001#ffd7ff255|h|e|l@1|o| |p|a|d@1|i|n|g| | +0#0000000#ffffff0@4|║| @11|║| @16|X+0#0000001#ffd7ff255| +0#0000000#ffffff0
|4| |╚+0#0000001#ffd7ff255|═@11|╝| +0#0000000#ffffff0@5| +0#0000001#ffd7ff255@14| +0#0000000#ffffff0@4|║| |h|e|l@1|o| |b|o|t|h| |║| @17|X+0#0000001#ffd7ff255
|5+0#0000000#ffffff0| @40|║| @11|║| @17|X+0#0000001#ffd7ff255
-|6+0#0000000#ffffff0| |╔+0#0000001#ffd7ff255|═@8| +0#0000000#ffffff0@9| +0#0000001#ffd7ff255@14| +0#0000000#ffffff0@4|╚|═@11|╝| @18
-|7| |║+0#0000001#ffd7ff255|b|o|r|d|e|r| |T|L| +0#0000000#ffffff0@9| +0#0000001#ffd7ff255@3|p|a|d@1|i|n|g|s| @2| +0#0000000#ffffff0@37
-|8| @20| +0#0000001#ffd7ff255@14| +0#0000000#ffffff0@12|║+0#0000001#ffd7ff255| @2|w|r|a|p@1|e|d| |l|o|n|g|e|r| |t|e| @2|║
-|9+0#0000000#ffffff0| @20| +0#0000001#ffd7ff255@14| +0#0000000#ffffff0@12|║+0#0000001#ffd7ff255| @2|x|t| @17|║
-|1+0#0000000#ffffff0|0| @72
+|6+0#0000000#ffffff0| |╔+0#0000001#ffd7ff255|═@8| +0#0000000#ffffff0@9| +0#0000001#ffd7ff255@13| +0#0000000#ffffff0@5|╚|═@11|╝| @18
+|7| |║+0#0000001#ffd7ff255|b|o|r|d|e|r| |T|L| +0#0000000#ffffff0@9| +0#0000001#ffd7ff255@3|p|a|d@1|i|n|g|s| @1| +0#0000000#ffffff0@38
+|8| @20| +0#0000001#ffd7ff255@13| +0#0000000#ffffff0@13|║+0#0000001#ffd7ff255| @2|w|r|a|p@1|e|d| |l|o|n|g|e|r| |t|e| @2|║
+|9+0#0000000#ffffff0| @20| +0#0000001#ffd7ff255@13| +0#0000000#ffffff0@13|║+0#0000001#ffd7ff255| @2|x|t| @17|║
+|1+0#0000000#ffffff0|0| @19| +0#0000001#ffd7ff255@13| +0#0000000#ffffff0@38
|1@1| @46|║+0#0000001#ffd7ff255| @2|r|i|g|h|t| |a|l|i|g|n|e|d| |t|e|x|t| @2|║
|1+0#0000000#ffffff0|2| @72
|1|3| @72
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index 595a96358..6150a0c3e 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -1955,12 +1955,49 @@ func Test_range()
call setreg('a', range(3))
call assert_equal("0\n1\n2\n", getreg('a'))
+ " settagstack()
+ call settagstack(1, #{items : range(4)})
+
+ " sign_define()
+ call assert_fails("call sign_define(range(5))", "E715:")
+ call assert_fails("call sign_placelist(range(5))", "E715:")
+
+ " sign_undefine()
+ call assert_fails("call sign_undefine(range(5))", "E908:")
+
+ " sign_unplacelist()
+ call assert_fails("call sign_unplacelist(range(5))", "E715:")
+
" sort()
call assert_equal([0, 1, 2, 3, 4, 5], sort(range(5, 0, -1)))
+ " 'spellsuggest'
+ func MySuggest()
+ return range(3)
+ endfunc
+ set spell spellsuggest=expr:MySuggest()
+ call assert_equal([], spellsuggest('baord', 3))
+ set nospell spellsuggest&
+
" string()
call assert_equal('[0, 1, 2, 3, 4]', string(range(5)))
+ " taglist() with 'tagfunc'
+ func TagFunc(pattern, flags, info)
+ return range(10)
+ endfunc
+ set tagfunc=TagFunc
+ call assert_fails("call taglist('asdf')", 'E987:')
+ set tagfunc=
+
+ " term_start()
+ if has('terminal')
+ call assert_fails('call term_start(range(3, 4))', 'E474:')
+ let g:terminal_ansi_colors = range(16)
+ call assert_fails('call term_start("ls", #{term_finish: "close"})', 'E475:')
+ unlet g:terminal_ansi_colors
+ endif
+
" type()
call assert_equal(v:t_list, type(range(5)))
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index ebcc1f414..75247b533 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -86,7 +86,7 @@ func Test_popup_with_border_and_padding()
call popup_create('hello padding', #{line: 2, col: 23, padding: []})
call popup_create('hello both', #{line: 2, col: 43, border: [], padding: [], highlight: 'Normal'})
call popup_create('border TL', #{line: 6, col: 3, border: [1, 0, 0, 4]})
- call popup_create('paddings', #{line: 6, col: 23, padding: [1, 3, 2, 4]})
+ call popup_create('paddings', #{line: 6, col: 23, padding: range(1, 4)})
call popup_create('wrapped longer text', #{line: 8, col: 55, padding: [0, 3, 0, 3], border: [0, 1, 0, 1]})
call popup_create('right aligned text', #{line: 11, col: 56, wrap: 0, padding: [0, 3, 0, 3], border: [0, 1, 0, 1]})
call popup_create('X', #{line: 2, col: 73})
@@ -180,6 +180,14 @@ func Test_popup_with_border_and_padding()
call popup_setoptions(winid, options)
call assert_equal(options, popup_getoptions(winid))
+ " Check that range() doesn't crash
+ call popup_setoptions(winid, #{
+ \ padding: range(1, 4),
+ \ border: range(5, 8),
+ \ borderhighlight: range(4),
+ \ borderchars: range(8),
+ \ })
+
let winid = popup_create('hello both', #{line: 3, col: 8, border: [], padding: []})
call assert_equal(#{
\ line: 3,
@@ -883,8 +891,14 @@ func Test_popup_invalid_arguments()
call popup_clear()
call assert_fails('call popup_create([#{text: "text", props: ["none"]}], {})', 'E715:')
call popup_clear()
+ call assert_fails('call popup_create([#{text: "text", props: range(3)}], {})', 'E715:')
+ call popup_clear()
call assert_fails('call popup_create("text", #{mask: ["asdf"]})', 'E475:')
call popup_clear()
+ call assert_fails('call popup_create("text", #{mask: range(5)})', 'E475:')
+ call popup_clear()
+ call popup_create("text", #{mask: [range(4)]})
+ call popup_clear()
call assert_fails('call popup_create("text", #{mask: test_null_list()})', 'E475:')
call assert_fails('call popup_create("text", #{mapping: []})', 'E745:')
call popup_clear()
@@ -1331,7 +1345,8 @@ func Test_popup_atcursor_pos()
normal 3G45|r@
let winid1 = popup_atcursor(['First', 'SeconD'], #{
\ pos: 'topright',
- \ moved: [0, 0, 0],
+ \ moved: range(3),
+ \ mousemoved: range(3),
\ })
END
call writefile(lines, 'XtestPopupAtcursorPos')
@@ -2099,6 +2114,10 @@ func Test_popup_settext()
call term_sendkeys(buf, ":call popup_settext(p, [#{text: 'aaaa'}, #{text: 'bbbb'}, #{text: 'cccc'}])\<CR>")
call VerifyScreenDump(buf, 'Test_popup_settext_06', {})
+ " range() (doesn't work)
+ call term_sendkeys(buf, ":call popup_settext(p, range(4, 8))\<CR>")
+ call VerifyScreenDump(buf, 'Test_popup_settext_07', {})
+
" clean up
call StopVimInTerminal(buf)
call delete('XtestPopupSetText')
diff --git a/src/version.c b/src/version.c
index 3d4b1cbcc..8b52a9467 100644
--- a/src/version.c
+++ b/src/version.c
@@ -743,6 +743,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 179,
+/**/
178,
/**/
177,