Commit Diff


commit - 332ed2e3454e27e1dab4b50a2c06aec9711f8469
commit + 8f127baa620cc9591a7be4e199bed821b2960644
blob - 06860322003c6ca4e9fadd18097fc928eeedce9a
blob + 1e48de7d89831f79371f4f47521d1be4742a5ce1
--- ui.c
+++ ui.c
@@ -1430,23 +1430,30 @@ static void
 redraw_tabline(void)
 {
 	struct tab	*tab;
-	size_t		 toskip;
-	int		 current, x, y, truncated;
+	size_t		 toskip, ots, tabwidth, space, x;
+	int		 current, y, truncated;
 	const char	*title;
 	char		 buf[25];
 
+	tabwidth = sizeof(buf)+1;
+	space = COLS-2;
+
 	toskip = 0;
-	x = 1;
 	TAILQ_FOREACH(tab, &tabshead, tabs) {
-		x += sizeof(buf) + 1;
 		toskip++;
 		if (tab->flags & TAB_CURRENT)
 			break;
 	}
-	if (x < COLS-2)
-		toskip = 0;
-	else
+
+	if (toskip * tabwidth < space)
+		toskip = 0;
+	else {
+		ots = toskip;
 		toskip--;
+                while (toskip != 0 &&
+		    (ots - toskip+1) * tabwidth < space)
+			toskip--;
+	}
 
 	werase(tabline);
 	wattron(tabline, tab_face.background);
@@ -1497,7 +1504,7 @@ redraw_tabline(void)
 	}
 
 	wattron(tabline, tab_face.background);
-	for (; x < COLS; ++x)
+	for (; x < (size_t)COLS; ++x)
 		waddch(tabline, ' ');
 	if (truncated)
 		mvwprintw(tabline, 0, COLS-1, ">");