0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.0179: still a few places where range() does not work

Problem:    Still a few places where range() does not work.
Solution:   Fix using range() causing problems.
This commit is contained in:
Bram Moolenaar
2020-01-30 14:55:42 +01:00
parent df54382eac
commit b09920203a
10 changed files with 107 additions and 19 deletions

View File

@@ -1798,7 +1798,7 @@ EXTERN int *eval_lavars_used INIT(= NULL);
// Only filled for Win32. // Only filled for Win32.
EXTERN char windowsVersion[20] INIT(= {0}); 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; EXTERN listitem_T range_list_item;
#endif #endif

View File

@@ -97,6 +97,8 @@ set_padding_border(dict_T *dict, int *array, char *name, int max_val)
for (i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
array[i] = 1; array[i] = 1;
if (list != NULL) if (list != NULL)
{
range_list_materialize(list);
for (i = 0, li = list->lv_first; i < 4 && i < list->lv_len; for (i = 0, li = list->lv_first; i < 4 && i < list->lv_len;
++i, li = li->li_next) ++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) if (nr >= 0)
array[i] = nr > max_val ? max_val : nr; 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"); wp->w_popup_prop_id = dict_get_number(d, (char_u *)"textpropid");
} }
/*
* Handle "moved" and "mousemoved" arguments.
*/
static void static void
handle_moved_argument(win_T *wp, dictitem_T *di, int mousemoved) 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)) || di->di_tv.vval.v_list->lv_len == 3))
{ {
list_T *l = di->di_tv.vval.v_list; list_T *l = di->di_tv.vval.v_list;
listitem_T *li = l->lv_first; listitem_T *li;
int mincol; int mincol;
int maxcol; 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); 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; listitem_T *li;
int i; int i;
range_list_materialize(list);
for (i = 0, li = list->lv_first; i < 4 && i < list->lv_len; for (i = 0, li = list->lv_first; i < 4 && i < list->lv_len;
++i, li = li->li_next) ++i, li = li->li_next)
{ {
@@ -780,6 +789,8 @@ apply_general_options(win_T *wp, dict_T *dict)
int i; int i;
if (list != NULL) if (list != NULL)
{
range_list_materialize(list);
for (i = 0, li = list->lv_first; i < 8 && i < list->lv_len; for (i = 0, li = list->lv_first; i < 8 && i < list->lv_len;
++i, li = li->li_next) ++i, li = li->li_next)
{ {
@@ -787,6 +798,7 @@ apply_general_options(win_T *wp, dict_T *dict)
if (*str != NUL) if (*str != NUL)
wp->w_border_char[i] = mb_ptr2char(str); wp->w_border_char[i] = mb_ptr2char(str);
} }
}
if (list->lv_len == 1) if (list->lv_len == 1)
for (i = 1; i < 8; ++i) for (i = 1; i < 8; ++i)
wp->w_border_char[i] = wp->w_border_char[0]; 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; ok = FALSE;
break; break;
} }
else
range_list_materialize(li->li_tv.vval.v_list);
} }
} }
if (ok) if (ok)

View File

@@ -4267,6 +4267,7 @@ set_tagstack(win_T *wp, dict_T *d, int action)
taggy_T *tagstack = wp->w_tagstack; taggy_T *tagstack = wp->w_tagstack;
int tagstackidx = wp->w_tagstackidx; int tagstackidx = wp->w_tagstackidx;
int tagstacklen = wp->w_tagstacklen; int tagstacklen = wp->w_tagstacklen;
// delete all the tag stack entries above the current entry // delete all the tag stack entries above the current entry
while (tagstackidx < tagstacklen) while (tagstackidx < tagstacklen)
tagstack_clear_entry(&tagstack[--tagstacklen]); tagstack_clear_entry(&tagstack[--tagstacklen]);

View File

