Skip to content

Commit d392a74

Browse files
zeertzjqbrammool
authored andcommitted
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 vim#12614)
1 parent e7d9ca2 commit d392a74

File tree

3 files changed

+36
-10
lines changed

3 files changed

+36
-10
lines changed

src/buffer.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ can_unload_buffer(buf_T *buf)
502502
* It can be:
503503
* 0 buffer becomes hidden
504504
* DOBUF_UNLOAD buffer is unloaded
505-
* DOBUF_DELETE buffer is unloaded and removed from buffer list
505+
* DOBUF_DEL buffer is unloaded and removed from buffer list
506506
* DOBUF_WIPE buffer is unloaded and really deleted
507507
* DOBUF_WIPE_REUSE idem, and add to buf_reuse list
508508
* When doing all but the first one on the current buffer, the caller should
@@ -5108,14 +5108,6 @@ build_stl_str_hl(
51085108
STRMOVE(s + 1, p);
51095109
*s = '<';
51105110

5111-
// Fill up for half a double-wide character.
5112-
while (++width < maxwidth)
5113-
{
5114-
s = s + STRLEN(s);
5115-
MB_CHAR2BYTES(fillchar, s);
5116-
*s = NUL;
5117-
}
5118-
51195111
--n; // count the '<'
51205112
for (; l < itemcnt; l++)
51215113
{
@@ -5124,6 +5116,14 @@ build_stl_str_hl(
51245116
else
51255117
stl_items[l].stl_start = s;
51265118
}
5119+
5120+
// Fill up for half a double-wide character.
5121+
while (++width < maxwidth)
5122+
{
5123+
s = s + STRLEN(s);
5124+
MB_CHAR2BYTES(fillchar, s);
5125+
*s = NUL;
5126+
}
51275127
}
51285128
width = maxwidth;
51295129
}

src/testdir/test_tabline.vim

+25-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func Test_tabline_empty_group()
133133
tabnew
134134
redraw!
135135

136-
tabclose
136+
bw!
137137
set tabline=
138138
endfunc
139139

@@ -202,4 +202,28 @@ func Test_tabline_showcmd()
202202
call StopVimInTerminal(buf)
203203
endfunc
204204

205+
func TruncTabLine()
206+
return '%1T口口%2Ta' .. repeat('b', &columns - 4) .. '%999X%#TabLine#c'
207+
endfunc
208+
209+
" Test 'tabline' with truncated double-width label at the start.
210+
func Test_tabline_truncated_double_width()
211+
tabnew
212+
redraw
213+
call assert_match('X$', Screenline(1))
214+
let attr_TabLineFill = screenattr(1, &columns - 1)
215+
let attr_TabLine = screenattr(1, &columns)
216+
call assert_notequal(attr_TabLine, attr_TabLineFill)
217+
218+
set tabline=%!TruncTabLine()
219+
redraw
220+
call assert_equal('<a' .. repeat('b', &columns - 4) .. 'c', Screenline(1))
221+
call assert_equal(attr_TabLineFill, screenattr(1, &columns - 2))
222+
call assert_equal(attr_TabLine, screenattr(1, &columns - 1))
223+
call assert_equal(attr_TabLine, screenattr(1, &columns))
224+
225+
bw!
226+
set tabline=
227+
endfunc
228+
205229
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

+2
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,8 @@ static char *(features[]) =
695695

696696
static int included_patches[] =
697697
{ /* Add new patch number below this line */
698+
/**/
699+
1672,
698700
/**/
699701
1671,
700702
/**/

0 commit comments

Comments
 (0)