aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2023-08-28 07:22:19 -0500
committerGitHub <noreply@github.com>2023-08-28 07:22:19 -0500
commitcffdf102d4f01fe5675c389eb80bf55daa62697a (patch)
tree27ff257e8e9022d5ff80deaca071bb88c5c8119c /src
parent1ad13e07d2d9a01fbadd59a84af601b2ab0d8c73 (diff)
downloadrneovim-cffdf102d4f01fe5675c389eb80bf55daa62697a.tar.gz
rneovim-cffdf102d4f01fe5675c389eb80bf55daa62697a.tar.bz2
rneovim-cffdf102d4f01fe5675c389eb80bf55daa62697a.zip
feat(terminal): allow :terminal to take modifiers (#15427)
The following modifiers are all now supported: :tab term :vertical term :horizontal term :botright term :topleft term Fixes: https://github.com/neovim/neovim/issues/11385
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_docmd.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index aba50b2042..3ff1442640 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -7302,12 +7302,31 @@ void set_pressedreturn(bool val)
static void ex_terminal(exarg_T *eap)
{
char ex_cmd[1024];
+ size_t len = 0;
+
+ if (cmdmod.cmod_tab > 0 || cmdmod.cmod_split != 0) {
+ bool multi_mods = false;
+
+ // ex_cmd must be a null terminated string before passing to add_win_cmd_modifiers
+ ex_cmd[0] = '\0';
+
+ len = add_win_cmd_modifiers(ex_cmd, &cmdmod, &multi_mods);
+ assert(len < sizeof(ex_cmd));
+ int result = snprintf(ex_cmd + len, sizeof(ex_cmd) - len, " new");
+ assert(result > 0);
+ len += (size_t)result;
+ } else {
+ int result = snprintf(ex_cmd, sizeof(ex_cmd), "enew%s", eap->forceit ? "!" : "");
+ assert(result > 0);
+ len += (size_t)result;
+ }
+
+ assert(len < sizeof(ex_cmd));
if (*eap->arg != NUL) { // Run {cmd} in 'shell'.
char *name = vim_strsave_escaped(eap->arg, "\"\\");
- snprintf(ex_cmd, sizeof(ex_cmd),
- ":enew%s | call termopen(\"%s\")",
- eap->forceit ? "!" : "", name);
+ snprintf(ex_cmd + len, sizeof(ex_cmd) - len,
+ " | call termopen(\"%s\")", name);
xfree(name);
} else { // No {cmd}: run the job with tokenized 'shell'.
if (*p_sh == NUL) {
@@ -7327,9 +7346,8 @@ static void ex_terminal(exarg_T *eap)
}
shell_free_argv(argv);
- snprintf(ex_cmd, sizeof(ex_cmd),
- ":enew%s | call termopen([%s])",
- eap->forceit ? "!" : "", shell_argv + 1);
+ snprintf(ex_cmd + len, sizeof(ex_cmd) - len,
+ " | call termopen([%s])", shell_argv + 1);
}
do_cmdline_cmd(ex_cmd);