Skip to content
Permalink
Browse files

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.
  • Loading branch information...
brammool committed Jan 8, 2019
1 parent 6d4470b commit e12bab3144af8943937bd0ff4bc57f04e53037b3
Showing with 77 additions and 21 deletions.
  1. +3 −0 runtime/doc/options.txt
  2. +6 −1 runtime/doc/various.txt
  3. +10 −10 src/ex_cmdidxs.h
  4. +3 −0 src/ex_cmds.h
  5. +20 −0 src/ex_docmd.c
  6. +1 −0 src/proto/screen.pro
  7. +1 −2 src/screen.c
  8. +31 −8 src/testdir/test_tabline.vim
  9. +2 −0 src/version.c
@@ -7758,6 +7758,9 @@ A jump table for the options with a short description can be found at |Q_op|.
the text to be displayed. Use "%1T" for the first label, "%2T" for
the second one, etc. Use "%X" items for closing labels.

When changing something that is used in 'tabline' that does not
trigger it to be updated, use |:redrawtabline|.

Keep in mind that only one of the tab pages is the current one, others
are invisible and you can't jump to their windows.

@@ -1,4 +1,4 @@
*various.txt* For Vim version 8.1. Last change: 2018 Dec 13
*various.txt* For Vim version 8.1. Last change: 2019 Jan 08


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

*:redrawt* *:redrawtabline*
:redrawt[abline] Redraw the tabline. Useful to update the tabline when
'tabline' includes an item that doesn't trigger
automatic updating.

*N<Del>*
<Del> When entering a number: Remove the last digit.
Note: if you like to use <BS> for this, add this
@@ -23,14 +23,14 @@ static const unsigned short cmdidxs1[26] =
/* p */ 309,
/* q */ 348,
/* r */ 351,
/* s */ 370,
/* t */ 437,
/* u */ 480,
/* v */ 491,
/* w */ 509,
/* x */ 524,
/* y */ 533,
/* z */ 534
/* s */ 371,
/* t */ 438,
/* u */ 481,
/* v */ 492,
/* w */ 510,
/* x */ 525,
/* y */ 534,
/* z */ 535
};

/*
@@ -58,7 +58,7 @@ static const unsigned char cmdidxs2[26][26] =
/* 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 },
/* 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 },
/* 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 },
/* 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 },
/* 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 },
/* 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 },
/* 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 },
/* 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] =
/* 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 }
};

static const int command_count = 547;
static const int command_count = 548;
@@ -1175,6 +1175,9 @@ EX(CMD_redraw, "redraw", ex_redraw,
EX(CMD_redrawstatus, "redrawstatus", ex_redrawstatus,
BANG|TRLBAR|CMDWIN,
ADDR_LINES),
EX(CMD_redrawtabline, "redrawtabline", ex_redrawtabline,
TRLBAR|CMDWIN,
ADDR_LINES),
EX(CMD_registers, "registers", ex_display,
EXTRA|NOTRLCOM|TRLBAR|CMDWIN,
ADDR_LINES),
@@ -296,6 +296,7 @@ static void ex_redo(exarg_T *eap);
static void ex_later(exarg_T *eap);
static void ex_redir(exarg_T *eap);
static void ex_redrawstatus(exarg_T *eap);
static void ex_redrawtabline(exarg_T *eap);
static void close_redir(void);
static void ex_mkrc(exarg_T *eap);
static void ex_mark(exarg_T *eap);
@@ -9918,6 +9919,25 @@ ex_redrawstatus(exarg_T *eap UNUSED)
out_flush();
}

/*
* ":redrawtabline": force redraw of the tabline
*/
static void
ex_redrawtabline(exarg_T *eap UNUSED)
{
int r = RedrawingDisabled;
int p = p_lz;

RedrawingDisabled = 0;
p_lz = FALSE;

draw_tabline();

RedrawingDisabled = r;
p_lz = p;
out_flush();
}

static void
close_redir(void)
{
@@ -52,6 +52,7 @@ int screen_del_lines(int off, int row, int line_count, int end, int force, int c
int showmode(void);
void unshowmode(int force);
void clearmode(void);
void draw_tabline(void);
void get_trans_bufname(buf_T *buf);
int redrawing(void);
int messaging(void);
@@ -154,7 +154,6 @@ static int win_do_lines(win_T *wp, int row, int line_count, int mayclear, int de
static void win_rest_invalid(win_T *wp);
static void msg_pos_mode(void);
static void recording_mode(int attr);
static void draw_tabline(void);
static int fillchar_status(int *attr, win_T *wp);
static int fillchar_vsep(int *attr);
#ifdef FEAT_MENU
@@ -10693,7 +10692,7 @@ recording_mode(int attr)
/*
* Draw the tab pages line at the top of the Vim window.
*/
static void
void
draw_tabline(void)
{
int tabcount = 0;
@@ -1,19 +1,22 @@
function! TablineWithCaughtError()

source shared.vim

func TablineWithCaughtError()
let s:func_in_tabline_called = 1
try
call eval('unknown expression')
catch
endtry
return ''
endfunction
endfunc

function! TablineWithError()
func TablineWithError()
let s:func_in_tabline_called = 1
call eval('unknown expression')
return ''
endfunction
endfunc

function! Test_caught_error_in_tabline()
func Test_caught_error_in_tabline()
if has('gui')
set guioptions-=e
endif
@@ -27,9 +30,9 @@ function! Test_caught_error_in_tabline()
call assert_equal(tabline, &tabline)
set tabline=
let &showtabline = showtabline_save
endfunction
endfunc

function! Test_tabline_will_be_disabled_with_error()
func Test_tabline_will_be_disabled_with_error()
if has('gui')
set guioptions-=e
endif
@@ -46,4 +49,24 @@ function! Test_tabline_will_be_disabled_with_error()
call assert_equal('', &tabline)
set tabline=
let &showtabline = showtabline_save
endfunction
endfunc

func Test_redrawtabline()
if has('gui')
set guioptions-=e
endif
let showtabline_save = &showtabline
set showtabline=2
set tabline=%{bufnr('$')}
edit Xtabline1
edit Xtabline2
redraw
call assert_match(bufnr('$') . '', Screenline(1))
au BufAdd * redrawtabline
badd Xtabline3
call assert_match(bufnr('$') . '', Screenline(1))

set tabline=
let &showtabline = showtabline_save
au! Bufadd
endfunc
@@ -799,6 +799,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
706,
/**/
705,
/**/

0 comments on commit e12bab3

Please sign in to comment.
You can’t perform that action at this time.