From: Arkissa Date: Sun, 19 Jul 2026 18:30:01 +0000 (+0000) Subject: patch 9.2.0811: mksession writes terminal command unquoted X-Git-Tag: v9.2.0811^0 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=9fa3a02c6f519a5541e7bd5acd2b2ac11831aaa5;p=thirdparty%2Fvim.git patch 9.2.0811: mksession writes terminal command unquoted Problem: mksession writes terminal command unquoted (after v9.2.0732) Solution: Quote the terminal command (Arkissa) fixes: #20788 closes: #20789 Signed-off-by: Arkissa Signed-off-by: Christian Brabandt --- diff --git a/src/terminal.c b/src/terminal.c index 2a2932a884..f136e1efbd 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -1126,8 +1126,18 @@ term_write_session(FILE *fd, win_T *wp, hashtab_T *terminal_bufs) if (fprintf(fd, ".. ' ++type=%s' ", term->tl_job->jv_tty_type) < 0) return FAIL; # endif - if (term->tl_command != NULL && fputs((char *)term->tl_command, fd) < 0) - return FAIL; + if (term->tl_command != NULL) + { + char_u *quoted_command = string_quote(term->tl_command, FALSE); + if (quoted_command == NULL) + return FAIL; + + int ret = fputs(".. ' ' .. ", fd) < 0 + || fputs((char *)quoted_command, fd) < 0; + vim_free(quoted_command); + if (ret) + return FAIL; + } if (put_eol(fd) != OK) return FAIL; diff --git a/src/testdir/test_mksession.vim b/src/testdir/test_mksession.vim index 179cbd3242..f7384f601e 100644 --- a/src/testdir/test_mksession.vim +++ b/src/testdir/test_mksession.vim @@ -613,6 +613,54 @@ func Test_mksession_terminal_shared_windows() call delete('Xtest_mks.out') endfunc +func Test_mksession_terminal_shell_command() + CheckFeature terminal + + set sessionoptions+=terminal + terminal + let term_buf = bufnr() + eval term_buf->term_setrestore('echo HELLO_WORLD') + mksession! Xtest_mks.out + + call StopShellInTerminal(term_buf) + + source Xtest_mks.out + + let restored_buf = bufnr() + call assert_equal('terminal', getbufvar(restored_buf, '&buftype')) + call WaitForAssert({-> assert_match( + \ 'HELLO_WORLD', + \ term_getline(restored_buf, 1))}) + call WaitForAssert({-> assert_match( + \ 'finished', + \ term_getstatus(restored_buf))}) + + bwipe! + call delete('Xtest_mks.out') +endfunc + +" Plain :terminal stores no command (tl_command == NULL), so nothing is +" written after the ':terminal ++curwin ...' line. Restoring must still +" produce a running shell terminal. +func Test_mksession_terminal_default_restore() + CheckFeature terminal + + terminal + let term_buf = bufnr() + mksession! Xtest_mks.out + call StopShellInTerminal(term_buf) + %bwipe! + + source Xtest_mks.out + let restored = bufnr() + call assert_equal('terminal', getbufvar(restored, '&buftype')) + call WaitForAssert({-> assert_match('running', term_getstatus(restored))}) + call StopShellInTerminal(restored) + + %bwipe! + call delete('Xtest_mks.out') +endfunc + func Test_mkview_terminal_windows() CheckFeature terminal diff --git a/src/version.c b/src/version.c index cf0d47a529..e523f6dad4 100644 --- a/src/version.c +++ b/src/version.c @@ -759,6 +759,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 811, /**/ 810, /**/