Skip to content

Commit 4f8388f

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents d404ddd + a4abe51 commit 4f8388f

12 files changed

+361
-58
lines changed

src/drawline.c

+5
Original file line numberDiff line numberDiff line change
@@ -1888,6 +1888,11 @@ win_line(
18881888
p_extra_free2 = wlv.p_extra;
18891889
}
18901890

1891+
if (lcs_eol_one < 0 && wlv.col
1892+
+ wlv.n_extra - 2 > wp->w_width)
1893+
// don't bail out at end of line
1894+
lcs_eol_one = 0;
1895+
18911896
// When 'wrap' is off then for "below" we need
18921897
// to start a new line explictly.
18931898
if (start_line)

src/proto/vim9instr.pro

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,15 @@ int generate_FUNCREF(cctx_T *cctx, ufunc_T *ufunc, isn_T **isnp);
4343
int generate_NEWFUNC(cctx_T *cctx, char_u *lambda_name, char_u *func_name);
4444
int generate_DEF(cctx_T *cctx, char_u *name, size_t len);
4545
int generate_JUMP(cctx_T *cctx, jumpwhen_T when, int where);
46+
int generate_WHILE(cctx_T *cctx, int funcref_idx);
4647
int generate_JUMP_IF_ARG_SET(cctx_T *cctx, int arg_off);
4748
int generate_FOR(cctx_T *cctx, int loop_idx);
49+
int generate_ENDLOOP(cctx_T *cctx, int funcref_idx, int prev_local_count);
4850
int generate_TRYCONT(cctx_T *cctx, int levels, int where);
4951
int check_internal_func_args(cctx_T *cctx, int func_idx, int argcount, int method_call, type2_T **argtypes, type2_T *shuffled_argtypes);
5052
int generate_BCALL(cctx_T *cctx, int func_idx, int argcount, int method_call);
5153
int generate_LISTAPPEND(cctx_T *cctx);
5254
int generate_BLOBAPPEND(cctx_T *cctx);
53-
int check_args_on_stack(cctx_T *cctx, ufunc_T *ufunc, int argcount);
5455
int generate_CALL(cctx_T *cctx, ufunc_T *ufunc, int pushed_argcount);
5556
int generate_UCALL(cctx_T *cctx, char_u *name, int argcount);
5657
int check_func_args_from_type(cctx_T *cctx, type_T *type, int argcount, int at_top, char_u *name);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
>x+0&#ffffff0@10|S|o|m|e| |t|e|x|t| |t|o| |a|d@1| |v|i|r|t|u|a|l| |t|e|x|t| |t|o|.|$+0#4040ff13&| +0#0000000&@2|a+0&#ffd7ff255|f|t|e|r| +0&#ffffff0@6
2+
@47|r+0&#ffd7ff255|i|g|h|t| |a|l|i|g|n|e|d
3+
| +0&#ffffff0@3|b+0&#ffd7ff255|e|l|o|w| |t|h|e| |l|i|n|e| +0&#ffffff0@41
4+
|s|e|c|o|n|d| |l|i|n|e|$+0#4040ff13&| +0#0000000&@47
5+
|x|A|n|o|t|h|e|r| |l|i|n|e| |w|i|t|h| |s|o|m|e| |t|e|x|t| |t|o| |m|a|k|e| |t|h|e| |w|r|a|p|.|$+0#4040ff13&| +0#0000000&@12
6+
@51|r+0&#ffd7ff255|i|g|h|t|m|o|s|t
7+
| +0&#ffffff0@59
8+
|:|s|e|t| |l|i|s|t| @32|1|,|1| @10|A|l@1|

src/testdir/test_textprop.vim

+3
Original file line numberDiff line numberDiff line change
@@ -3181,6 +3181,9 @@ func Test_insert_text_with_padding()
31813181
call term_sendkeys(buf, "ggix\<Esc>")
31823182
call VerifyScreenDump(buf, 'Test_prop_text_with_padding_3', {})
31833183

3184+
call term_sendkeys(buf, ":set list\<CR>")
3185+
call VerifyScreenDump(buf, 'Test_prop_text_with_padding_4', {})
3186+
31843187
call StopVimInTerminal(buf)
31853188
call delete('XscriptPropsPadded')
31863189
endfunc

src/testdir/test_vim9_disassemble.vim

