To: vim_dev@googlegroups.com Subject: Patch 8.2.1979 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1979 Problem: "term_opencmd" option of term_start() is truncated. (Sergey Vlasov) Solution: Allocate the buffer to hold the command. (closes #7284) Files: src/terminal.c, src/testdir/test_terminal.vim *** ../vim-8.2.1978/src/terminal.c 2020-11-12 14:20:32.025927280 +0100 --- src/terminal.c 2020-11-12 15:10:16.778082377 +0100 *************** *** 3450,3464 **** 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); } else ch_log(NULL, "terminal job finished"); --- 3450,3468 ---- if (term->tl_finish == TL_FINISH_OPEN && term->tl_buffer->b_nwindows == 0) { ! 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"); *** ../vim-8.2.1978/src/testdir/test_terminal.vim 2020-11-05 19:36:34.710317015 +0100 --- src/testdir/test_terminal.vim 2020-11-12 15:08:41.946317611 +0100 *************** *** 567,576 **** call assert_fails("call term_start(cmd, {'term_opencmd': 'split %d and %s'})", 'E475:') call assert_fails("call term_start(cmd, {'term_opencmd': 'split % and %d'})", 'E475:') ! call term_start(cmd, {'term_finish': 'open', 'term_opencmd': '4split | buffer %d'}) close! call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime) call assert_equal(4, winheight(0)) bwipe endfunc --- 567,578 ---- call assert_fails("call term_start(cmd, {'term_opencmd': 'split %d and %s'})", 'E475:') call assert_fails("call term_start(cmd, {'term_opencmd': 'split % and %d'})", 'E475:') ! call term_start(cmd, {'term_finish': 'open', 'term_opencmd': '4split | buffer %d | let g:result = "opened the buffer in a window"'}) close! call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime) call assert_equal(4, winheight(0)) + call assert_equal('opened the buffer in a window', g:result) + unlet g:result bwipe endfunc *** ../vim-8.2.1978/src/version.c 2020-11-12 14:20:32.025927280 +0100 --- src/version.c 2020-11-12 15:10:37.918029983 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 1979, /**/ -- "The amigos also appear to be guilty of not citing the work of others who had gone before them. Even worse, they have a chapter about modeling time and space without making a single reference to Star Trek!" (Scott Ambler, reviewing the UML User Guide) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///