]> granicus.if.org Git - vim/commitdiff
patch 8.2.3624: when renaming a terminal buffer status text is not updated v8.2.3624
authorBram Moolenaar <Bram@vim.org>
Fri, 19 Nov 2021 17:01:08 +0000 (17:01 +0000)
committerBram Moolenaar <Bram@vim.org>
Fri, 19 Nov 2021 17:01:08 +0000 (17:01 +0000)
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)

src/buffer.c
src/proto/terminal.pro
src/terminal.c
src/testdir/test_terminal.vim
src/version.c

index 29cfb8a993e36f993cc71a9282858f7d6339114c..2983ca9fe823c3535701f92ae835073974780c81 100644 (file)
@@ -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
index 061a668bf88b6f9758fc90c48e8072ee3a5ebff6..f5e3258d1f12d48bdf6a23920aa32f44aa4c4c40 100644 (file)
@@ -31,6 +31,7 @@ int term_get_attr(win_T *wp, linenr_T lnum, int col);
 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);
index fb8b2881fb0bad8ea732e323065d3d8ce8579387..c00302d2b590c3e5aa1a9a095dd0a3785f93d0a6 100644 (file)
@@ -4637,6 +4637,15 @@ term_get_status_text(term_T *term)
     return term->tl_status_text;
 }
 
+/*
+ * 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.
  */
index cd7f477c262cd6de59e1e5271c7a4acd63ef3b91..62dfbf1050fb19675f4f2d85d34f187bf9b733de 100644 (file)
@@ -159,6 +159,18 @@ func Test_terminal_hide_buffer_job_finished()
   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
index 919a802d3cfa897b17a54032f3e6bf8ba7474a83..7cadcebf04d2ca10344ec5937a6179a40573bbf2 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3624,
 /**/
     3623,
 /**/