Skip to content

Commit

Permalink
Merge remote-tracking branch 'vim/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ychin committed Sep 15, 2022
2 parents d404ddd + a4abe51 commit 4f8388f
Show file tree
Hide file tree
Showing 12 changed files with 361 additions and 58 deletions.
5 changes: 5 additions & 0 deletions src/drawline.c
Expand Up @@ -1888,6 +1888,11 @@ win_line(
p_extra_free2 = wlv.p_extra;
}

if (lcs_eol_one < 0 && wlv.col
+ wlv.n_extra - 2 > wp->w_width)
// don't bail out at end of line
lcs_eol_one = 0;

// When 'wrap' is off then for "below" we need
// to start a new line explictly.
if (start_line)
Expand Down
3 changes: 2 additions & 1 deletion src/proto/vim9instr.pro
Expand Up @@ -43,14 +43,15 @@ int generate_FUNCREF(cctx_T *cctx, ufunc_T *ufunc, isn_T **isnp);
int generate_NEWFUNC(cctx_T *cctx, char_u *lambda_name, char_u *func_name);
int generate_DEF(cctx_T *cctx, char_u *name, size_t len);
int generate_JUMP(cctx_T *cctx, jumpwhen_T when, int where);
int generate_WHILE(cctx_T *cctx, int funcref_idx);
int generate_JUMP_IF_ARG_SET(cctx_T *cctx, int arg_off);
int generate_FOR(cctx_T *cctx, int loop_idx);
int generate_ENDLOOP(cctx_T *cctx, int funcref_idx, int prev_local_count);
int generate_TRYCONT(cctx_T *cctx, int levels, int where);
int check_internal_func_args(cctx_T *cctx, int func_idx, int argcount, int method_call, type2_T **argtypes, type2_T *shuffled_argtypes);
int generate_BCALL(cctx_T *cctx, int func_idx, int argcount, int method_call);
int generate_LISTAPPEND(cctx_T *cctx);
int generate_BLOBAPPEND(cctx_T *cctx);
int check_args_on_stack(cctx_T *cctx, ufunc_T *ufunc, int argcount);
int generate_CALL(cctx_T *cctx, ufunc_T *ufunc, int pushed_argcount);
int generate_UCALL(cctx_T *cctx, char_u *name, int argcount);
int check_func_args_from_type(cctx_T *cctx, type_T *type, int argcount, int at_top, char_u *name);
Expand Down
8 changes: 8 additions & 0 deletions src/testdir/dumps/Test_prop_text_with_padding_4.dump
@@ -0,0 +1,8 @@
>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
@47|r+0&#ffd7ff255|i|g|h|t| |a|l|i|g|n|e|d
| +0&#ffffff0@3|b+0&#ffd7ff255|e|l|o|w| |t|h|e| |l|i|n|e| +0&#ffffff0@41
|s|e|c|o|n|d| |l|i|n|e|$+0#4040ff13&| +0#0000000&@47
|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
@51|r+0&#ffd7ff255|i|g|h|t|m|o|s|t
| +0&#ffffff0@59
|:|s|e|t| |l|i|s|t| @32|1|,|1| @10|A|l@1|
3 changes: 3 additions & 0 deletions src/testdir/test_textprop.vim
Expand Up @@ -3181,6 +3181,9 @@ func Test_insert_text_with_padding()
call term_sendkeys(buf, "ggix\<Esc>")
call VerifyScreenDump(buf, 'Test_prop_text_with_padding_3', {})

call term_sendkeys(buf, ":set list\<CR>")
call VerifyScreenDump(buf, 'Test_prop_text_with_padding_4', {})

call StopVimInTerminal(buf)
call delete('XscriptPropsPadded')
endfunc
Expand Down
49 changes: 35 additions & 14 deletions src/testdir/test_vim9_disassemble.vim
Expand Up @@ -1466,17 +1466,20 @@ def Test_disassemble_for_loop()
'\d NEWLIST size 0\_s*' ..
'\d SETTYPE list<number>\_s*' ..
'\d STORE $0\_s*' ..

'for i in range(3)\_s*' ..
'\d STORE -1 in $1\_s*' ..
'\d PUSHNR 3\_s*' ..
'\d BCALL range(argc 1)\_s*' ..
'\d FOR $1 -> \d\+\_s*' ..
'\d STORE $2\_s*' ..
'\d STORE $3\_s*' ..

'res->add(i)\_s*' ..
'\d LOAD $0\_s*' ..
'\d LOAD $2\_s*' ..
'\d LOAD $3\_s*' ..
'\d\+ LISTAPPEND\_s*' ..
'\d\+ DROP\_s*' ..

'endfor\_s*' ..
'\d\+ JUMP -> \d\+\_s*' ..
'\d\+ DROP',
Expand All @@ -1498,21 +1501,25 @@ def Test_disassemble_for_loop_eval()
'var res = ""\_s*' ..
'\d PUSHS ""\_s*' ..
'\d STORE $0\_s*' ..

