Mercurial > vim
changeset 15396:325e4a8ba1b6 v8.1.0706
patch 8.1.0706: tabline is not always redrawn
commit https://github.com/vim/vim/commit/e12bab3144af8943937bd0ff4bc57f04e53037b3
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jan 8 22:02:56 2019 +0100
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 08 Jan 2019 22:15:05 +0100 |
parents | 989d5000e18e |
children | 32c14d681e03 |
files | runtime/doc/options.txt runtime/doc/various.txt src/ex_cmdidxs.h src/ex_cmds.h src/ex_docmd.c src/proto/screen.pro src/screen.c src/testdir/test_tabline.vim src/version.c |
diffstat | 9 files changed, 77 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -7758,6 +7758,9 @@ A jump table for the options with a shor 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.
--- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -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. T 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
--- a/src/ex_cmdidxs.h +++ b/src/ex_cmdidxs.h @@ -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][ /* 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][ /* 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;
--- a/src/ex_cmds.h +++ b/src/ex_cmds.h @@ -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),
--- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -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) {
--- a/src/proto/screen.pro +++ b/src/proto/screen.pro @@ -52,6 +52,7 @@ int screen_del_lines(int off, int row, i 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);
--- a/src/screen.c +++ b/src/screen.c @@ -154,7 +154,6 @@ static int win_do_lines(win_T *wp, int r 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;
--- a/src/testdir/test_tabline.vim +++ b/src/testdir/test_tabline.vim @@ -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_ 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