Skip to content

Commit e12bab3

Browse files
committed
patch 8.1.0706: tabline is not always redrawn
Problem: Tabline is not always redrawn when something that is used in 'tabline' changes. Solution: Add ":redrawtabline" so that a plugin can at least cause the redraw when needed.
1 parent 6d4470b commit e12bab3

File tree

9 files changed

+77
-21
lines changed

9 files changed

+77
-21
lines changed

runtime/doc/options.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7758,6 +7758,9 @@ A jump table for the options with a short description can be found at |Q_op|.
77587758
the text to be displayed. Use "%1T" for the first label, "%2T" for
77597759
the second one, etc. Use "%X" items for closing labels.
77607760

7761+
When changing something that is used in 'tabline' that does not
7762+
trigger it to be updated, use |:redrawtabline|.
7763+
77617764
Keep in mind that only one of the tab pages is the current one, others
77627765
are invisible and you can't jump to their windows.
77637766

runtime/doc/various.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*various.txt* For Vim version 8.1. Last change: 2018 Dec 13
1+
*various.txt* For Vim version 8.1. Last change: 2019 Jan 08
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -30,6 +30,11 @@ CTRL-L Clear and redraw the screen. The redraw may happen
3030
includes an item that doesn't cause automatic
3131
updating.
3232

33+
*:redrawt* *:redrawtabline*
34+
:redrawt[abline] Redraw the tabline. Useful to update the tabline when
35+
'tabline' includes an item that doesn't trigger
36+
automatic updating.
37+
3338
*N<Del>*
3439
<Del> When entering a number: Remove the last digit.
3540
Note: if you like to use <BS> for this, add this

src/ex_cmdidxs.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ static const unsigned short cmdidxs1[26] =
2323
/* p */ 309,
2424
/* q */ 348,
2525
/* r */ 351,
26-
/* s */ 370,
27-
/* t */ 437,
28-
/* u */ 480,
29-
/* v */ 491,
30-
/* w */ 509,
31-
/* x */ 524,
32-
/* y */ 533,
33-
/* z */ 534
26+
/* s */ 371,
27+
/* t */ 438,
28+
/* u */ 481,
29+
/* v */ 492,
30+
/* w */ 510,
31+
/* x */ 525,
32+
/* y */ 534,
33+
/* z */ 535
3434
};
3535

3636
/*
@@ -58,7 +58,7 @@ static const unsigned char cmdidxs2[26][26] =
5858
/* o */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 5, 0, 0, 0, 0, 0, 0, 9, 0, 11, 0, 0, 0 },
5959
/* p */ { 1, 0, 3, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 9, 0, 0, 16, 17, 26, 0, 27, 0, 28, 0 },
6060
/* q */ { 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
61-
/* r */ { 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 18, 0, 0, 0, 0 },
61+
/* r */ { 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 19, 0, 0, 0, 0 },
6262
/* s */ { 2, 6, 15, 0, 18, 22, 0, 24, 25, 0, 0, 28, 30, 34, 38, 40, 0, 48, 0, 49, 0, 61, 62, 0, 63, 0 },
6363
/* t */ { 2, 0, 19, 0, 22, 24, 0, 25, 0, 26, 0, 27, 31, 34, 36, 37, 0, 38, 40, 0, 41, 0, 0, 0, 0, 0 },
6464
/* u */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
@@ -69,4 +69,4 @@ static const unsigned char cmdidxs2[26][26] =
6969
/* z */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
7070
};
7171

72-
static const int command_count = 547;
72+
static const int command_count = 548;

src/ex_cmds.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,9 @@ EX(CMD_redraw, "redraw", ex_redraw,
11751175
EX(CMD_redrawstatus, "redrawstatus", ex_redrawstatus,
11761176
BANG|TRLBAR|CMDWIN,
11771177
ADDR_LINES),
1178+
EX(CMD_redrawtabline, "redrawtabline", ex_redrawtabline,
1179+
TRLBAR|CMDWIN,
1180+
ADDR_LINES),
11781181
EX(CMD_registers, "registers", ex_display,
11791182
EXTRA|NOTRLCOM|TRLBAR|CMDWIN,
11801183
ADDR_LINES),

src/ex_docmd.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ static void ex_redo(exarg_T *eap);
296296
static void ex_later(exarg_T *eap);
297297
static void ex_redir(exarg_T *eap);
298298
static void ex_redrawstatus(exarg_T *eap);
299+
static void ex_redrawtabline(exarg_T *eap);
299300
static void close_redir(void);
300301
static void ex_mkrc(exarg_T *eap);
301302
static void ex_mark(exarg_T *eap);
@@ -9918,6 +9919,25 @@ ex_redrawstatus(exarg_T *eap UNUSED)
99189919
out_flush();
99199920
}
99209921

