mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
feat(api): nvim_cmd supports plus ("+cmd", "++opt") flags #30103
Problem: nvim_cmd does not handle plus flags. Solution: In nvim_cmd, parse the flags and set the relevant `ea` fields.
This commit is contained in:
@ -634,6 +634,22 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Arena
|
||||
build_cmdline_str(&cmdline, &ea, &cmdinfo, args);
|
||||
ea.cmdlinep = &cmdline;
|
||||
|
||||
// Check for "++opt=val" argument.
|
||||
if (ea.argt & EX_ARGOPT) {
|
||||
while (ea.arg[0] == '+' && ea.arg[1] == '+') {
|
||||
char *orig_arg = ea.arg;
|
||||
int result = getargopt(&ea);
|
||||
VALIDATE_S(result != FAIL || is_cmd_ni(ea.cmdidx), "argument ", orig_arg, {
|
||||
goto end;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Check for "+command" argument.
|
||||
if ((ea.argt & EX_CMDARG) && !ea.usefilter) {
|
||||
ea.do_ecmd_cmd = getargcmd(&ea.arg);
|
||||
}
|
||||
|
||||
garray_T capture_local;
|
||||
const int save_msg_silent = msg_silent;
|
||||
garray_T * const save_capture_ga = capture_ga;
|
||||
|
@ -4147,7 +4147,7 @@ void separate_nextcmd(exarg_T *eap)
|
||||
}
|
||||
|
||||
/// get + command from ex argument
|
||||
static char *getargcmd(char **argp)
|
||||
char *getargcmd(char **argp)
|
||||
{
|
||||
char *arg = *argp;
|
||||
char *command = NULL;
|
||||
@ -4222,7 +4222,7 @@ static char *get_bad_name(expand_T *xp FUNC_ATTR_UNUSED, int idx)
|
||||
/// Get "++opt=arg" argument.
|
||||
///
|
||||
/// @return FAIL or OK.
|
||||
static int getargopt(exarg_T *eap)
|
||||
int getargopt(exarg_T *eap)
|
||||
{
|
||||
char *arg = eap->arg + 2;
|
||||
int *pp = NULL;
|
||||
|
Reference in New Issue
Block a user