diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-11-12 15:12:15 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-11-12 15:12:15 +0100 |
commit | 47c5ea44b975adca00eaacecee5c4108996178d9 (patch) | |
tree | f34ffda43557f6eeb8e1ddf5cfd02a775f2d421e /src/terminal.c | |
parent | 957cf67d50516ba98716f59c9e1cb6412ec1535d (diff) | |
download | vim-git-47c5ea44b975adca00eaacecee5c4108996178d9.tar.gz |
patch 8.2.1979: "term_opencmd" option of term_start() is truncatedv8.2.1979
Problem: "term_opencmd" option of term_start() is truncated. (Sergey
Vlasov)
Solution: Allocate the buffer to hold the command. (closes #7284)
Diffstat (limited to 'src/terminal.c')
-rw-r--r-- | src/terminal.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/terminal.c b/src/terminal.c index 0fb9f485a..4e2ff14dd 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -3450,15 +3450,19 @@ term_after_channel_closed(term_T *term) if (term->tl_finish == TL_FINISH_OPEN && term->tl_buffer->b_nwindows == 0) { - char buf[50]; - - // TODO: use term_opencmd - ch_log(NULL, "terminal job finished, opening window"); - vim_snprintf(buf, sizeof(buf), - term->tl_opencmd == NULL - ? "botright sbuf %d" - : (char *)term->tl_opencmd, fnum); - do_cmdline_cmd((char_u *)buf); + char *cmd = term->tl_opencmd == NULL + ? "botright sbuf %d" + : (char *)term->tl_opencmd; + size_t len = strlen(cmd) + 50; + char *buf = alloc(len); + + if (buf != NULL) + { + ch_log(NULL, "terminal job finished, opening window"); + vim_snprintf(buf, len, cmd, fnum); + do_cmdline_cmd((char_u *)buf); + vim_free(buf); + } } else ch_log(NULL, "terminal job finished"); |