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 17, 2022
2 parents a9ac6c8 + c249913 commit 45b74e3
Show file tree
Hide file tree
Showing 36 changed files with 637 additions and 320 deletions.
14 changes: 10 additions & 4 deletions runtime/doc/builtin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ foldlevel({lnum}) Number fold level at {lnum}
foldtext() String line displayed for closed fold
foldtextresult({lnum}) String text for closed fold at {lnum}
foreground() Number bring the Vim window to the foreground
fullcommand({name}) String get full command from {name}
fullcommand({name} [, {vim9}]) String get full command from {name}
funcref({name} [, {arglist}] [, {dict}])
Funcref reference to function {name}
function({name} [, {arglist}] [, {dict}])
Expand Down Expand Up @@ -2967,14 +2967,20 @@ foreground() Move the Vim window to the foreground. Useful when sent from
{only in the Win32, Motif and GTK GUI versions and the
Win32 console version}

fullcommand({name}) *fullcommand()*
fullcommand({name} [, {vim9}]) *fullcommand()*
Get the full command name from a short abbreviated command
name; see |20.2| for details on command abbreviations.

The string argument {name} may start with a `:` and can
include a [range], these are skipped and not returned.
Returns an empty string if a command doesn't exist or if it's
ambiguous (for user-defined commands).
Returns an empty string if a command doesn't exist, if it's
ambiguous (for user-defined commands) or cannot be shortened
this way. |vim9-no-shorten|

Without the {vim9} argument uses the current script version.
If {vim9} is present and FALSE then legacy script rules are
used. When {vim9} is present and TRUE then Vim9 rules are
used, e.g. "en" is not a short form of "endif".

