]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0592: Error when restoring session with terminal window v9.2.0592
authorFoxe Chen <chen.foxe@gmail.com>
Wed, 3 Jun 2026 18:57:17 +0000 (18:57 +0000)
committerChristian Brabandt <cb@256bit.org>
Wed, 3 Jun 2026 18:57:17 +0000 (18:57 +0000)
Problem:  Error when restoring session with terminal window
          (after v9.2.0579)
Solution: Convert to proper Vim9 script (Foxe Chen)

closes: #20416

Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/terminal.c
src/testdir/test_mksession.vim
src/version.c

index b748ed35f1bfe4782e6da0f40dd06c35d6358ba3..a22047506eff00b5ca7e4d1d1f171e4121fb9363 100644 (file)
@@ -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 ' . s:term_buf_%d", bufnr) < 0)
+           if (fprintf(fd, "execute 'buffer ' . term_buf_%d", bufnr) < 0)
                return FAIL;
            return put_eol(fd);
        }
@@ -1128,7 +1128,7 @@ term_write_session(FILE *fd, win_T *wp, hashtab_T *terminal_bufs)
     if (put_eol(fd) != OK)
        return FAIL;
 
-    if (fprintf(fd, "let s:term_buf_%d = bufnr()", bufnr) < 0)
+    if (fprintf(fd, "var term_buf_%d: number = bufnr()", bufnr) < 0)
        return FAIL;
 
     if (terminal_bufs != NULL && wp->w_buffer->b_nwindows > 1)
index 9bf1b47ff5332498bf8425c009ebe1ad9a320079..4dec8815a43525f7107a29fab741371fe102a68a 100644 (file)
@@ -581,17 +581,20 @@ func Test_mksession_terminal_shared_windows()
   let lines = readfile('Xtest_mks.out')
   let found_creation = 0
   let found_use = 0
+  let found_var = 0
 
   for line in lines
     if line =~ '^terminal'
       let found_creation = 1
       call assert_match('terminal ++curwin ++cols=\d\+ ++rows=\d\+', line)
-    elseif line =~ "^execute 'buffer ' . s:term_buf_" . term_buf . "$"
+    elseif line =~ $"^var term_buf_{term_buf}: number = bufnr()$"
+      let found_var = 1
+    elseif line =~ "^execute 'buffer ' . term_buf_" . term_buf . "$"
       let found_use = 1
     endif
   endfor
 
-  call assert_true(found_creation && found_use)
+  call assert_true(found_creation && found_use && found_var)
 
   call StopShellInTerminal(term_buf)
   call delete('Xtest_mks.out')
index e2999b0b230c3016bc7de389bf6a278e10505f2c..250b6381539c64461451bdb1cab28ffc24abd5ab 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    592,
 /**/
     591,
 /**/