+35-14
Original file line numberDiff line numberDiff line change
@@ -1466,17 +1466,20 @@ def Test_disassemble_for_loop()
14661466
'\d NEWLIST size 0\_s*' ..
14671467
'\d SETTYPE list<number>\_s*' ..
14681468
'\d STORE $0\_s*' ..
1469+
14691470
'for i in range(3)\_s*' ..
14701471
'\d STORE -1 in $1\_s*' ..
14711472
'\d PUSHNR 3\_s*' ..
14721473
'\d BCALL range(argc 1)\_s*' ..
14731474
'\d FOR $1 -> \d\+\_s*' ..
1474-
'\d STORE $2\_s*' ..
1475+
'\d STORE $3\_s*' ..
1476+
14751477
'res->add(i)\_s*' ..
14761478
'\d LOAD $0\_s*' ..
1477-
'\d LOAD $2\_s*' ..
1479+
'\d LOAD $3\_s*' ..
14781480
'\d\+ LISTAPPEND\_s*' ..
14791481
'\d\+ DROP\_s*' ..
1482+
14801483
'endfor\_s*' ..
14811484
'\d\+ JUMP -> \d\+\_s*' ..
14821485
'\d\+ DROP',
@@ -1498,21 +1501,25 @@ def Test_disassemble_for_loop_eval()
14981501
'var res = ""\_s*' ..
14991502
'\d PUSHS ""\_s*' ..
15001503
'\d STORE $0\_s*' ..
1504+
15011505
'for str in eval(''\["one", "two"\]'')\_s*' ..
15021506
'\d STORE -1 in $1\_s*' ..
15031507
'\d PUSHS "\["one", "two"\]"\_s*' ..
15041508
'\d BCALL eval(argc 1)\_s*' ..
15051509
'\d FOR $1 -> \d\+\_s*' ..
1506-
'\d STORE $2\_s*' ..
1510+
'\d STORE $3\_s*' ..
1511+
15071512
'res ..= str\_s*' ..
15081513
'\d\+ LOAD $0\_s*' ..
1509-
'\d\+ LOAD $2\_s*' ..
1514+
'\d\+ LOAD $3\_s*' ..
15101515
'\d 2STRING_ANY stack\[-1\]\_s*' ..
15111516
'\d\+ CONCAT size 2\_s*' ..
15121517
'\d\+ STORE $0\_s*' ..
1518+
15131519
'endfor\_s*' ..
15141520
'\d\+ JUMP -> 5\_s*' ..
15151521
'\d\+ DROP\_s*' ..
1522+
15161523
'return res\_s*' ..
15171524
'\d\+ LOAD $0\_s*' ..
15181525
'\d\+ RETURN',
@@ -1539,12 +1546,14 @@ def Test_disassemble_for_loop_unpack()
15391546
'\d\+ NEWLIST size 2\_s*' ..
15401547
'\d\+ FOR $0 -> 16\_s*' ..
15411548
'\d\+ UNPACK 2\_s*' ..
1542-
'\d\+ STORE $1\_s*' ..
15431549
'\d\+ STORE $2\_s*' ..
1550+
'\d\+ STORE $3\_s*' ..
1551+
15441552
'echo x1 x2\_s*' ..
1545-
'\d\+ LOAD $1\_s*' ..
15461553
'\d\+ LOAD $2\_s*' ..
1554+
'\d\+ LOAD $3\_s*' ..
15471555
'\d\+ ECHO 2\_s*' ..
1556+
15481557
'endfor\_s*' ..
15491558
'\d\+ JUMP -> 8\_s*' ..
15501559
'\d\+ DROP\_s*' ..
@@ -1576,32 +1585,43 @@ def Test_disassemble_for_loop_continue()
15761585
'2 PUSHNR 2\_s*' ..
15771586
'3 NEWLIST size 2\_s*' ..
15781587
'4 FOR $0 -> 22\_s*' ..
1579-
'5 STORE $1\_s*' ..
1588+
'5 STORE $2\_s*' ..
1589+
15801590
'try\_s*' ..
15811591
'6 TRY catch -> 17, endtry -> 20\_s*' ..
1592+
15821593
'echo "ok"\_s*' ..
15831594
'7 PUSHS "ok"\_s*' ..
15841595
'8 ECHO 1\_s*' ..
1596+
15851597
'try\_s*' ..
15861598
'9 TRY catch -> 13, endtry -> 15\_s*' ..
1599+
15871600
'echo "deeper"\_s*' ..
15881601
'10 PUSHS "deeper"\_s*' ..
15891602
'11 ECHO 1\_s*' ..
1603+
15901604
'catch\_s*' ..
15911605
'12 JUMP -> 15\_s*' ..
15921606
'13 CATCH\_s*' ..
1607+
15931608
'continue\_s*' ..
15941609
'14 TRY-CONTINUE 2 levels -> 4\_s*' ..
1610+
15951611
'endtry\_s*' ..
15961612
'15 ENDTRY\_s*' ..
1613+
15971614
'catch\_s*' ..
15981615
'16 JUMP -> 20\_s*' ..
15991616
'17 CATCH\_s*' ..
1617+
16001618
'echo "not ok"\_s*' ..
16011619
'18 PUSHS "not ok"\_s*' ..
16021620
'19 ECHO 1\_s*' ..
1621+
16031622
'endtry\_s*' ..
16041623
'20 ENDTRY\_s*' ..
1624+
16051625
'endfor\_s*' ..
16061626
'21 JUMP -> 4\_s*' ..
16071627
'\d\+ DROP\_s*' ..
@@ -2478,7 +2498,8 @@ def Test_silent_for()
24782498
'\d NEWLIST size 1\_s*' ..
24792499
'\d CMDMOD_REV\_s*' ..
24802500
'5 FOR $0 -> 8\_s*' ..
2481-
'\d STORE $1\_s*' ..
2501+
'\d STORE $2\_s*' ..
2502+
24822503
'endfor\_s*' ..
24832504
'\d JUMP -> 5\_s*' ..
24842505
'8 DROP\_s*' ..
@@ -2499,7 +2520,7 @@ def Test_silent_while()
24992520
'\d LOADG g:not\_s*' ..
25002521
'\d COND2BOOL\_s*' ..
25012522
'\d CMDMOD_REV\_s*' ..
2502-
'\d JUMP_IF_FALSE -> 6\_s*' ..
2523+
'\d WHILE $0 -> 6\_s*' ..
25032524