'for str in eval(''\["one", "two"\]'')\_s*' ..
'\d STORE -1 in $1\_s*' ..
'\d PUSHS "\["one", "two"\]"\_s*' ..
'\d BCALL eval(argc 1)\_s*' ..
'\d FOR $1 -> \d\+\_s*' ..
'\d STORE $2\_s*' ..
'\d STORE $3\_s*' ..

'res ..= str\_s*' ..
'\d\+ LOAD $0\_s*' ..
'\d\+ LOAD $2\_s*' ..
'\d\+ LOAD $3\_s*' ..
'\d 2STRING_ANY stack\[-1\]\_s*' ..
'\d\+ CONCAT size 2\_s*' ..
'\d\+ STORE $0\_s*' ..

'endfor\_s*' ..
'\d\+ JUMP -> 5\_s*' ..
'\d\+ DROP\_s*' ..

'return res\_s*' ..
'\d\+ LOAD $0\_s*' ..
'\d\+ RETURN',
Expand All @@ -1539,12 +1546,14 @@ def Test_disassemble_for_loop_unpack()
'\d\+ NEWLIST size 2\_s*' ..
'\d\+ FOR $0 -> 16\_s*' ..
'\d\+ UNPACK 2\_s*' ..
'\d\+ STORE $1\_s*' ..
'\d\+ STORE $2\_s*' ..
'\d\+ STORE $3\_s*' ..

'echo x1 x2\_s*' ..
'\d\+ LOAD $1\_s*' ..
'\d\+ LOAD $2\_s*' ..
'\d\+ LOAD $3\_s*' ..
'\d\+ ECHO 2\_s*' ..

'endfor\_s*' ..
'\d\+ JUMP -> 8\_s*' ..
'\d\+ DROP\_s*' ..
Expand Down Expand Up @@ -1576,32 +1585,43 @@ def Test_disassemble_for_loop_continue()
'2 PUSHNR 2\_s*' ..
'3 NEWLIST size 2\_s*' ..
'4 FOR $0 -> 22\_s*' ..
'5 STORE $1\_s*' ..
'5 STORE $2\_s*' ..

'try\_s*' ..
'6 TRY catch -> 17, endtry -> 20\_s*' ..

'echo "ok"\_s*' ..
'7 PUSHS "ok"\_s*' ..
'8 ECHO 1\_s*' ..

'try\_s*' ..
'9 TRY catch -> 13, endtry -> 15\_s*' ..

'echo "deeper"\_s*' ..
'10 PUSHS "deeper"\_s*' ..
'11 ECHO 1\_s*' ..

'catch\_s*' ..
'12 JUMP -> 15\_s*' ..
'13 CATCH\_s*' ..

'continue\_s*' ..
'14 TRY-CONTINUE 2 levels -> 4\_s*' ..

'endtry\_s*' ..
'15 ENDTRY\_s*' ..

'catch\_s*' ..
'16 JUMP -> 20\_s*' ..
'17 CATCH\_s*' ..

'echo "not ok"\_s*' ..
'18 PUSHS "not ok"\_s*' ..
'19 ECHO 1\_s*' ..

'endtry\_s*' ..
'20 ENDTRY\_s*' ..

'endfor\_s*' ..
'21 JUMP -> 4\_s*' ..
'\d\+ DROP\_s*' ..
Expand Down Expand Up @@ -2478,7 +2498,8 @@ def Test_silent_for()
'\d NEWLIST size 1\_s*' ..
'\d CMDMOD_REV\_s*' ..
'5 FOR $0 -> 8\_s*' ..
'\d STORE $1\_s*' ..
'\d STORE $2\_s*' ..

'endfor\_s*' ..
'\d JUMP -> 5\_s*' ..
'8 DROP\_s*' ..
Expand All @@ -2499,7 +2520,7 @@ def Test_silent_while()
'\d LOADG g:not\_s*' ..
'\d COND2BOOL\_s*' ..
'\d CMDMOD_REV\_s*' ..
'\d JUMP_IF_FALSE -> 6\_s*' ..
'\d WHILE $0 -> 6\_s*' ..

'endwhile\_s*' ..
'\d JUMP -> 0\_s*' ..
Expand Down Expand Up @@ -2691,17 +2712,17 @@ def Test_debug_for()
'4 STORE -1 in $0\_s*' ..
'5 PUSHNR 0\_s*' ..
'6 NEWLIST size 1\_s*' ..
'7 DEBUG line 2-2 varcount 2\_s*' ..
'7 DEBUG line 2-2 varcount 3\_s*' ..
'8 FOR $0 -> 15\_s*' ..
'9 STORE $1\_s*' ..
'9 STORE $2\_s*' ..

'echo a\_s*' ..
'10 DEBUG line 3-3 varcount 2\_s*' ..
'11 LOAD $1\_s*' ..
'10 DEBUG line 3-3 varcount 3\_s*' ..
'11 LOAD $2\_s*' ..
'12 ECHO 1\_s*' ..

