diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-07-22 06:25:07 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-07-22 12:25:07 +0200 |
commit | 39549159fef535ef2d44c0ca62137bac16f469ee (patch) | |
tree | 2f23f016381ddcaa17e3a385c74553373899cf29 | |
parent | f8684bf6b9e586733c42a21f3f4c947a37bacdbc (diff) | |
download | rneovim-39549159fef535ef2d44c0ca62137bac16f469ee.tar.gz rneovim-39549159fef535ef2d44c0ca62137bac16f469ee.tar.bz2 rneovim-39549159fef535ef2d44c0ca62137bac16f469ee.zip |
vim-patch:8.1.0706: introduce :redrawtabline #10570
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.
https://github.com/vim/vim/commit/e12bab3144af8943937bd0ff4bc57f04e53037b3
-rw-r--r-- | runtime/doc/options.txt | 2 | ||||
-rw-r--r-- | runtime/doc/various.txt | 5 | ||||
-rw-r--r-- | src/nvim/ex_cmds.lua | 6 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 16 | ||||
-rw-r--r-- | src/nvim/screen.c | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test_tabline.vim | 39 |
6 files changed, 61 insertions, 9 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 84e08ae04b..f8a6ee4a48 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -6027,6 +6027,8 @@ 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|. This option cannot be set in a modeline when 'modelineexpr' is off. Keep in mind that only one of the tab pages is the current one, others diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index bfb00f74c4..0429341b6f 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -31,6 +31,11 @@ CTRL-L Clears and redraws the screen. The redraw may happen Useful if 'statusline' 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 diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua index b1739b9e67..8c0d22809f 100644 --- a/src/nvim/ex_cmds.lua +++ b/src/nvim/ex_cmds.lua @@ -2151,6 +2151,12 @@ return { func='ex_redrawstatus', }, { + command='redrawtabline', + flags=bit.bor(TRLBAR, CMDWIN), + addr_type=ADDR_LINES, + func='ex_redrawtabline', + }, + { command='registers', flags=bit.bor(EXTRA, NOTRLCOM, TRLBAR, CMDWIN), addr_type=ADDR_LINES, diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 081ca8bf8e..af4f34d907 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -7874,6 +7874,22 @@ static void ex_redrawstatus(exarg_T *eap) ui_flush(); } +// ":redrawtabline": force redraw of the tabline +static void ex_redrawtabline(exarg_T *eap FUNC_ATTR_UNUSED) +{ + const int r = RedrawingDisabled; + const int p = p_lz; + + RedrawingDisabled = 0; + p_lz = false; + + draw_tabline(); + + RedrawingDisabled = r; + p_lz = p; + ui_flush(); +} + static void close_redir(void) { if (redir_fd != NULL) { diff --git a/src/nvim/screen.c b/src/nvim/screen.c index ab9f71ed6c..457141f911 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -6650,7 +6650,7 @@ static void recording_mode(int attr) /* * Draw the tab pages line at the top of the Vim window. */ -static void draw_tabline(void) +void draw_tabline(void) { int tabcount = 0; int tabwidth = 0; diff --git a/src/nvim/testdir/test_tabline.vim b/src/nvim/testdir/test_tabline.vim index 6c7a02d650..f24552088b 100644 --- a/src/nvim/testdir/test_tabline.vim +++ b/src/nvim/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() let showtabline_save = &showtabline set showtabline=2 let s:func_in_tabline_called = 0 @@ -24,9 +27,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() let showtabline_save = &showtabline set showtabline=2 let s:func_in_tabline_called = 0 @@ -40,4 +43,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 |