For example `fullcommand('s')`, `fullcommand('sub')`,
`fullcommand(':%substitute')` all return "substitute".
Expand Down
3 changes: 3 additions & 0 deletions runtime/filetype.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2108,6 +2108,9 @@ au BufNewFile,BufRead */.config/upstart/*.override setf upstart
" Vala
au BufNewFile,BufRead *.vala setf vala

" VDF
au BufNewFile,BufRead *.vdf setf vdf

" VDM
au BufRead,BufNewFile *.vdmpp,*.vpp setf vdmpp
au BufRead,BufNewFile *.vdmrt setf vdmrt
Expand Down
2 changes: 1 addition & 1 deletion runtime/optwin.vim
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ call <SID>AddOption("splitbelow", gettext("a new window is put below the current
call <SID>BinOptionG("sb", &sb)
call <SID>AddOption("splitright", gettext("a new window is put right of the current one"))
call <SID>BinOptionG("spr", &spr)
call <SID>AddOption("splitscroll", gettext("determines scroll behavior when spliting windows"))
call <SID>AddOption("splitscroll", gettext("determines scroll behavior for split windows"))
call <SID>BinOptionG("spsc", &spsc)
call <SID>AddOption("scrollbind", gettext("this window scrolls together with other bound windows"))
call append("$", "\t" .. s:local_to_window)
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4258,7 +4258,7 @@ objects/vim9type.o: vim9type.c vim.h protodef.h auto/config.h feature.h os_unix.
os_mac.h ascii.h keymap.h termdefs.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h libvterm/include/vterm.h \
libvterm/include/vterm_keycodes.h alloc.h ex_cmds.h spell.h proto.h \
globals.h errors.h
globals.h errors.h vim9.h
objects/viminfo.o: viminfo.c vim.h protodef.h auto/config.h feature.h os_unix.h \
os_mac.h ascii.h keymap.h termdefs.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h libvterm/include/vterm.h \
Expand Down
2 changes: 1 addition & 1 deletion src/evalfunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1853,7 +1853,7 @@ static funcentry_T global_functions[] =
ret_string, f_foldtextresult},
{"foreground", 0, 0, 0, NULL,
ret_void, f_foreground},
{"fullcommand", 1, 1, FEARG_1, arg1_string,
{"fullcommand", 1, 2, FEARG_1, arg2_string_bool,
ret_string, f_fullcommand},
{"funcref", 1, 3, FEARG_1, arg3_any_list_dict,
ret_func_unknown, f_funcref},
Expand Down
30 changes: 23 additions & 7 deletions src/ex_docmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -4054,31 +4054,45 @@ cmd_exists(char_u *name)
void
f_fullcommand(typval_T *argvars, typval_T *rettv)
{
exarg_T ea;
char_u *name;
char_u *p;
exarg_T ea;
char_u *name;
char_u *p;
int vim9script = in_vim9script();
int save_cmod_flags = cmdmod.cmod_flags;

rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;

if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
if (in_vim9script()
&& (check_for_string_arg(argvars, 0) == FAIL
|| check_for_opt_bool_arg(argvars, 1) == FAIL))
return;

name = argvars[0].vval.v_string;
if (name == NULL)
return;

if (argvars[1].v_type != VAR_UNKNOWN)
{
vim9script = tv_get_bool(&argvars[1]);
cmdmod.cmod_flags &= ~(CMOD_VIM9CMD | CMOD_LEGACY);
cmdmod.cmod_flags |= vim9script ? CMOD_VIM9CMD : CMOD_LEGACY;
}

while (*name == ':')
name++;
name = skip_range(name, TRUE, NULL);

ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name;
ea.cmdidx = (cmdidx_T)0;
ea.addr_count = 0;
++emsg_silent; // don't complain about using "en" in Vim9 script
p = find_ex_command(&ea, NULL, NULL, NULL);
--emsg_silent;
if (p == NULL || ea.cmdidx == CMD_SIZE)
return;
if (in_vim9script())
goto theend;

if (vim9script)
{
int res;

Expand All @@ -4087,12 +4101,14 @@ f_fullcommand(typval_T *argvars, typval_T *rettv)
--emsg_silent;

if (res == FAIL)
return;
goto theend;
}

rettv->vval.v_string = vim_strsave(IS_USER_CMDIDX(ea.cmdidx)
? get_user_command_name(ea.useridx, ea.cmdidx)
: cmdnames[ea.cmdidx].cmd_name);
theend:
cmdmod.cmod_flags = save_cmod_flags;
}
#endif

Expand Down
28 changes: 19 additions & 9 deletions src/move.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,19 +470,29 @@ check_top_offset(void)
return FALSE;
}

/*
* Update w_curswant.
*/
void
update_curswant(void)
update_curswant_force(void)
{
if (curwin->w_set_curswant)
{
validate_virtcol();
curwin->w_curswant = curwin->w_virtcol
validate_virtcol();
curwin->w_curswant = curwin->w_virtcol
#ifdef FEAT_PROP_POPUP
- curwin->w_virtcol_first_char
- curwin->w_virtcol_first_char
#endif
;
curwin->w_set_curswant = FALSE;
}
;
curwin->w_set_curswant = FALSE;
}

/*
* Update w_curswant if w_set_curswant is set.
*/
void
update_curswant(void)
{
if (curwin->w_set_curswant)
update_curswant_force();
}

