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)
diff --git a/src/buffer.c b/src/buffer.c
index 330b3b9..14eac92 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -502,7 +502,7 @@
  * 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 @@
 	    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 @@
 		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
index 09adf2f..3cba2aa 100644
--- a/src/testdir/test_tabline.vim
+++ b/src/testdir/test_tabline.vim
@@ -133,7 +133,7 @@
   tabnew
   redraw!
 
-  tabclose
+  bw!
   set tabline=
 endfunc
 
@@ -202,4 +202,28 @@
   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('<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
diff --git a/src/version.c b/src/version.c
index b21e5a6..876e20c 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1672,
+/**/
     1671,
 /**/
     1670,