@@ -417,7 +417,11 @@ term_start(
if ((opt->jo_set & (JO_IN_IO + JO_OUT_IO + JO_ERR_IO)) if ((opt->jo_set & (JO_IN_IO + JO_OUT_IO + JO_ERR_IO))
== (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_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)); emsg(_(e_invarg));
return NULL; return NULL;
@@ -538,7 +542,7 @@ term_start(
} }
else if (argvar->v_type != VAR_LIST else if (argvar->v_type != VAR_LIST
|| argvar->vval.v_list == NULL || argvar->vval.v_list == NULL
|| argvar->vval.v_list->lv_len < 1 || argvar->vval.v_list->lv_len == 0
|| (cmd = tv_get_string_chk( || (cmd = tv_get_string_chk(
&argvar->vval.v_list->lv_first->li_tv)) == NULL) &argvar->vval.v_list->lv_first->li_tv)) == NULL)
cmd = (char_u*)""; cmd = (char_u*)"";
@@ -3763,9 +3767,9 @@ set_ansi_colors_list(VTerm *vterm, list_T *list)
{ {
int n = 0; int n = 0;
long_u rgb[16]; 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; char_u *color_name;
guicolor_T guicolor; guicolor_T guicolor;
@@ -3800,6 +3804,7 @@ init_vterm_ansi_colors(VTerm *vterm)
if (var != NULL if (var != NULL
&& (var->di_tv.v_type != VAR_LIST && (var->di_tv.v_type != VAR_LIST
|| var->di_tv.vval.v_list == NULL || 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)) || set_ansi_colors_list(vterm, var->di_tv.vval.v_list) == FAIL))
semsg(_(e_invarg2), "g:terminal_ansi_colors"); semsg(_(e_invarg2), "g:terminal_ansi_colors");
} }

View File

@@ -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|

View File

@@ -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 |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 |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 |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 |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| @2| +0#0000000#ffffff0@37 |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@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|| |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@14| +0#0000000#ffffff0@12||+0#0000001#ffd7ff255| @2|x|t| @17|| |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| @72 |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@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+0#0000000#ffffff0|2| @72
|1|3| @72 |1|3| @72

View File

@@ -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 |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 |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 |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 |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| @2| +0#0000000#ffffff0@37 |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@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|║ |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@14| +0#0000000#ffffff0@12|║+0#0000001#ffd7ff255| @2|x|t| @17|║ |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| @72 |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@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+0#0000000#ffffff0|2| @72
|1|3| @72 |1|3| @72

View File

@@ -1955,12 +1955,49 @@ func Test_range()
call setreg('a', range(3)) call setreg('a', range(3))
call assert_equal("0\n1\n2\n", getreg('a')) 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() " sort()
call assert_equal([0, 1, 2, 3, 4, 5], sort(range(5, 0, -1))) 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() " string()
call assert_equal('[0, 1, 2, 3, 4]', string(range(5))) 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() " type()
call assert_equal(v:t_list, type(range(5))) call assert_equal(v:t_list, type(range(5)))

View File

@@ -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 padding', #{line: 2, col: 23, padding: []})
call popup_create('hello both', #{line: 2, col: 43, border: [], padding: [], highlight: 'Normal'}) 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('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('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('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}) 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 popup_setoptions(winid, options)
call assert_equal(options, popup_getoptions(winid)) 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: []}) let winid = popup_create('hello both', #{line: 3, col: 8, border: [], padding: []})
call assert_equal(#{ call assert_equal(#{
\ line: 3, \ line: 3,
@@ -883,8 +891,14 @@ func Test_popup_invalid_arguments()
call popup_clear() call popup_clear()
call assert_fails('call popup_create([#{text: "text", props: ["none"]}], {})', 'E715:') call assert_fails('call popup_create([#{text: "text", props: ["none"]}], {})', 'E715:')
call popup_clear() 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 assert_fails('call popup_create("text", #{mask: ["asdf"]})', 'E475:')
call popup_clear() 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", #{mask: test_null_list()})', 'E475:')
call assert_fails('call popup_create("text", #{mapping: []})', 'E745:') call assert_fails('call popup_create("text", #{mapping: []})', 'E745:')
call popup_clear() call popup_clear()
@@ -1331,7 +1345,8 @@ func Test_popup_atcursor_pos()
normal 3G45|r@ normal 3G45|r@
let winid1 = popup_atcursor(['First', 'SeconD'], #{ let winid1 = popup_atcursor(['First', 'SeconD'], #{
\ pos: 'topright', \ pos: 'topright',
\ moved: [0, 0, 0], \ moved: range(3),
\ mousemoved: range(3),
\ }) \ })
END END
call writefile(lines, 'XtestPopupAtcursorPos') 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 term_sendkeys(buf, ":call popup_settext(p, [#{text: 'aaaa'}, #{text: 'bbbb'}, #{text: 'cccc'}])\<CR>")
call VerifyScreenDump(buf, 'Test_popup_settext_06', {}) 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 " clean up
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('XtestPopupSetText') call delete('XtestPopupSetText')

View File

@@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
179,
/**/ /**/
178, 178,
/**/ /**/