25042525
'endwhile\_s*' ..
25052526
'\d JUMP -> 0\_s*' ..
@@ -2691,17 +2712,17 @@ def Test_debug_for()
26912712
'4 STORE -1 in $0\_s*' ..
26922713
'5 PUSHNR 0\_s*' ..
26932714
'6 NEWLIST size 1\_s*' ..
2694-
'7 DEBUG line 2-2 varcount 2\_s*' ..
2715+
'7 DEBUG line 2-2 varcount 3\_s*' ..
26952716
'8 FOR $0 -> 15\_s*' ..
2696-
'9 STORE $1\_s*' ..
2717+
'9 STORE $2\_s*' ..
26972718

26982719
'echo a\_s*' ..
2699-
'10 DEBUG line 3-3 varcount 2\_s*' ..
2700-
'11 LOAD $1\_s*' ..
2720+
'10 DEBUG line 3-3 varcount 3\_s*' ..
2721+
'11 LOAD $2\_s*' ..
27012722
'12 ECHO 1\_s*' ..
27022723

27032724
'endfor\_s*' ..
2704-
'13 DEBUG line 4-4 varcount 2\_s*' ..
2725+
'13 DEBUG line 4-4 varcount 3\_s*' ..
27052726
'14 JUMP -> 7\_s*' ..
27062727
'15 DROP\_s*' ..
27072728
'16 RETURN void*',

src/testdir/test_window_cmd.vim

+26
Original file line numberDiff line numberDiff line change
@@ -1770,4 +1770,30 @@ func Test_splitscroll_with_splits()
17701770
set splitscroll&
17711771
endfunc
17721772

1773+
function Test_nosplitscroll_cmdwin_cursor_position()
1774+
set nosplitscroll
1775+
call setline(1, range(&lines))
1776+
1777+
" No scroll when cursor is at near bottom of window and cusor position
1778+
" recompution (done by line('w0') in this test) happens while in cmdwin.
1779+
normal! G
1780+
let firstline = line('w0')
1781+
autocmd CmdwinEnter * ++once autocmd WinEnter * ++once call line('w0')
1782+
execute "normal! q:\<C-w>q"
1783+
redraw!
1784+
call assert_equal(firstline, line('w0'))
1785+
1786+
" User script can change cursor position successfully while in cmdwin and it
1787+
" shouldn't be changed when closing cmdwin.
1788+
execute "normal! Gq:\<Cmd>call win_execute(winnr('#')->win_getid(), 'call cursor(1, 1)')\<CR>\<C-w>q"
1789+
call assert_equal(1, line('.'))
1790+
call assert_equal(1, col('.'))
1791+
1792+
execute "normal! Gq:\<Cmd>autocmd WinEnter * ++once call cursor(1, 1)\<CR>\<C-w>q"
1793+
call assert_equal(1, line('.'))
1794+
call assert_equal(1, col('.'))
1795+
1796+
%bwipeout!
1797+
set splitscroll&
1798+
endfunction
17731799
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

