changeset 26185:582218dbc6b3 v8.2.3624

patch 8.2.3624: when renaming a terminal buffer status text is not updated Commit: https://github.com/vim/vim/commit/3ad695328f94e0197e84454f125c7f3464091d0c Author: Bram Moolenaar <Bram@vim.org> Date: Fri Nov 19 17:01:08 2021 +0000 patch 8.2.3624: when renaming a terminal buffer status text is not updated Problem: When renaming a terminal buffer the status text is not updated. Solution: Clear the cached status text when renaming a terminal buffer. (closes #9162)
author Bram Moolenaar <Bram@vim.org>
date Fri, 19 Nov 2021 18:15:03 +0100
parents 9f38d23faea0
children f80b615131df
files src/buffer.c src/proto/terminal.pro src/terminal.c src/testdir/test_terminal.vim src/version.c
diffstat 5 files changed, 29 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -3453,6 +3453,11 @@ buf_name_changed(buf_T *buf)
     if (buf->b_ml.ml_mfp != NULL)
 	ml_setname(buf);
 
+#ifdef FEAT_TERMINAL
+    if (buf->b_term != NULL)
+	term_clear_status_text(buf->b_term);
+#endif
+
     if (curwin->w_buffer == buf)
 	check_arg_idx(curwin);	// check file name for arg list
 #ifdef FEAT_TITLE
--- a/src/proto/terminal.pro
+++ b/src/proto/terminal.pro
@@ -31,6 +31,7 @@ int term_get_attr(win_T *wp, linenr_T ln
 void term_update_colors(term_T *term);
 void term_update_colors_all(void);
 char_u *term_get_status_text(term_T *term);
+void term_clear_status_text(term_T *term);
 int set_ref_in_term(int copyID);
 void f_term_dumpwrite(typval_T *argvars, typval_T *rettv);
 int term_swap_diff(void);
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -4638,6 +4638,15 @@ term_get_status_text(term_T *term)
 }
 
 /*
+ * Clear the cached value of the status text.
+ */
+    void
+term_clear_status_text(term_T *term)
+{
+    VIM_CLEAR(term->tl_status_text);
+}
+
+/*
  * Mark references in jobs of terminals.
  */
     int
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -159,6 +159,18 @@ func Test_terminal_hide_buffer_job_finis
   bwipe Xasdfasdf
 endfunc
 
+func Test_terminal_rename_buffer()
+  let cmd = Get_cat_123_cmd()
+  let buf = term_start(cmd, {'term_name': 'foo'})
+  call WaitForAssert({-> assert_equal('finished', term_getstatus(buf))})
+  call assert_equal('foo', bufname())
+  call assert_match('foo.*finished', execute('ls'))
+  file bar
+  call assert_equal('bar', bufname())
+  call assert_match('bar.*finished', execute('ls'))
+  exe 'bwipe! ' .. buf
+endfunc
+
 func s:Nasty_exit_cb(job, st)
   exe g:buf . 'bwipe!'
   let g:buf = 0
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    3624,
+/**/
     3623,
 /**/
     3622,