9922+
/*
9923+
* ":redrawtabline": force redraw of the tabline
9924+
*/
9925+
static void
9926+
ex_redrawtabline(exarg_T *eap UNUSED)
9927+
{
9928+
int r = RedrawingDisabled;
9929+
int p = p_lz;
9930+
9931+
RedrawingDisabled = 0;
9932+
p_lz = FALSE;
9933+
9934+
draw_tabline();
9935+
9936+
RedrawingDisabled = r;
9937+
p_lz = p;
9938+
out_flush();
9939+
}
9940+
99219941
static void
99229942
close_redir(void)
99239943
{

src/proto/screen.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ int screen_del_lines(int off, int row, int line_count, int end, int force, int c
5252
int showmode(void);
5353
void unshowmode(int force);
5454
void clearmode(void);
55+
void draw_tabline(void);
5556
void get_trans_bufname(buf_T *buf);
5657
int redrawing(void);
5758
int messaging(void);

src/screen.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ static int win_do_lines(win_T *wp, int row, int line_count, int mayclear, int de
154154
static void win_rest_invalid(win_T *wp);
155155
static void msg_pos_mode(void);
156156
static void recording_mode(int attr);
157-
static void draw_tabline(void);
158157
static int fillchar_status(int *attr, win_T *wp);
159158
static int fillchar_vsep(int *attr);
160159
#ifdef FEAT_MENU
@@ -10693,7 +10692,7 @@ recording_mode(int attr)
1069310692
/*
1069410693
* Draw the tab pages line at the top of the Vim window.
1069510694
*/
10696-
static void
10695+
void
1069710696
draw_tabline(void)
1069810697
{
1069910698
int tabcount = 0;

src/testdir/test_tabline.vim

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
function! TablineWithCaughtError()
1+
2+
source shared.vim
3+
4+
func TablineWithCaughtError()
25
let s:func_in_tabline_called = 1
36
try
47
call eval('unknown expression')
58
catch
69
endtry
710
return ''
8-
endfunction
11+
endfunc
912

10-
function! TablineWithError()
13+
func TablineWithError()
1114
let s:func_in_tabline_called = 1
1215
call eval('unknown expression')
1316
return ''
14-
endfunction
17+
endfunc
1518

16-
function! Test_caught_error_in_tabline()
19+
func Test_caught_error_in_tabline()
1720
if has('gui')
1821
set guioptions-=e
1922
endif
@@ -27,9 +30,9 @@ function! Test_caught_error_in_tabline()
2730
call assert_equal(tabline, &tabline)
2831
set tabline=
2932
let &showtabline = showtabline_save
30-
endfunction
33+
endfunc
3134

32-
function! Test_tabline_will_be_disabled_with_error()
35+
func Test_tabline_will_be_disabled_with_error()
3336
if has('gui')
3437
set guioptions-=e
3538
endif
@@ -46,4 +49,24 @@ function! Test_tabline_will_be_disabled_with_error()
4649
call assert_equal('', &tabline)
4750
set tabline=
4851
let &showtabline = showtabline_save
49-
endfunction
52+
endfunc
53+
54+
func Test_redrawtabline()
55+
if has('gui')
56+
set guioptions-=e
57+
endif
58+
let showtabline_save = &showtabline
59+
set showtabline=2
60+
set tabline=%{bufnr('$')}
61+
edit Xtabline1
62+
edit Xtabline2
63+
redraw
64+
call assert_match(bufnr('$') . '', Screenline(1))
65+
au BufAdd * redrawtabline
66+
badd Xtabline3
67+
call assert_match(bufnr('$') . '', Screenline(1))
68+
69+
set tabline=
70+
let &showtabline = showtabline_save
71+
au! Bufadd
72+
endfunc

src/version.c

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

800800
static int included_patches[] =
801801
{ /* Add new patch number below this line */
802+
/**/
803+
706,
802804
/**/
803805
705,
804806
/**/

0 commit comments

Comments
 (0)