0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

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 #12614)
This commit is contained in:
zeertzjq
2023-07-01 20:24:40 +01:00
committed by Bram Moolenaar
parent e7d9ca2b3b
commit d392a74c5a
3 changed files with 36 additions and 10 deletions

View File

@@ -502,7 +502,7 @@ can_unload_buffer(buf_T *buf)
* It can be: * It can be:
* 0 buffer becomes hidden * 0 buffer becomes hidden
* DOBUF_UNLOAD buffer is unloaded * 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 buffer is unloaded and really deleted
* DOBUF_WIPE_REUSE idem, and add to buf_reuse list * DOBUF_WIPE_REUSE idem, and add to buf_reuse list
* When doing all but the first one on the current buffer, the caller should * 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); STRMOVE(s + 1, p);
*s = '<'; *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 '<' --n; // count the '<'
for (; l < itemcnt; l++) for (; l < itemcnt; l++)
{ {
@@ -5124,6 +5116,14 @@ build_stl_str_hl(
else else
stl_items[l].stl_start = s; 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; width = maxwidth;
} }

View File

@@ -133,7 +133,7 @@ func Test_tabline_empty_group()
tabnew tabnew
redraw! redraw!
tabclose bw!
set tabline= set tabline=
endfunc endfunc
@@ -202,4 +202,28 @@ func Test_tabline_showcmd()
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
endfunc 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('<a' .. repeat('b', &columns - 4) .. 'c', Screenline(1))
call assert_equal(attr_TabLineFill, screenattr(1, &columns - 2))
call assert_equal(attr_TabLine, screenattr(1, &columns - 1))
call assert_equal(attr_TabLine, screenattr(1, &columns))
bw!
set tabline=
endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1672,
/**/ /**/
1671, 1671,
/**/ /**/