'endfor\_s*' ..
'13 DEBUG line 4-4 varcount 2\_s*' ..
'13 DEBUG line 4-4 varcount 3\_s*' ..
'14 JUMP -> 7\_s*' ..
'15 DROP\_s*' ..
'16 RETURN void*',
Expand Down
26 changes: 26 additions & 0 deletions src/testdir/test_window_cmd.vim
Expand Up @@ -1770,4 +1770,30 @@ func Test_splitscroll_with_splits()
set splitscroll&
endfunc

function Test_nosplitscroll_cmdwin_cursor_position()
set nosplitscroll
call setline(1, range(&lines))

" No scroll when cursor is at near bottom of window and cusor position
" recompution (done by line('w0') in this test) happens while in cmdwin.
normal! G
let firstline = line('w0')
autocmd CmdwinEnter * ++once autocmd WinEnter * ++once call line('w0')
execute "normal! q:\<C-w>q"
redraw!
call assert_equal(firstline, line('w0'))

" User script can change cursor position successfully while in cmdwin and it
" shouldn't be changed when closing cmdwin.
execute "normal! Gq:\<Cmd>call win_execute(winnr('#')->win_getid(), 'call cursor(1, 1)')\<CR>\<C-w>q"
call assert_equal(1, line('.'))
call assert_equal(1, col('.'))

execute "normal! Gq:\<Cmd>autocmd WinEnter * ++once call cursor(1, 1)\<CR>\<C-w>q"
call assert_equal(1, line('.'))
call assert_equal(1, col('.'))

%bwipeout!
set splitscroll&
endfunction
" vim: shiftwidth=2 sts=2 expandtab
6 changes: 6 additions & 0 deletions src/version.c
Expand Up @@ -718,6 +718,12 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
472,
/**/
471,
/**/
470,
/**/
469,
/**/
Expand Down
31 changes: 29 additions & 2 deletions src/vim9.h
Expand Up @@ -122,6 +122,9 @@ typedef enum {

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

ISN_TRY, // add entry to ec_trystack, uses isn_arg.tryref
ISN_THROW, // pop value of stack, store in v:exception
Expand Down Expand Up @@ -240,6 +243,7 @@ typedef enum {
JUMP_ALWAYS,
JUMP_NEVER,
JUMP_IF_FALSE, // pop and jump if false
JUMP_WHILE_FALSE, // pop and jump if false for :while
JUMP_AND_KEEP_IF_TRUE, // jump if top of stack is truthy, drop if not
JUMP_IF_COND_TRUE, // jump if top of stack is true, drop if not
JUMP_IF_COND_FALSE, // jump if top of stack is false, drop if not
Expand All @@ -263,6 +267,19 @@ typedef struct {
int for_end; // position to jump to after done
} forloop_T;

// arguments to ISN_WHILE
typedef struct {
int while_funcref_idx; // variable index for funcref count
int while_end; // position to jump to after done
} whileloop_T;

// arguments to ISN_ENDLOOP
typedef struct {
short end_funcref_idx; // variable index of funcrefs.ga_len
short end_var_idx; // first variable declared in the loop
short end_var_count; // number of variables declared in the loop
} endloop_T;

// indirect arguments to ISN_TRY
typedef struct {
int try_catch; // position to jump to on throw
Expand Down Expand Up @@ -446,6 +463,8 @@ struct isn_S {
jump_T jump;
jumparg_T jumparg;
forloop_T forloop;
whileloop_T whileloop;
endloop_T endloop;
try_T tryref;
trycont_T trycont;
cbfunc_T bfunc;
Expand Down Expand Up @@ -597,6 +616,9 @@ typedef struct {
typedef struct {
int ws_top_label; // instruction idx at WHILE
endlabel_T *ws_end_label; // instructions to set end
int ws_funcref_idx; // index of var that holds funcref count
int ws_local_count; // ctx_locals.ga_len at :while
int ws_closure_count; // ctx_closure_count at :while
} whilescope_T;

/*
Expand All @@ -605,6 +627,9 @@ typedef struct {
typedef struct {
int fs_top_label; // instruction idx at FOR
endlabel_T *fs_end_label; // break instructions
int fs_funcref_idx; // index of var that holds funcref count
int fs_local_count; // ctx_locals.ga_len at :for
int fs_closure_count; // ctx_closure_count at :for
} forscope_T;

/*
Expand Down Expand Up @@ -726,8 +751,10 @@ struct cctx_S {

garray_T ctx_locals; // currently visible local variables

int ctx_has_closure; // set to one if a closure was created in
// the function
int ctx_has_closure; // set to one if a FUNCREF was used in the
// function
int ctx_closure_count; // incremented for each closure created in
// the function.

skip_T ctx_skip;
scope_T *ctx_scope; // current scope, NULL at toplevel
Expand Down

0 comments on commit 4f8388f

Please sign in to comment.