/*
Expand Down
48 changes: 29 additions & 19 deletions src/normal.c
Original file line number Diff line number Diff line change
Expand Up @@ -5503,9 +5503,8 @@ nv_visual(cmdarg_T *cap)
{
if (resel_VIsual_line_count <= 1)
{
validate_virtcol();
curwin->w_curswant = curwin->w_virtcol
+ resel_VIsual_vcol * cap->count0 - 1;
update_curswant_force();
curwin->w_curswant += resel_VIsual_vcol * cap->count0 - 1;
}
else
curwin->w_curswant = resel_VIsual_vcol;
Expand All @@ -5518,9 +5517,8 @@ nv_visual(cmdarg_T *cap)
}
else if (VIsual_mode == Ctrl_V)
{
validate_virtcol();
curwin->w_curswant = curwin->w_virtcol
+ resel_VIsual_vcol * cap->count0 - 1;
update_curswant_force();
curwin->w_curswant += + resel_VIsual_vcol * cap->count0 - 1;
coladvance(curwin->w_curswant);
}
else
Expand Down Expand Up @@ -5747,13 +5745,19 @@ nv_g_home_m_cmd(cmdarg_T *cap)
cap->oap->inclusive = FALSE;
if (curwin->w_p_wrap && curwin->w_width != 0)
{
int width1 = curwin->w_width - curwin_col_off();
int width2 = width1 + curwin_col_off2();
int width1 = curwin->w_width - curwin_col_off();
int width2 = width1 + curwin_col_off2();
int virtcol;

validate_virtcol();
virtcol = curwin->w_virtcol
#ifdef FEAT_PROP_POPUP
- curwin->w_virtcol_first_char
#endif
;
i = 0;
if (curwin->w_virtcol >= (colnr_T)width1 && width2 > 0)
i = (curwin->w_virtcol - width1) / width2 * width2 + width1;
if (virtcol >= (colnr_T)width1 && width2 > 0)
i = (virtcol - width1) / width2 * width2 + width1;
}
else
i = curwin->w_leftcol;
Expand Down Expand Up @@ -5827,24 +5831,32 @@ nv_g_dollar_cmd(cmdarg_T *cap)
{
int width1 = curwin->w_width - col_off;
int width2 = width1 + curwin_col_off2();
int virtcol;

validate_virtcol();
virtcol = curwin->w_virtcol
#ifdef FEAT_PROP_POPUP
- curwin->w_virtcol_first_char
#endif
;
i = width1 - 1;
if (curwin->w_virtcol >= (colnr_T)width1)
i += ((curwin->w_virtcol - width1) / width2 + 1)
if (virtcol >= (colnr_T)width1)
i += ((virtcol - width1) / width2 + 1)
* width2;
coladvance((colnr_T)i);

// Make sure we stick in this column.
validate_virtcol();
curwin->w_curswant = curwin->w_virtcol;
curwin->w_set_curswant = FALSE;
update_curswant_force();
if (curwin->w_cursor.col > 0 && curwin->w_p_wrap)
{
// Check for landing on a character that got split at
// the end of the line. We do not want to advance to
// the next screen line.
if (curwin->w_virtcol > (colnr_T)i)
if (curwin->w_virtcol
#ifdef FEAT_PROP_POPUP
- curwin->w_virtcol_first_char
#endif
> (colnr_T)i)
--curwin->w_cursor.col;
}
}
Expand Down Expand Up @@ -5872,9 +5884,7 @@ nv_g_dollar_cmd(cmdarg_T *cap)
}

// Make sure we stick in this column.
validate_virtcol();
curwin->w_curswant = curwin->w_virtcol;
curwin->w_set_curswant = FALSE;
update_curswant_force();
}
}

Expand Down
12 changes: 10 additions & 2 deletions src/ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,8 @@ op_replace(oparg_T *oap, int c)

while (LTOREQ_POS(curwin->w_cursor, oap->end))
{
int done = FALSE;

n = gchar_cursor();
if (n != NUL)
{
Expand All @@ -1186,6 +1188,7 @@ op_replace(oparg_T *oap, int c)
if (curwin->w_cursor.lnum == oap->end.lnum)
oap->end.col += new_byte_len - old_byte_len;
replace_character(c);
done = TRUE;
}
else
{
Expand All @@ -1204,10 +1207,15 @@ op_replace(oparg_T *oap, int c)
if (curwin->w_cursor.lnum == oap->end.lnum)
getvpos(&oap->end, end_vcol);
}
PBYTE(curwin->w_cursor, c);
// with "coladd" set may move to just after a TAB
if (gchar_cursor() != NUL)
{
PBYTE(curwin->w_cursor, c);
done = TRUE;
}
}
}
else if (virtual_op && curwin->w_cursor.lnum == oap->end.lnum)
if (!done && virtual_op && curwin->w_cursor.lnum == oap->end.lnum)
{
int virtcols = oap->end.coladd;

Expand Down
1 change: 1 addition & 0 deletions src/proto/move.pro
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
void redraw_for_cursorline(win_T *wp);
void update_topline_redraw(void);
void update_topline(void);
void update_curswant_force(void);
void update_curswant(void);
void check_cursor_moved(win_T *wp);
void changed_window_setting(void);
Expand Down
2 changes: 1 addition & 1 deletion src/proto/userfunc.pro
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ int func_is_global(ufunc_T *ufunc);
int func_requires_g_prefix(ufunc_T *ufunc);
int func_name_refcount(char_u *name);
void func_clear_free(ufunc_T *fp, int force);
int copy_func(char_u *lambda, char_u *global, ectx_T *ectx);
int copy_lambda_to_global_func(char_u *lambda, char_u *global, short loop_var_idx, short loop_var_count, ectx_T *ectx);
int funcdepth_increment(void);
void funcdepth_decrement(void);
int funcdepth_get(void);
Expand Down
2 changes: 2 additions & 0 deletions src/proto/vim9cmds.pro
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ char_u *compile_for(char_u *arg_start, cctx_T *cctx);
char_u *compile_endfor(char_u *arg, cctx_T *cctx);
char_u *compile_while(char_u *arg, cctx_T *cctx);
char_u *compile_endwhile(char_u *arg, cctx_T *cctx);
short get_loop_var_info(cctx_T *cctx, short *loop_var_idx);
int get_loop_var_idx(cctx_T *cctx);
char_u *compile_continue(char_u *arg, cctx_T *cctx);
char_u *compile_break(char_u *arg, cctx_T *cctx);
char_u *compile_block(char_u *arg, cctx_T *cctx);
Expand Down
2 changes: 1 addition & 1 deletion src/proto/vim9execute.pro
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void restore_current_ectx(ectx_T *ectx);
int add_defer_function(char_u *name, int argcount, typval_T *argvars);
char_u *char_from_string(char_u *str, varnumber_T index);
char_u *string_slice(char_u *str, varnumber_T first, varnumber_T last, int exclusive);
int fill_partial_and_closure(partial_T *pt, ufunc_T *ufunc, ectx_T *ectx);
int fill_partial_and_closure(partial_T *pt, ufunc_T *ufunc, short loop_var_idx, short loop_var_count, ectx_T *ectx);
int may_load_script(int sid, int *loaded);
typval_T *lookup_debug_var(char_u *name);
int may_break_in_function(ufunc_T *ufunc);
Expand Down
4 changes: 2 additions & 2 deletions src/proto/vim9instr.pro
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int generate_CHECKLEN(cctx_T *cctx, int min_len, int more_OK);
int generate_STORE(cctx_T *cctx, isntype_T isn_type, int idx, char_u *name);
int generate_STORENR(cctx_T *cctx, int idx, varnumber_T value);
int generate_LOAD(cctx_T *cctx, isntype_T isn_type, int idx, char_u *name, type_T *type);
int generate_LOADOUTER(cctx_T *cctx, int idx, int nesting, type_T *type);
int generate_LOADOUTER(cctx_T *cctx, int idx, int nesting, int loop_idx, type_T *type);
int generate_LOADV(cctx_T *cctx, char_u *name);
int generate_UNLET(cctx_T *cctx, isntype_T isn_type, char_u *name, int forceit);
int generate_LOCKCONST(cctx_T *cctx);
Expand All @@ -40,7 +40,7 @@ int generate_VIM9SCRIPT(cctx_T *cctx, isntype_T isn_type, int sid, int idx, type
int generate_NEWLIST(cctx_T *cctx, int count, int use_null);
int generate_NEWDICT(cctx_T *cctx, int count, int use_null);
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_NEWFUNC(cctx_T *cctx, char_u *lambda_name, char_u *func_name, short loop_var_idx, short loop_var_count);
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);
Expand Down
4 changes: 2 additions & 2 deletions src/regexp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1817,14 +1817,14 @@ static regsubmatch_T rsm; // can only be used when can_f_submatch is TRUE
* call_func() by vim_regsub_both().
*/
static int
fill_submatch_list(int argc UNUSED, typval_T *argv, int argskip, int argcount)
fill_submatch_list(int argc UNUSED, typval_T *argv, int argskip, ufunc_T *fp)
{
listitem_T *li;
int i;
char_u *s;
typval_T *listarg = argv + argskip;

if (argcount == argskip)
if (!has_varargs(fp) && fp->uf_args.ga_len <= argskip)
// called function doesn't take a submatches argument
return argskip;

Expand Down
Loading

0 comments on commit 45b74e3

Please sign in to comment.