[vim/vim] Fix mksession with same terminal in shared windows (PR #21224)

11 views
Skip to first unread message

Niklas Lindström

unread,
Sep 4, 2026, 5:08:20 PM (2 days ago) Sep 4
to vim/vim, Subscribed

Problem

Vim session files use vim9script, which requires the .. string concatenation syntax, but the legacy . form is currently used when making a session file from a state where one Vim terminal is shared in multiple windows.

Steps to reproduce

Go to a test directory , launch vim, open a vim terminal, split its window, make a session file, then quit. Sourcing the created session file will fail during execution with error E15: Invalid expression: ". term_buf_2". Like this:

$ cd "$(mktemp -d)"
$ vim --clean -c 'exec "term"|sp|mksession!|qa!'
$ vim --clean -S Session.vim

Solution

  • Change to the .. form in the specific part of the term_write_session function where the legacy form was still used.
  • Amend the existing test to check for this form, and add sourcing of the resulting session file to ensure it is valid.

You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/21224

Commit Summary

  • 21f4d78 Fix mksession with same terminal in shared windows

File Changes

(2 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/21224@github.com>

Mao-Yining

unread,
Sep 5, 2026, 6:23:46 AM (yesterday) Sep 5
to vim/vim, Subscribed
mao-yining left a comment (vim/vim#21224)
Just think this looks nicer, purely a style thing.

________________________________
发件人: Niklas Lindstr?m ***@***.***>
发送时间: Saturday, 05 September 2026 17:42:58
收件人: vim/vim ***@***.***>
抄送: Mao-Yining ***@***.***>; Comment ***@***.***>
主题: Re: [vim/vim] Fix mksession with same terminal in shared windows (PR #21224)


@niklasl commented on this pull request.

________________________________

In src/terminal.c<https://github.com/vim/vim/pull/21224#discussion_r3940179810>:

> @@ -1107,7 +1107,7 @@ term_write_session(FILE *fd, win_T *wp, hashtab_T *terminal_bufs)
if (!HASHITEM_EMPTY(entry))
{
// we've already opened this terminal buffer
- if (fprintf(fd, "execute 'buffer ' . term_buf_%d", bufnr) < 0)
+ if (fprintf(fd, "execute 'buffer ' .. term_buf_%d", bufnr) < 0)


Amending my observation: that's not string concatenation, it's multiple arguments to execute, of course, and I missed your adjusted prior space (sorry)! I still think the consistency argument still holds though, and would probably prefer a separate (lower priority) style change PR, if that's desired.


Reply to this email directly, view it on GitHub<https://github.com/vim/vim/pull/21224#discussion_r3940179810>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AYJDXIU4ELEE66LPG3GF7UL5NPN2FAVCNFSNUABEKJSXA33TNF2G64TZHM2DAOJZG42DQMR3JFZXG5LFHM2TGNJTGA3DSMZTHGQXMAQ>.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS<https://github.com/notifications/mobile/ios/AYJDXIR5CIAGOQE6LINVNWL5NPN2FA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTKMJSGA3TGMJZHA2KM4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJKTGN5XXIZLSL5UW64Y> and Android<https://github.com/notifications/mobile/android/AYJDXIRL6SIXKLQHFWN3BOL5NPN2FA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTKMJSGA3TGMJZHA2KM4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI>. Download it today!
You are receiving this because you commented.Message ID: ***@***.***>


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/21224/c5551146747@github.com>

Reply all
Reply to author
Forward
0 new messages