# HG changeset patch # User Bram Moolenaar # Date 1688239807 -7200 # Node ID 5dfaba11d7c366748664b258939c9bc6786aea4d # Parent e311afd8e9c2ce77fdffddf72a66a213ab731b4f patch 9.0.1672: tabline highlight wrong after truncated double width label Commit: https://github.com/vim/vim/commit/d392a74c5a8af8271a33a20d37ae1a8ea422cb4b Author: zeertzjq Date: Sat Jul 1 20:24:40 2023 +0100 patch 9.0.1672: tabline highlight wrong after truncated double width label Problem: Tabline highlight wrong after truncated double width label. Solution: Fill up half a double width character later. (closes https://github.com/vim/vim/issues/12614) diff --git a/src/buffer.c b/src/buffer.c --- a/src/buffer.c +++ b/src/buffer.c @@ -502,7 +502,7 @@ can_unload_buffer(buf_T *buf) * It can be: * 0 buffer becomes hidden * DOBUF_UNLOAD buffer is unloaded - * DOBUF_DELETE buffer is unloaded and removed from buffer list + * DOBUF_DEL buffer is unloaded and removed from buffer list * DOBUF_WIPE buffer is unloaded and really deleted * DOBUF_WIPE_REUSE idem, and add to buf_reuse list * When doing all but the first one on the current buffer, the caller should @@ -5108,14 +5108,6 @@ build_stl_str_hl( STRMOVE(s + 1, p); *s = '<'; - // Fill up for half a double-wide character. - while (++width < maxwidth) - { - s = s + STRLEN(s); - MB_CHAR2BYTES(fillchar, s); - *s = NUL; - } - --n; // count the '<' for (; l < itemcnt; l++) { @@ -5124,6 +5116,14 @@ build_stl_str_hl( else stl_items[l].stl_start = s; } + + // Fill up for half a double-wide character. + while (++width < maxwidth) + { + s = s + STRLEN(s); + MB_CHAR2BYTES(fillchar, s); + *s = NUL; + } } width = maxwidth; } diff --git a/src/testdir/test_tabline.vim b/src/testdir/test_tabline.vim --- a/src/testdir/test_tabline.vim +++ b/src/testdir/test_tabline.vim @@ -133,7 +133,7 @@ func Test_tabline_empty_group() tabnew redraw! - tabclose + bw! set tabline= endfunc @@ -202,4 +202,28 @@ func Test_tabline_showcmd() call StopVimInTerminal(buf) endfunc +func TruncTabLine() + return '%1T口口%2Ta' .. repeat('b', &columns - 4) .. '%999X%#TabLine#c' +endfunc + +" Test 'tabline' with truncated double-width label at the start. +func Test_tabline_truncated_double_width() + tabnew + redraw + call assert_match('X$', Screenline(1)) + let attr_TabLineFill = screenattr(1, &columns - 1) + let attr_TabLine = screenattr(1, &columns) + call assert_notequal(attr_TabLine, attr_TabLineFill) + + set tabline=%!TruncTabLine() + redraw + call assert_equal('