+6
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,12 @@ static char *(features[]) =
718718

719719
static int included_patches[] =
720720
{ /* Add new patch number below this line */
721+
/**/
722+
472,
723+
/**/
724+
471,
725+
/**/
726+
470,
721727
/**/
722728
469,
723729
/**/

src/vim9.h

+29-2
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ typedef enum {
122122

123123
// loop
124124
ISN_FOR, // get next item from a list, uses isn_arg.forloop
125+
ISN_WHILE, // jump if condition false, store funcref count, uses
126+
// isn_arg.whileloop
127+
ISN_ENDLOOP, // handle variables for closures, uses isn_arg.endloop
125128

126129
ISN_TRY, // add entry to ec_trystack, uses isn_arg.tryref
127130
ISN_THROW, // pop value of stack, store in v:exception
@@ -240,6 +243,7 @@ typedef enum {
240243
JUMP_ALWAYS,
241244
JUMP_NEVER,
242245
JUMP_IF_FALSE, // pop and jump if false
246+
JUMP_WHILE_FALSE, // pop and jump if false for :while
243247
JUMP_AND_KEEP_IF_TRUE, // jump if top of stack is truthy, drop if not
244248
JUMP_IF_COND_TRUE, // jump if top of stack is true, drop if not
245249
JUMP_IF_COND_FALSE, // jump if top of stack is false, drop if not
@@ -263,6 +267,19 @@ typedef struct {
263267
int for_end; // position to jump to after done
264268
} forloop_T;
265269

270+
// arguments to ISN_WHILE
271+
typedef struct {
272+
int while_funcref_idx; // variable index for funcref count
273+
int while_end; // position to jump to after done
274+
} whileloop_T;
275+
276+
// arguments to ISN_ENDLOOP
277+
typedef struct {
278+
short end_funcref_idx; // variable index of funcrefs.ga_len
279+
short end_var_idx; // first variable declared in the loop
280+
short end_var_count; // number of variables declared in the loop
281+
} endloop_T;
282+
266283
// indirect arguments to ISN_TRY
267284
typedef struct {
268285
int try_catch; // position to jump to on throw
@@ -446,6 +463,8 @@ struct isn_S {
446463
jump_T jump;
447464
jumparg_T jumparg;
448465
forloop_T forloop;
466+
whileloop_T whileloop;
467+
endloop_T endloop;
449468
try_T tryref;
450469
trycont_T trycont;
451470
cbfunc_T bfunc;
@@ -597,6 +616,9 @@ typedef struct {
597616
typedef struct {
598617
int ws_top_label; // instruction idx at WHILE
599618
endlabel_T *ws_end_label; // instructions to set end
619+
int ws_funcref_idx; // index of var that holds funcref count
620+
int ws_local_count; // ctx_locals.ga_len at :while
621+
int ws_closure_count; // ctx_closure_count at :while
600622
} whilescope_T;
601623

602624
/*
@@ -605,6 +627,9 @@ typedef struct {
605627
typedef struct {
606628
int fs_top_label; // instruction idx at FOR
607629
endlabel_T *fs_end_label; // break instructions
630+
int fs_funcref_idx; // index of var that holds funcref count
631+
int fs_local_count; // ctx_locals.ga_len at :for
632+
int fs_closure_count; // ctx_closure_count at :for
608633
} forscope_T;
609634

610635
/*
@@ -726,8 +751,10 @@ struct cctx_S {
726751

727752
garray_T ctx_locals; // currently visible local variables
728753

729-
int ctx_has_closure; // set to one if a closure was created in
730-
// the function
754+
int ctx_has_closure; // set to one if a FUNCREF was used in the
755+
// function
756+
int ctx_closure_count; // incremented for each closure created in
757+
// the function.
731758

732759
skip_T ctx_skip;
733760
scope_T *ctx_scope; // current scope, NULL at toplevel

0 commit comments

Comments
 (0)