Skip to content

Commit 3ad6953

Browse files
committed
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)
1 parent 8b8d829 commit 3ad6953

File tree

5 files changed

+29
-0
lines changed

5 files changed

+29
-0
lines changed

src/buffer.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3453,6 +3453,11 @@ buf_name_changed(buf_T *buf)
34533453
if (buf->b_ml.ml_mfp != NULL)
34543454
ml_setname(buf);
34553455

3456+
#ifdef FEAT_TERMINAL
3457+
if (buf->b_term != NULL)
3458+
term_clear_status_text(buf->b_term);
3459+
#endif
3460+
34563461
if (curwin->w_buffer == buf)
34573462
check_arg_idx(curwin); // check file name for arg list
34583463
#ifdef FEAT_TITLE

src/proto/terminal.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ int term_get_attr(win_T *wp, linenr_T lnum, int col);
3131
void term_update_colors(term_T *term);
3232
void term_update_colors_all(void);
3333
char_u *term_get_status_text(term_T *term);
34+
void term_clear_status_text(term_T *term);
3435
int set_ref_in_term(int copyID);
3536
void f_term_dumpwrite(typval_T *argvars, typval_T *rettv);
3637
int term_swap_diff(void);

src/terminal.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4637,6 +4637,15 @@ term_get_status_text(term_T *term)
46374637
return term->tl_status_text;
46384638
}
46394639

4640+
/*
4641+
* Clear the cached value of the status text.
4642+
*/
4643+
void
4644+
term_clear_status_text(term_T *term)
4645+
{
4646+
VIM_CLEAR(term->tl_status_text);
4647+
}
4648+
46404649
/*
46414650
* Mark references in jobs of terminals.
46424651
*/

src/testdir/test_terminal.vim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,18 @@ func Test_terminal_hide_buffer_job_finished()
159159
bwipe Xasdfasdf
160160
endfunc
161161

162+
func Test_terminal_rename_buffer()
163+
let cmd = Get_cat_123_cmd()
164+
let buf = term_start(cmd, {'term_name': 'foo'})
165+
call WaitForAssert({-> assert_equal('finished', term_getstatus(buf))})
166+
call assert_equal('foo', bufname())
167+
call assert_match('foo.*finished', execute('ls'))
168+
file bar
169+
call assert_equal('bar', bufname())
170+
call assert_match('bar.*finished', execute('ls'))
171+
exe 'bwipe! ' .. buf
172+
endfunc
173+
162174
func s:Nasty_exit_cb(job, st)
163175
exe g:buf . 'bwipe!'
164176
let g:buf = 0

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,8 @@ static char *(features[]) =
757757

758758
static int included_patches[] =
759759
{ /* Add new patch number below this line */
760+
/**/
761+
3624,
760762
/**/
761763
3623,
762764
/**/

0 commit comments

Comments
 (0)