patch 9.1.1425: tabpanel: there are still some problems with the tabpanel

Problem:  tabpanel: there are still some problems with the tabpanel with
          column handling
Solution: fix the problems and refactor Tabpanel feature (Hirohito
          Higashi).

fixes: #17423
fixes: #17332
closes: #17336

Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/clipboard.c b/src/clipboard.c
index d0feb2f..fb967dc 100644
--- a/src/clipboard.c
+++ b/src/clipboard.c
@@ -404,7 +404,7 @@
 	gui_mch_invert_rectangle(row, col, height, width);
     else
 #endif
-	screen_draw_rectangle(row, col + TPL_LCOL(NULL), height, width, invert);
+	screen_draw_rectangle(row, col, height, width, invert);
 #ifdef FEAT_PROP_POPUP
     screen_zindex = 0;
 #endif
diff --git a/src/drawline.c b/src/drawline.c
index 3be9a3a..84a1d89 100644
--- a/src/drawline.c
+++ b/src/drawline.c
@@ -875,7 +875,7 @@
 	}
     }
 
-    screen_line(wp, wlv->screen_row, wp->w_wincol + TPL_LCOL(wp), wlv->col,
+    screen_line(wp, wlv->screen_row, wp->w_wincol, wlv->col,
 		    clear_end ? wp->w_width : -wp->w_width,
 		    wlv->vcol - 1, wlv->screen_line_flags);
 }
@@ -4355,7 +4355,7 @@
 #ifdef FEAT_PROP_POPUP
 		     && !text_prop_above && !text_prop_follows
 #endif
-		     && wp->w_width == COLUMNS_WITHOUT_TPL())
+		     && wp->w_width == Columns)
 	    {
 		// Remember that the line wraps, used for modeless copy.
 		LineWraps[wlv.screen_row - 1] = TRUE;
@@ -4380,7 +4380,7 @@
 									  == 2
 				 || (*mb_off2cells)(
 				     LineOffset[wlv.screen_row - 1]
-							    + (int)COLUMNS_WITHOUT_TPL() - 2,
+							    + (int)topframe->fr_width - 2,
 				     LineOffset[wlv.screen_row]
 						      + screen_Columns) == 2)))
 		{
@@ -4390,17 +4390,17 @@
 		    // auto-wrap, we overwrite the character.
 		    if (screen_cur_col != wp->w_width)
 			screen_char(LineOffset[wlv.screen_row - 1]
-						       + (unsigned)COLUMNS_WITHOUT_TPL() - 1,
-				       wlv.screen_row - 1, (int)(COLUMNS_WITHOUT_TPL() - 1));
+						       + (unsigned)topframe->fr_width - 1,
+				       wlv.screen_row - 1, (int)(topframe->fr_width - 1));
 
 		    // When there is a multi-byte character, just output a
 		    // space to keep it simple.
 		    if (has_mbyte && MB_BYTE2LEN(ScreenLines[LineOffset[
-				     wlv.screen_row - 1] + (COLUMNS_WITHOUT_TPL() - 1)]) > 1)
+				     wlv.screen_row - 1] + (topframe->fr_width - 1)]) > 1)
 			out_char(' ');
 		    else
 			out_char(ScreenLines[LineOffset[wlv.screen_row - 1]
-							    + (COLUMNS_WITHOUT_TPL() - 1)]);
+							    + (topframe->fr_width - 1)]);
 		    // force a redraw of the first char on the next line
 		    ScreenAttrs[LineOffset[wlv.screen_row]] = (sattr_T)-1;
 		    screen_start();	// don't know where cursor is now
diff --git a/src/drawscreen.c b/src/drawscreen.c
index 1e71cae..60b76d5 100644
--- a/src/drawscreen.c
+++ b/src/drawscreen.c
@@ -541,13 +541,13 @@
 	    plen = this_ru_col - 1;
 	}
 
-	screen_puts(p, row, wp->w_wincol + TPL_LCOL(wp), attr);
-	screen_fill(row, row + 1, plen + wp->w_wincol + TPL_LCOL(wp),
-			this_ru_col + wp->w_wincol + TPL_LCOL(wp), fillchar, fillchar, attr);
+	screen_puts(p, row, wp->w_wincol, attr);
+	screen_fill(row, row + 1, plen + wp->w_wincol,
+			this_ru_col + wp->w_wincol, fillchar, fillchar, attr);
 	if ((NameBufflen = get_keymap_str(wp, (char_u *)"<%s>", NameBuff, MAXPATHL)) > 0
 		&& (this_ru_col - plen) > (NameBufflen + 1))
 	    screen_puts(NameBuff, row, (int)(this_ru_col - NameBufflen
-						   - 1 + wp->w_wincol + TPL_LCOL(wp)), attr);
+						   - 1 + wp->w_wincol), attr);
 
 	win_redr_ruler(wp, TRUE, ignore_pum);
 
@@ -572,8 +572,7 @@
 	    fillchar = fillchar_status(&attr, wp);
 	else
 	    fillchar = fillchar_vsep(&attr, wp);
-	if (W_ENDCOL(wp) < COLUMNS_WITHOUT_TPL())
-	    screen_putchar(fillchar, row, W_ENDCOL(wp) + TPL_LCOL(wp), attr);
+	screen_putchar(fillchar, row, W_ENDCOL(wp), attr);
     }
     busy = FALSE;
 }
@@ -798,11 +797,11 @@
 	    buffer[bufferlen] = NUL;
 	}
 
-	screen_puts(buffer, row, this_ru_col + off + TPL_LCOL(wp), attr);
+	screen_puts(buffer, row, this_ru_col + off, attr);
 	n1 = redraw_cmdline;
 	screen_fill(row, row + 1,
-		this_ru_col + off + bufferlen + TPL_LCOL(wp),
-		(off + width) + TPL_LCOL(wp),
+		this_ru_col + off + bufferlen,
+		(off + width),
 		fillchar, fillchar, attr);
 	// don't redraw the cmdline because of showing the ruler
 	redraw_cmdline = n1;
@@ -1043,7 +1042,7 @@
     }
     wp->w_winbar_items[item_idx].wb_menu = NULL; // end marker
 
-    screen_line(wp, wp->w_winrow, wp->w_wincol + TPL_LCOL(wp), wp->w_width,
+    screen_line(wp, wp->w_winrow, wp->w_wincol, wp->w_width,
 							  wp->w_width, -1, 0);
 }
 #endif
@@ -1378,8 +1377,8 @@
     }
 #endif
 
-    screen_line(wp, row + W_WINROW(wp), wp->w_wincol + TPL_LCOL(wp),
-						wp->w_width, wp->w_width, -1, 0);
+    screen_line(wp, row + W_WINROW(wp), wp->w_wincol, wp->w_width, wp->w_width,
+	    -1, 0);
 
     // Update w_cline_height and w_cline_folded if the cursor line was
     // updated (saves a call to plines() later).
@@ -2613,13 +2612,16 @@
 
 	for (k = 0; k < Rows; ++k)
 	    if (enc_utf8)
-		if ((*mb_off2cells)(LineOffset[k] + Columns - 2,
+		if ((*mb_off2cells)(LineOffset[k] + topframe->fr_width - 2,
 					   LineOffset[k] + screen_Columns) > 1)
-		    screen_draw_rectangle(k, Columns - 2, 1, 2, FALSE);
+		    screen_draw_rectangle(k, topframe->fr_width - 2, 1, 2,
+			    FALSE);
 		else
-		    screen_draw_rectangle(k, Columns - 1, 1, 1, FALSE);
+		    screen_draw_rectangle(k, topframe->fr_width - 1, 1, 1,
+			    FALSE);
 	    else
-		screen_char(LineOffset[k] + Columns - 1, k, Columns - 1);
+		screen_char(LineOffset[k] + topframe->fr_width - 1, k,
+			Columns - 1);
     }
 #endif
 
@@ -2689,8 +2691,8 @@
 	    // Last line isn't finished: Display "@@@" at the end.
 	    screen_fill(W_WINROW(wp) + wp->w_height - 1,
 		    W_WINROW(wp) + wp->w_height,
-		    (start_col < wp->w_wincol ? wp->w_wincol : start_col) + TPL_LCOL(wp),
-		    (int)W_ENDCOL(wp) + TPL_LCOL(wp),
+		    (start_col < wp->w_wincol ? wp->w_wincol : start_col),
+		    (int)W_ENDCOL(wp),
 		    symbol, symbol, HL_ATTR(HLF_AT));
 	    set_empty_rows(wp, srow);
 	    wp->w_botline = lnum;
diff --git a/src/edit.c b/src/edit.c
index 3661088..b4e6767 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -1716,7 +1716,7 @@
 
 	    if (fix_col != pc_col)
 	    {
-		screen_putchar(' ', pc_row, fix_col + TPL_LCOL(NULL), attr);
+		screen_putchar(' ', pc_row, fix_col, attr);
 		--curwin->w_wcol;
 		pc_status = PC_STATUS_RIGHT;
 	    }
@@ -1736,7 +1736,7 @@
 	screen_getbytes(pc_row, pc_col, pc_bytes, &pc_attr);
 	pc_status = PC_STATUS_SET;
     }
-    screen_putchar(c, pc_row, pc_col + TPL_LCOL(NULL), attr);
+    screen_putchar(c, pc_row, pc_col, attr);
 }
 
 #if defined(FEAT_JOB_CHANNEL) || defined(PROTO)
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index a929465..08d2c1e 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -8234,7 +8234,7 @@
     {
 	n = W_WINROW(curwin) + curwin->w_wrow - msg_scrolled;
 	if (n >= 0)
-	    windgoto(n, curwin->w_wincol + curwin->w_wcol + TPL_LCOL(curwin));
+	    windgoto(n, curwin->w_wincol + curwin->w_wcol);
     }
 
     len = eap->line2;
diff --git a/src/gui.c b/src/gui.c
index 41647d6..fbbfb87 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -4907,8 +4907,6 @@
     row = Y_2_ROW(y);
     col = X_2_COL(x);
 
-    col -= TPL_LCOL(NULL);
-
     if (row < 0 || col < 0)		// before first window
 	return NULL;
     wp = mouse_find_win(&row, &col, popup);
@@ -5379,8 +5377,6 @@
     int		col = X_2_COL(x);
     win_T	*wp;
 
-    col -= TPL_LCOL(NULL);
-
     if (row < 0 || col < 0)
 	return;
 
diff --git a/src/mouse.c b/src/mouse.c
index 65540e5..0d05e64 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -479,9 +479,11 @@
 
     start_visual.lnum = 0;
 
-    // Check for clicking in the tab page line.
+    // Check for clicking in the tab page panel.
 #if defined(FEAT_TABPANEL)
-    if (mouse_col < TPL_LCOL(NULL))
+    if (mouse_row < firstwin->w_winrow + topframe->fr_height
+	&& (mouse_col < firstwin->w_wincol
+		|| mouse_col >= firstwin->w_wincol + topframe->fr_width))
     {
 	if (is_drag)
 	{
@@ -499,7 +501,7 @@
 # ifdef FEAT_CMDWIN
 		&& cmdwin_type == 0
 # endif
-		&& mouse_col < Columns)
+		)
 	{
 	    in_tabpanel = TRUE;
 	    c1 = get_tabpagenr_on_tabpanel();
@@ -568,7 +570,8 @@
 	    }
 
 	    // click in a tab selects that tab page
-	    if (is_click && cmdwin_type == 0 && mouse_col < Columns)
+	    if (is_click && cmdwin_type == 0
+		    && mouse_col < firstwin->w_wincol + topframe->fr_width)
 	    {
 		in_tab_line = TRUE;
 		c1 = TabPageIdxs[mouse_col];
@@ -1725,10 +1728,6 @@
     int		mouse_char = ' ';
 #endif
 
-    col -= TPL_LCOL(NULL);
-    if (col < 0)
-	return IN_TABPANEL;
-
     mouse_past_bottom = FALSE;
     mouse_past_eol = FALSE;
 
@@ -1813,7 +1812,7 @@
 
     if (!(flags & MOUSE_FOCUS))
     {
-	if (row < 0 || col + TPL_LCOL(NULL) < 0) // check if it makes sense
+	if (row < 0 || col < 0) // check if it makes sense
 	    return IN_UNKNOWN;
 
 	// find the window where the row is in and adjust "row" and "col" to be
@@ -3220,7 +3219,14 @@
 #endif
 
     fp = topframe;
+
+    if (*colp < firstwin->w_wincol
+	    || *colp >= firstwin->w_wincol + fp->fr_width
+	    || *rowp < firstwin->w_winrow)
+	return NULL;
+
     *rowp -= firstwin->w_winrow;
+    *colp -= firstwin->w_wincol;
     for (;;)
     {
 	if (fp->fr_layout == FR_LEAF)
@@ -3333,9 +3339,6 @@
 	    winid = wp->w_id;
 	    winrow = row + 1;
 	    wincol = col + 1;
-	    wincol -= TPL_LCOL(NULL);
-	    if (wincol < 0)
-		wincol = 0;
 	    row -= top_off;
 	    col -= left_off;
 	    if (row >= 0 && row < wp->w_height && col >= 0 && col < wp->w_width)
diff --git a/src/popupmenu.c b/src/popupmenu.c
index 6d91c33..fb32017 100644
--- a/src/popupmenu.c
+++ b/src/popupmenu.c
@@ -658,25 +658,22 @@
 	width = cells + over_cell + 1;
 	rt = orig_rt;
 
-	screen_putchar(truncrl, row,
-		col - width + 1 + TPL_LCOL(NULL), trunc_attr);
+	screen_putchar(truncrl, row, col - width + 1, trunc_attr);
 
 	if (over_cell > 0)
-	    screen_fill(row, row + 1, col - width + 2 + TPL_LCOL(NULL),
-		    col - width + 2 + over_cell + TPL_LCOL(NULL), ' ', ' ',
-		    attr);
+	    screen_fill(row, row + 1, col - width + 2,
+		    col - width + 2 + over_cell, ' ', ' ', attr);
     }
 
     if (attrs == NULL)
-	screen_puts_len(rt, (int)STRLEN(rt), row,
-		col - cells + 1 + TPL_LCOL(NULL), attr);
+	screen_puts_len(rt, (int)STRLEN(rt), row, col - cells + 1, attr);
     else
-	pum_screen_puts_with_attrs(row, col - cells + 1 + TPL_LCOL(NULL),
-		cells, rt, (int)STRLEN(rt), attrs);
+	pum_screen_puts_with_attrs(row, col - cells + 1, cells, rt,
+		(int)STRLEN(rt), attrs);
 
     vim_free(rt_start);
     VIM_CLEAR(st);
-    return col - width + TPL_LCOL(NULL);
+    return col - width;
 }
 #endif
 
@@ -750,19 +747,17 @@
     }
 
     if (attrs == NULL)
-	screen_puts_len(st, size, row, col + TPL_LCOL(NULL), attr);
+	screen_puts_len(st, size, row, col, attr);
     else
-	pum_screen_puts_with_attrs(row, col + TPL_LCOL(NULL), cells, st, size,
-		attrs);
+	pum_screen_puts_with_attrs(row, col, cells, st, size, attrs);
 
     if (truncated)
     {
 	if (over_cell > 0)
-	    screen_fill(row, row + 1, col + cells + TPL_LCOL(NULL),
-		    col + cells + over_cell + TPL_LCOL(NULL), ' ', ' ', attr);
+	    screen_fill(row, row + 1, col + cells,
+		    col + cells + over_cell, ' ', ' ', attr);
 
-	screen_putchar(trunc, row,
-		col + cells + over_cell + TPL_LCOL(NULL), trunc_attr);
+	screen_putchar(trunc, row, col + cells + over_cell, trunc_attr);
     }
 
     VIM_CLEAR(st);
@@ -873,10 +868,10 @@
 
 #ifdef FEAT_RIGHTLEFT
     if (pum_rl)
-	screen_putchar(' ', row, pum_col - pum_width + TPL_LCOL(NULL), attr);
+	screen_putchar(' ', row, pum_col - pum_width, attr);
     else
 #endif
-	screen_putchar(' ', row, pum_col + pum_width + TPL_LCOL(NULL), attr);
+	screen_putchar(' ', row, pum_col + pum_width, attr);
 }
 
 /*
@@ -959,12 +954,12 @@
 	if (pum_rl)
 	{
 	    if (pum_col < curwin->w_wincol + curwin->w_width - 1)
-		screen_putchar(' ', row, pum_col + 1 + TPL_LCOL(NULL), attr);
+		screen_putchar(' ', row, pum_col + 1, attr);
 	}
 	else
 #endif
 	    if (pum_col > 0)
-		screen_putchar(' ', row, pum_col - 1 + TPL_LCOL(NULL), attr);
+		screen_putchar(' ', row, pum_col - 1, attr);
 
 	// Display each entry, use two spaces for a Tab.
 	// Do this 3 times and order from p_cia
@@ -1005,16 +1000,15 @@
 #ifdef FEAT_RIGHTLEFT
 	    if (pum_rl)
 	    {
-		screen_fill(row, row + 1, pum_col - basic_width - n + 1 + TPL_LCOL(NULL),
-						col + 1 + TPL_LCOL(NULL), ' ', ' ', orig_attr);
+		screen_fill(row, row + 1, pum_col - basic_width - n + 1,
+						col + 1, ' ', ' ', orig_attr);
 		col = pum_col - basic_width - n;
 	    }
 	    else
 #endif
 	    {
-		screen_fill(row, row + 1, col + TPL_LCOL(NULL),
-			pum_col + basic_width + n + TPL_LCOL(NULL), ' ', ' ',
-			orig_attr);
+		screen_fill(row, row + 1, col, pum_col + basic_width + n,
+							' ', ' ', orig_attr);
 		col = pum_col + basic_width + n;
 	    }
 	    totwidth = basic_width + n;
@@ -1022,14 +1016,12 @@
 
 #ifdef FEAT_RIGHTLEFT
 	if (pum_rl)
-	    screen_fill(row, row + 1,
-		    pum_col - pum_width + 1 + TPL_LCOL(NULL),
-		    col + 1 + TPL_LCOL(NULL), ' ', ' ', orig_attr);
+	    screen_fill(row, row + 1, pum_col - pum_width + 1, col + 1, ' ',
+							    ' ', orig_attr);
 	else
 #endif
-	    screen_fill(row, row + 1, col + TPL_LCOL(NULL),
-		    pum_col + pum_width + TPL_LCOL(NULL),
-		    ' ', ' ', orig_attr);
+	    screen_fill(row, row + 1, col, pum_col + pum_width, ' ', ' ',
+								orig_attr);
 	pum_draw_scrollbar(row, i, thumb_pos, thumb_height);
 
 	++row;
diff --git a/src/popupwin.c b/src/popupwin.c
index a9a2843..199ffaf 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -86,7 +86,7 @@
     if (STRCMP(key, "line") == 0)
 	n = screen_screenrow() + 1 + n;
     else // "col"
-	n = screen_screencol() + 1 + n - TPL_LCOL(NULL);
+	n = screen_screencol() + 1 + n;
 
     // Zero means "not set", use -1 instead.
     if (n == 0)
@@ -1354,15 +1354,15 @@
 	{
 	    wp->w_wincol = wantcol - 1;
 	    // Need to see at least one character after the decoration.
-	    if (wp->w_wincol > Columns - left_extra - 1)
-		wp->w_wincol = Columns - left_extra - 1;
+	    if (wp->w_wincol > firstwin->w_wincol + topframe->fr_width - left_extra - 1)
+		wp->w_wincol = firstwin->w_wincol + topframe->fr_width - left_extra - 1;
 	}
     }
 
     // When centering or right aligned, use maximum width.
     // When left aligned use the space available, but shift to the left when we
     // hit the right of the screen.
-    maxspace = Columns - wp->w_wincol - left_extra;
+    maxspace = firstwin->w_wincol + topframe->fr_width - wp->w_wincol - left_extra;
     maxwidth = maxspace;
     if (wp->w_maxwidth > 0 && maxwidth > wp->w_maxwidth)
     {
@@ -1545,7 +1545,7 @@
     }
     if (center_hor)
     {
-	wp->w_wincol = (Columns - wp->w_width - extra_width - TPL_LCOL(NULL)) / 2;
+	wp->w_wincol = (firstwin->w_wincol + topframe->fr_width - wp->w_width - extra_width) / 2;
 	if (wp->w_wincol < 0)
 	    wp->w_wincol = 0;
     }
@@ -1581,9 +1581,9 @@
 	// try to show the right border and any scrollbar
 	want_col = left_extra + wp->w_width + right_extra;
 	if (want_col > 0 && wp->w_wincol > 0
-					 && wp->w_wincol + want_col >= Columns)
+					 && wp->w_wincol + want_col >= firstwin->w_wincol + topframe->fr_width)
 	{
-	    wp->w_wincol = Columns - want_col;
+	    wp->w_wincol = firstwin->w_wincol + topframe->fr_width - want_col;
 	    if (wp->w_wincol < 0)
 		wp->w_wincol = 0;
 	}
@@ -1673,6 +1673,13 @@
     else if (wp->w_winrow < 0)
 	wp->w_winrow = 0;
 
+    if (wp->w_wincol + wp->w_width > firstwin->w_wincol + topframe->fr_width)
+	wp->w_wincol = firstwin->w_wincol + topframe->fr_width - wp->w_width;
+    else if (wp->w_wincol < firstwin->w_wincol)
+	wp->w_wincol = firstwin->w_wincol;
+    if (wp->w_wincol < 0)
+	wp->w_wincol = 0;
+
     if (wp->w_height != org_height)
 	win_comp_scroll(wp);
 
@@ -4081,7 +4088,7 @@
 	// win_update() doesn't handle them.
 	top_off = popup_top_extra(wp);
 	left_extra = wp->w_popup_padding[3] + wp->w_popup_border[3]
-		+ TPL_LCOL(NULL) - wp->w_popup_leftoff;
+							- wp->w_popup_leftoff;
 	if (wp->w_wincol + left_extra < 0)
 	    left_extra = -wp->w_wincol;
 	wp->w_winrow += top_off;
@@ -4163,7 +4170,7 @@
 	}
 
 	// Title goes on top of border or padding.
-	title_wincol = wp->w_wincol + 1 + TPL_LCOL(NULL);
+	title_wincol = wp->w_wincol + 1;
 	if (wp->w_popup_title != NULL)
 	{
 	    title_len = vim_strsize(wp->w_popup_title);
@@ -4191,7 +4198,7 @@
 		      wp->w_popup_border[0] > 0 ? border_attr[0] : popup_attr);
 	}
 
-	wincol = wp->w_wincol - wp->w_popup_leftoff + TPL_LCOL(NULL);
+	wincol = wp->w_wincol - wp->w_popup_leftoff;
 	top_padding = wp->w_popup_padding[0];
 	if (wp->w_popup_border[0] > 0)
 	{
@@ -4229,7 +4236,7 @@
 	{
 	    padcol = wincol + wp->w_popup_border[3];
 	    padendcol = wp->w_wincol + total_width - wp->w_popup_border[1]
-		    + TPL_LCOL(NULL) - wp->w_has_scrollbar;
+							- wp->w_has_scrollbar;
 	    if (padcol < 0)
 	    {
 		padendcol += padcol;
@@ -4327,7 +4334,7 @@
 	    if (wp->w_has_scrollbar)
 	    {
 		int line = i - top_off;
-		int scroll_col = wp->w_wincol + total_width - 1 + TPL_LCOL(NULL)
+		int scroll_col = wp->w_wincol + total_width - 1
 						       - wp->w_popup_border[1];
 
 		if (line >= 0 && line < wp->w_height)
diff --git a/src/screen.c b/src/screen.c
index d8a060f..f262cf4 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -156,13 +156,13 @@
     if (wp->w_p_rl)
     {
 	screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
-		W_ENDCOL(wp) - nn + TPL_LCOL(wp), (int)W_ENDCOL(wp) - off + TPL_LCOL(wp),
+		W_ENDCOL(wp) - nn, (int)W_ENDCOL(wp) - off,
 		c1, c2, attr);
     }
     else
 #endif
 	screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
-		wp->w_wincol + off + TPL_LCOL(wp), (int)wp->w_wincol + nn + TPL_LCOL(wp),
+		wp->w_wincol + off, (int)wp->w_wincol + nn,
 		c1, c2, attr);
     return nn;
 }
@@ -215,18 +215,15 @@
     if (wp->w_p_rl)
     {
 	screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
-		wp->w_wincol + TPL_LCOL(wp), W_ENDCOL(wp) - 1 - n +
-		TPL_LCOL(wp), c2, c2, attr);
+		wp->w_wincol, W_ENDCOL(wp) - 1 - n, c2, c2, attr);
 	screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
-		W_ENDCOL(wp) - 1 - n + TPL_LCOL(wp), W_ENDCOL(wp) - n +
-		TPL_LCOL(wp), c1, c2, attr);
+		W_ENDCOL(wp) - 1 - n, W_ENDCOL(wp) - n, c1, c2, attr);
     }
     else
 #endif
     {
 	screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + endrow,
-		wp->w_wincol + n + TPL_LCOL(wp), (int)W_ENDCOL(wp) + TPL_LCOL(wp),
-		c1, c2, attr);
+		wp->w_wincol + n, (int)W_ENDCOL(wp), c1, c2, attr);
     }
 
     set_empty_rows(wp, row);
@@ -369,6 +366,9 @@
 			    && ScreenLines[off_from + 1]
 						!= ScreenLines[off_to + 1])))))
 	return TRUE;
+    // TODO: This is a temporary solution until the root cause is fixed.
+    if (firstwin->w_wincol > 0)
+	return TRUE;
     return FALSE;
 }
 
@@ -395,9 +395,7 @@
 
     if (!popup_visible)
 	return FALSE;
-    if (col < TPL_LCOL(NULL))
-	return FALSE;
-    off = row * screen_Columns + col - TPL_LCOL(NULL);
+    off = row * screen_Columns + col;
     return popup_mask[off] > screen_zindex || popup_transparent[off];
 }
 #endif
@@ -857,7 +855,7 @@
     {
 	// For a window that has a right neighbor, draw the separator char
 	// right of the window contents.  But not on top of a popup window.
-	if (coloff + col < TPL_LCOL(NULL) + COLUMNS_WITHOUT_TPL())
+	if (coloff + col < firstwin->w_wincol + topframe->fr_width)
 	{
 	    if (!skip_for_popup(row, col + coloff))
 	    {
@@ -922,14 +920,10 @@
     if (!wp->w_vsep_width)
 	return;
 
-    if (COLUMNS_WITHOUT_TPL() <= W_ENDCOL(wp) + 1)
-	return;
-
     // draw the vertical separator right of this window
     c = fillchar_vsep(&hl, wp);
     screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + wp->w_height,
-	    W_ENDCOL(wp) + TPL_LCOL(wp), W_ENDCOL(wp) + 1 + TPL_LCOL(wp),
-	    c, ' ', hl);
+	    W_ENDCOL(wp), W_ENDCOL(wp) + 1, c, ' ', hl);
 }
 
 /*
@@ -1056,9 +1050,10 @@
 	// Use 'tabline'.  Always at the first line of the screen.
 	stl = p_tal;
 	row = 0;
+	col = firstwin->w_wincol;
 	fillchar = ' ';
 	attr = HL_ATTR(HLF_TPF);
-	maxwidth = COLUMNS_WITHOUT_TPL();
+	maxwidth = topframe->fr_width;
 	opt_name = (char_u *)"tabline";
     }
     else
@@ -1155,7 +1150,7 @@
     for (n = 0; hltab[n].start != NULL; n++)
     {
 	len = (int)(hltab[n].start - p);
-	screen_puts_len(p, len, row, col + TPL_LCOL(wp), curattr);
+	screen_puts_len(p, len, row, col, curattr);
 	col += vim_strnsize(p, len);
 	p = hltab[n].start;
 
@@ -1176,12 +1171,12 @@
 	else
 	    curattr = highlight_user[hltab[n].userhl - 1];
     }
-    screen_puts(p, row, col + TPL_LCOL(wp), curattr);
+    screen_puts(p, row, col, curattr);
 
     if (wp == NULL)
     {
 	// Fill the TabPageIdxs[] array for clicking in the tab pagesline.
-	col = 0;
+	col = firstwin->w_wincol;
 	len = 0;
 	p = buf;
 	fillchar = 0;
@@ -1193,7 +1188,7 @@
 	    p = tabtab[n].start;
 	    fillchar = tabtab[n].userhl;
 	}
-	while (col < COLUMNS_WITHOUT_TPL())
+	while (col < Columns)
 	    TabPageIdxs[col++] = fillchar;
     }
 
@@ -2132,15 +2127,15 @@
 
     if (wp == NULL)
     {
-	col = 0;
-	width = COLUMNS_WITHOUT_TPL();
+	col = firstwin->w_wincol;
+	width = topframe->fr_width;
     }
     else
     {
 	col = wp->w_wincol;
 	width = wp->w_width;
     }
-    screen_draw_rectangle(row, col + TPL_LCOL(wp), end - row, width, FALSE);
+    screen_draw_rectangle(row, col, end - row, width, FALSE);
 }
 
     void
@@ -2918,11 +2913,6 @@
     unsigned	off_to = LineOffset[to] + wp->w_wincol;
     unsigned	off_from = LineOffset[from] + wp->w_wincol;
 
-#if defined(FEAT_TABPANEL)
-    off_to += TPL_LCOL(wp);
-    off_from += TPL_LCOL(wp);
-#endif
-
     mch_memmove(ScreenLines + off_to, ScreenLines + off_from,
 	    wp->w_width * sizeof(schar_T));
     if (enc_utf8)
@@ -3256,7 +3246,7 @@
 			   && (*mb_ptr2cells)(ml_get_cursor()) == 2
 			   && vim_isprintc(gchar_cursor())) ? 2 : 1)) :
 #endif
-					    curwin->w_wcol) + TPL_LCOL(NULL));
+					    curwin->w_wcol));
     }
 }
 
@@ -3326,8 +3316,7 @@
 	if (lastrow > Rows)
 	    lastrow = Rows;
 	screen_fill(nextrow - line_count, lastrow - line_count,
-		  wp->w_wincol + TPL_LCOL(wp), (int)W_ENDCOL(wp) + TPL_LCOL(wp),
-		  ' ', ' ', 0);
+		  wp->w_wincol, (int)W_ENDCOL(wp), ' ', ' ', 0);
     }
 
     if (screen_ins_lines(0, W_WINROW(wp) + row, line_count, (int)Rows, 0, NULL)
@@ -3425,7 +3414,7 @@
 
     // only a few lines left: redraw is faster
     if (mayclear && Rows - line_count < 5
-	    && wp->w_width == COLUMNS_WITHOUT_TPL())
+	    && wp->w_width == topframe->fr_width)
     {
 	if (!no_win_do_lines_ins)
 	    screenclear();	    // will set wp->w_lines_valid to 0
@@ -3442,8 +3431,7 @@
     if (row + line_count >= wp->w_height)
     {
 	screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + wp->w_height,
-		wp->w_wincol + TPL_LCOL(wp), (int)W_ENDCOL(wp) + TPL_LCOL(wp),
-		' ', ' ', 0);
+		wp->w_wincol, (int)W_ENDCOL(wp), ' ', ' ', 0);
 	return OK;
     }
 
@@ -3464,9 +3452,9 @@
      * a character in the lower right corner of the scroll region may cause a
      * scroll-up .
      */
-    if (scroll_region || wp->w_width != COLUMNS_WITHOUT_TPL())
+    if (scroll_region || wp->w_width != topframe->fr_width)
     {
-	if (scroll_region && (wp->w_width == COLUMNS_WITHOUT_TPL()
+	if (scroll_region && (wp->w_width == topframe->fr_width
 		    || *T_CSV != NUL))
 	    scroll_region_set(wp, row);
 	if (del)
@@ -3475,7 +3463,7 @@
 	else
 	    retval = screen_ins_lines(W_WINROW(wp) + row, 0, line_count,
 					   wp->w_height - row, clear_attr, wp);
-	if (scroll_region && (wp->w_width == COLUMNS_WITHOUT_TPL()
+	if (scroll_region && (wp->w_width == topframe->fr_width
 		    || *T_CSV != NUL))
 	    scroll_region_reset();
 	return retval;
@@ -3599,7 +3587,7 @@
      * exists.
      */
     result_empty = (row + line_count >= end);
-    if (wp != NULL && wp->w_width != COLUMNS_WITHOUT_TPL() && *T_CSV == NUL)
+    if (wp != NULL && wp->w_width != topframe->fr_width && *T_CSV == NUL)
     {
 	// Avoid that lines are first cleared here and then redrawn, which
 	// results in many characters updated twice.  This happens with CTRL-F
@@ -3645,7 +3633,7 @@
 #ifdef FEAT_CLIPBOARD
     // Remove a modeless selection when inserting lines halfway the screen
     // or not the full width of the screen.
-    if (off + row > 0 || (wp != NULL && wp->w_width != COLUMNS_WITHOUT_TPL()))
+    if (off + row > 0 || (wp != NULL && wp->w_width != topframe->fr_width))
 	clip_clear_selection(&clip_star);
     else
 	clip_scroll_selection(-line_count);
@@ -3677,7 +3665,7 @@
     end += off;
     for (i = 0; i < line_count; ++i)
     {
-	if (wp != NULL && wp->w_width != COLUMNS_WITHOUT_TPL())
+	if (wp != NULL && wp->w_width != topframe->fr_width)
 	{
 	    // need to copy part of a line
 	    j = end - 1 - i;
@@ -3685,11 +3673,10 @@
 		linecopy(j + line_count, j, wp);
 	    j += line_count;
 	    if (can_clear((char_u *)" "))
-		lineclear(LineOffset[j] + wp->w_wincol + TPL_LCOL(wp),
+		lineclear(LineOffset[j] + wp->w_wincol,
 			wp->w_width, clear_attr);
 	    else
-		lineinvalid(LineOffset[j] + wp->w_wincol + TPL_LCOL(wp),
-			wp->w_width);
+		lineinvalid(LineOffset[j] + wp->w_wincol, wp->w_width);
 	    LineWraps[j] = FALSE;
 	}
 	else
@@ -3704,10 +3691,9 @@
 	    LineOffset[j + line_count] = temp;
 	    LineWraps[j + line_count] = FALSE;
 	    if (can_clear((char_u *)" "))
-		lineclear(temp + TPL_LCOL(wp), COLUMNS_WITHOUT_TPL(),
-			clear_attr);
+		lineclear(temp, topframe->fr_width, clear_attr);
 	    else
-		lineinvalid(temp + TPL_LCOL(wp), COLUMNS_WITHOUT_TPL());
+		lineinvalid(temp, topframe->fr_width);
 	}
     }
 
@@ -3840,7 +3826,7 @@
      * 5. Use T_DL (delete line) if it exists.
      * 6. redraw the characters from ScreenLines[].
      */
-    if (wp != NULL && wp->w_width != COLUMNS_WITHOUT_TPL() && *T_CSV == NUL)
+    if (wp != NULL && wp->w_width != topframe->fr_width && *T_CSV == NUL)
     {
 	// Avoid that lines are first cleared here and then redrawn, which
 	// results in many characters updated twice.  This happens with CTRL-F
@@ -3863,7 +3849,7 @@
     else if (*T_CDL != NUL && line_count > 1 && can_delete)
 	type = USE_T_CDL;
     else if (can_clear(T_CE) && result_empty
-	    && (wp == NULL || wp->w_width == COLUMNS_WITHOUT_TPL()))
+	    && (wp == NULL || wp->w_width == topframe->fr_width))
 	type = USE_T_CE;
     else if (*T_DL != NUL && can_delete)
 	type = USE_T_DL;
@@ -3875,7 +3861,7 @@
 #ifdef FEAT_CLIPBOARD
     // Remove a modeless selection when deleting lines halfway the screen or
     // not the full width of the screen.
-    if (off + row > 0 || (wp != NULL && wp->w_width != COLUMNS_WITHOUT_TPL()))
+    if (off + row > 0 || (wp != NULL && wp->w_width != topframe->fr_width))
 	clip_clear_selection(&clip_star);
     else
 	clip_scroll_selection(line_count);
@@ -3914,7 +3900,7 @@
     end += off;
     for (i = 0; i < line_count; ++i)
     {
-	if (wp != NULL && wp->w_width != COLUMNS_WITHOUT_TPL())
+	if (wp != NULL && wp->w_width != topframe->fr_width)
 	{
 	    // need to copy part of a line
 	    j = row + i;
@@ -3922,11 +3908,10 @@
 		linecopy(j - line_count, j, wp);
 	    j -= line_count;
 	    if (can_clear((char_u *)" "))
-		lineclear(LineOffset[j] + wp->w_wincol + TPL_LCOL(wp),
+		lineclear(LineOffset[j] + wp->w_wincol,
 			wp->w_width, clear_attr);
 	    else
-		lineinvalid(LineOffset[j] + wp->w_wincol + TPL_LCOL(wp),
-			wp->w_width);
+		lineinvalid(LineOffset[j] + wp->w_wincol, wp->w_width);
 	    LineWraps[j] = FALSE;
 	}
 	else
@@ -3942,10 +3927,9 @@
 	    LineOffset[j - line_count] = temp;
 	    LineWraps[j - line_count] = FALSE;
 	    if (can_clear((char_u *)" "))
-		lineclear(temp + TPL_LCOL(NULL), COLUMNS_WITHOUT_TPL(),
-			clear_attr);
+		lineclear(temp, (int)Columns, clear_attr);
 	    else
-		lineinvalid(temp + TPL_LCOL(NULL), COLUMNS_WITHOUT_TPL());
+		lineinvalid(temp, (int)Columns);
 	}
     }
 
@@ -4333,7 +4317,7 @@
 					    );
 
 #if defined(FEAT_TABPANEL)
-    col = TPL_LCOL(NULL);
+    col = firstwin->w_wincol;
 #endif
 
     if (ScreenLines == NULL)
@@ -4364,7 +4348,7 @@
 	FOR_ALL_TABPAGES(tp)
 	    ++tabcount;
 
-	tabwidth = (COLUMNS_WITHOUT_TPL() - 1 + tabcount / 2) / tabcount;
+	tabwidth = (topframe->fr_width - 1 + tabcount / 2) / tabcount;
 	if (tabwidth < 6)
 	    tabwidth = 6;
 
diff --git a/src/tabpanel.c b/src/tabpanel.c
index 599e434..3845faa 100644
--- a/src/tabpanel.c
+++ b/src/tabpanel.c
@@ -164,7 +164,7 @@
     int		row = 0;
     int		off = 0;
 #endif
-int		vsrow = 0;
+    int		vsrow = 0;
     int		is_right = tpl_align == ALIGN_RIGHT;
 
     if (maxwidth == 0)
@@ -198,14 +198,10 @@
 		    maxwidth - VERT_LEN, &curtab_row, NULL);
 	    do_by_tplmode(TPLMODE_REDRAW, VERT_LEN, maxwidth, &curtab_row,
 		    NULL);
-	    // clear for multi-byte vert separater
-	    screen_fill(0, cmdline_row, COLUMNS_WITHOUT_TPL(),
-		    COLUMNS_WITHOUT_TPL() + VERT_LEN,
-		    TPL_FILLCHAR, TPL_FILLCHAR, vs_attr);
-	    // draw vert separater in tabpanel
+	    // draw vert separator in tabpanel
 	    for (vsrow = 0; vsrow < cmdline_row; vsrow++)
 		screen_putchar(curwin->w_fill_chars.tpl_vert, vsrow,
-			COLUMNS_WITHOUT_TPL(), vs_attr);
+			topframe->fr_width, vs_attr);
 	}
 	else
 	{
@@ -214,10 +210,7 @@
 		    &curtab_row, NULL);
 	    do_by_tplmode(TPLMODE_REDRAW, 0, maxwidth - VERT_LEN,
 		    &curtab_row, NULL);
-	    // clear for multi-byte vert separater
-	    screen_fill(0, cmdline_row, maxwidth - VERT_LEN,
-		    maxwidth, TPL_FILLCHAR, TPL_FILLCHAR, vs_attr);
-	    // draw vert separater in tabpanel
+	    // draw vert separator in tabpanel
 	    for (vsrow = 0; vsrow < cmdline_row; vsrow++)
 		screen_putchar(curwin->w_fill_chars.tpl_vert, vsrow,
 			maxwidth - VERT_LEN, vs_attr);
@@ -272,8 +265,8 @@
     int is_right = tpl_align == ALIGN_RIGHT;
     if (tplmode == TPLMODE_REDRAW)
 	screen_fill(row_start, row_end,
-		(is_right ? COLUMNS_WITHOUT_TPL() : 0) + col_start,
-		(is_right ? COLUMNS_WITHOUT_TPL() : 0) + col_end,
+		(is_right ? topframe->fr_width : 0) + col_start,
+		(is_right ? topframe->fr_width : 0) + col_end,
 		TPL_FILLCHAR, TPL_FILLCHAR, attr);
 }
 
@@ -356,7 +349,7 @@
 	    if (*pargs->pcol + chcells <= pargs->col_end)
 	    {
 		int off = (tpl_align == ALIGN_RIGHT)
-			? COLUMNS_WITHOUT_TPL()
+			? topframe->fr_width
 			: 0;
 		if (TPLMODE_REDRAW == tplmode
 			&& (*pargs->prow - pargs->offsetrow >= 0
@@ -628,7 +621,7 @@
 		    p++;
 		}
 
-		while (p[i] != '\n' && p[i] != '\r' && (p[i] != NUL))
+		while (p[i] != '\n' && p[i] != '\r' && p[i] != NUL)
 		{
 		    if (i + 1 >= sizeof(buf))
 			break;
diff --git a/src/term.c b/src/term.c
index 2d2c940..bf56361 100644
--- a/src/term.c
+++ b/src/term.c
@@ -3630,7 +3630,17 @@
     if (old_Columns != Columns)
     {
 	old_Columns = Columns;
-	shell_new_columns();	// update window sizes
+
+	tabpage_T *save_curtab = curtab;
+	tabpage_T *tp;
+	FOR_ALL_TABPAGES(tp)
+	{
+	    unuse_tabpage(curtab);
+	    use_tabpage(tp);
+	    shell_new_columns();
+	}
+	unuse_tabpage(curtab);
+	use_tabpage(save_curtab);
     }
 }
 
@@ -4454,16 +4464,9 @@
 {
     OUT_STR(tgoto((char *)T_CS, W_WINROW(wp) + wp->w_height - 1,
 							 W_WINROW(wp) + off));
-#if defined(FEAT_TABPANEL)
-    if (*T_CSV != NUL)
-	OUT_STR(tgoto((char *)T_CSV,
-		wp->w_wincol + wp->w_width - 1 + TPL_LCOL(NULL),
-		wp->w_wincol + TPL_LCOL(NULL)));
-#else
-    if (*T_CSV != NUL && wp->w_width != Columns)
+    if (*T_CSV != NUL && wp->w_width != topframe->fr_width)
 	OUT_STR(tgoto((char *)T_CSV, wp->w_wincol + wp->w_width - 1,
 							       wp->w_wincol));
-#endif
     screen_start();		    // don't know where cursor is now
 }
 
@@ -4475,7 +4478,7 @@
 {
     OUT_STR(tgoto((char *)T_CS, (int)Rows - 1, 0));
     if (*T_CSV != NUL)
-	OUT_STR(tgoto((char *)T_CSV, COLUMNS_WITHOUT_TPL() - 1, 0));
+	OUT_STR(tgoto((char *)T_CSV, topframe->fr_width - 1, 0));
     screen_start();		    // don't know where cursor is now
 }
 
diff --git a/src/terminal.c b/src/terminal.c
index a075840..921b234 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -1351,7 +1351,7 @@
 	// do not use the window cursor position
 	position_cursor(curwin, &curbuf->b_term->tl_cursor_pos);
 	windgoto(W_WINROW(curwin) + curwin->w_wrow,
-		 curwin->w_wincol + curwin->w_wcol + TPL_LCOL(NULL));
+		 curwin->w_wincol + curwin->w_wcol);
     }
     if (redraw)
     {
@@ -4120,8 +4120,7 @@
 #ifdef FEAT_MENU
 				+ winbar_height(wp)
 #endif
-				, wp->w_wincol + TPL_LCOL(wp), pos.col,
-				wp->w_width, -1,
+				, wp->w_wincol, pos.col, wp->w_width, -1,
 #ifdef FEAT_PROP_POPUP
 				popup_is_popup(wp) ? SLF_POPUP :
 #endif
diff --git a/src/testdir/dumps/Test_tabpanel_dont_overflow_into_tabpanel_0.dump b/src/testdir/dumps/Test_tabpanel_dont_overflow_into_tabpanel_0.dump
index 5fd8f9b..6076978 100644
--- a/src/testdir/dumps/Test_tabpanel_dont_overflow_into_tabpanel_0.dump
+++ b/src/testdir/dumps/Test_tabpanel_dont_overflow_into_tabpanel_0.dump
@@ -7,4 +7,4 @@
 | +1#0000000&@9|~+0#4040ff13&| @33
 | +1#0000000&@9|~+0#4040ff13&| @33
 | +1#0000000&@9|~+0#4040ff13&| @33
-| +0#0000000&@36|1|,|1| @4
+| +0#0000000&@26|1|,|1| @10|A|l@1| 
diff --git a/src/testdir/dumps/Test_tabpanel_drawing_01.dump b/src/testdir/dumps/Test_tabpanel_drawing_01.dump
index 8601542..74ba073 100644
--- a/src/testdir/dumps/Test_tabpanel_drawing_01.dump
+++ b/src/testdir/dumps/Test_tabpanel_drawing_01.dump
@@ -3,4 +3,4 @@
 | +1#0000000&@15|~+0#4040ff13&| @27
 | +1#0000000&@15|~+0#4040ff13&| @27
 | +1#0000000&@15|~+0#4040ff13&| @27
-| +0#0000000&@26|0|,|0|-|1| @8|A|l|0|,
+| +0#0000000&@26|0|,|0|-|1| @8|A|l@1| 
diff --git a/src/testdir/dumps/Test_tabpanel_drawing_04.dump b/src/testdir/dumps/Test_tabpanel_drawing_04.dump
index 61b759e..dd3c82e 100644
--- a/src/testdir/dumps/Test_tabpanel_drawing_04.dump
+++ b/src/testdir/dumps/Test_tabpanel_drawing_04.dump
@@ -3,4 +3,4 @@
 | +1&&@15|f+0&&| @27
 | +1&&@15|~+0#4040ff13&| @27
 | +1#0000000&@15|~+0#4040ff13&| @27
-| +0#0000000&@42|1|,
+| +0#0000000&@26|1|,|1| @10|A|l@1| 
diff --git a/src/testdir/dumps/Test_tabpanel_drawing_05.dump b/src/testdir/dumps/Test_tabpanel_drawing_05.dump
index e9ea7cb..08e040b 100644
--- a/src/testdir/dumps/Test_tabpanel_drawing_05.dump
+++ b/src/testdir/dumps/Test_tabpanel_drawing_05.dump
@@ -3,4 +3,4 @@
 | +2&&@15|f+0&&| @27
 |2+2&&|:|X+0#4040ff13&|t|a|b|p|a|n|e|l|2| +2#0000000&@3|~+0#4040ff13&| @27
 | +1#0000000&@15|~+0#4040ff13&| @27
-| +0#0000000&@42|1|,
+| +0#0000000&@26|1|,|1| @10|A|l@1| 
diff --git a/src/testdir/dumps/Test_tabpanel_drawing_fill_tailing_0.dump b/src/testdir/dumps/Test_tabpanel_drawing_fill_tailing_0.dump
index 40e3bd7..4ca56d4 100644
--- a/src/testdir/dumps/Test_tabpanel_drawing_fill_tailing_0.dump
+++ b/src/testdir/dumps/Test_tabpanel_drawing_fill_tailing_0.dump
@@ -7,4 +7,4 @@
 |b+2#0000000&@2|.|t|x|t| @12|~+0#4040ff13&| @23
 |B+2#0000000&|O|T@1|O|M| @13|~+0#4040ff13&| @23
 | +1#0000000&@19|~+0#4040ff13&| @23
-| +0#0000000&@44
+| +0#0000000&@26|0|,|0|-|1| @8|A|l@1| 
diff --git a/src/testdir/dumps/Test_tabpanel_drawing_pum_0.dump b/src/testdir/dumps/Test_tabpanel_drawing_pum_0.dump
index 190e5d9..d98dbfd 100644
--- a/src/testdir/dumps/Test_tabpanel_drawing_pum_0.dump
+++ b/src/testdir/dumps/Test_tabpanel_drawing_pum_0.dump
@@ -1,10 +1,10 @@
-|a+8#0000001#e0e0e08@2|.|t|x|t| @12|!+0#0000000#ffffff0> @23
-|b+2&&@2|.|t|x|t| @12|!+0#0000001#e0e0e08| @14| +0#0000000#0000001| +0#4040ff13#ffffff0@7
-| +1#0000000&@19|#+0#0000001#ffd7ff255| @14| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@7
-| +1#0000000&@19|&+0#0000001#ffd7ff255| @14| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@7
-| +1#0000000&@19|*+0#0000001#ffd7ff255| @14| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@7
-| +1#0000000&@19|++0#0000001#ffd7ff255@1| @13| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@7
-| +1#0000000&@19|-+0#0000001#ffd7ff255@1| @13| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@7
-| +1#0000000&@19|<+0#0000001#ffd7ff255| @14| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@7
-| +1#0000000&@19|=+0#0000001#ffd7ff255| @14| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@7
-|-+2#0000000&@1| |m+0#00e0003&|a|t|c|h| |1| |o|f| |5|9|6| +0#0000000&@27
+|a+8#0000001#e0e0e08@2|.|t|x|t| @12|a+0#0000000#ffffff0@1> @22
+|++2&&| |b@2|.|t|x|t| @9| +0#0000001#e0e0e08|a@1| @12| +0#0000000#ffffff0@9
+| +1&&@18| +0#0000001#ffd7ff255|a@3| @10| +0#0000000#ffffff0@9
+| +1&&@18| +0#0000001#ffd7ff255|a@2|c| @10| +0#0000000#ffffff0@9
+| +1&&@18| +0#0000001#ffd7ff255|a@2|b| @10| +0#0000000#ffffff0@9
+| +1&&@19| +0&&@24
+| +1&&@19|~+0#4040ff13&| @23
+| +1#0000000&@19|~+0#4040ff13&| @23
+| +1#0000000&@19|~+0#4040ff13&| @23
+|-+2#0000000&@1| |m+0#00e0003&|a|t|c|h| |1| |o|f| |4| +0#0000000&@29
diff --git a/src/testdir/dumps/Test_tabpanel_drawing_pum_1.dump b/src/testdir/dumps/Test_tabpanel_drawing_pum_1.dump
index 9888bc0..17e0c97 100644
--- a/src/testdir/dumps/Test_tabpanel_drawing_pum_1.dump
+++ b/src/testdir/dumps/Test_tabpanel_drawing_pum_1.dump
@@ -1,10 +1,10 @@
-|a+8#0000001#e0e0e08@2|.|t|x|t| @12|!+0#0000000#ffffff0| @23
-|++2&&| |b@2|.|t|x|t| @10| +0&&@1|a|b@1|r|e|v|i|a|t|e> @12
-| +1&&@19|~+0#4040ff13&| +0#0000001#e0e0e08|a|b@1|r|e|v|i|a|t|e| @4| +0#4040ff13#ffffff0@7
-| +1#0000000&@19|~+0#4040ff13&| +0#0000001#ffd7ff255|a|b|c|l|e|a|r| @7| +0#4040ff13#ffffff0@7
-| +1#0000000&@19|~+0#4040ff13&| +0#0000001#ffd7ff255|a|b|o|v|e|l|e|f|t| @5| +0#4040ff13#ffffff0@7
-| +1#0000000&@19|~+0#4040ff13&| +0#0000001#ffd7ff255|a|b|s|t|r|a|c|t| @6| +0#4040ff13#ffffff0@7
-| +1#0000000&@19|~+0#4040ff13&| @23
-| +1#0000000&@19|~+0#4040ff13&| @23
+|a+8#0000001#e0e0e08@2|.|t|x|t| @12|a+0#0000000#ffffff0@1| @22
+|++2&&| |b@2|.|t|x|t| @10|a+0&&@1| @22
+| +1&&@19|a+0&&| +0#0000001#ffd7ff255|a@1| @12| +0#0000000#ffffff0@7
+| +1&&@19|a+0&&| +0#0000001#ffd7ff255|a@3| @10| +0#0000000#ffffff0@7
+| +1&&@19|a+0&&| +0#0000001#ffd7ff255|a@2|c| @10| +0#0000000#ffffff0@7
+| +1&&@19| +0&&| +0#0000001#e0e0e08|a@2|b| @10| +0#0000000#ffffff0@7
+| +1&&@19| +0&&@1|a@2|b> @18
+| +1&&@19|~+0#4040ff13&| @23
 | +1#0000000&@19|~+0#4040ff13&| @23
 |-+2#0000000&@1| |m+0#00e0003&|a|t|c|h| |1| |o|f| |4| +0#0000000&@29
diff --git a/src/testdir/dumps/Test_tabpanel_drawing_pum_2.dump b/src/testdir/dumps/Test_tabpanel_drawing_pum_2.dump
new file mode 100644
index 0000000..4ea7b91
--- /dev/null
+++ b/src/testdir/dumps/Test_tabpanel_drawing_pum_2.dump
@@ -0,0 +1,10 @@
+|a+0&#ffffff0@1| @22|a+8#0000001#e0e0e08@2|.|t|x|t| @12
+|a+0#0000000#ffffff0@1| @22|++2&&| |b@2|.|t|x|t| @10
+|a+0&&@3| @20| +1&&@19
+|a+0&&@2|c| @17| +0#0000001#e0e0e08|a@1| @12| +1#0000000#ffffff0@6
+|a+0&&@2|b| @17| +0#0000001#ffd7ff255|a@3| @10| +1#0000000#ffffff0@6
+| +0&&@21| +0#0000001#ffd7ff255|a@2|c| @10| +1#0000000#ffffff0@6
+| +0&&@21| +0#0000001#ffd7ff255|a@2|b| @10| +1#0000000#ffffff0@6
+| +0&&@22|a@1| +1&&@19
+>~+0#4040ff13&| @23| +1#0000000&@19
+|-+2&&@1| |m+0#00e0003&|a|t|c|h| |1| |o|f| |4| +0#0000000&@29
diff --git a/src/testdir/dumps/Test_tabpanel_drawing_with_popupwin_0.dump b/src/testdir/dumps/Test_tabpanel_drawing_with_popupwin_0.dump
index 080fa27..7f390e7 100644
--- a/src/testdir/dumps/Test_tabpanel_drawing_with_popupwin_0.dump
+++ b/src/testdir/dumps/Test_tabpanel_drawing_with_popupwin_0.dump
@@ -1,10 +1,10 @@
-|[+8#0000001#e0e0e08|N|o| |N|a|m|e|]| @10|╔+0#0000000#ffffff0|═|╗|.@18|╔|═|╗
-|[+2&&|S|c|r|a|t|c|h|]| @10|║+0&&|@|║|.@18|║|@|║
-| +1&&@19|╚+0&&|═|╝|.@5|a|t|c|u|r|s|o|r|.@4|╚|═|╝
-| +1&&@19|.+0&&@8>.@15
-| +1&&@19|.+0&&@24
-| +1&&@19|╔+0&&|═|╗|.@18|╔|═|╗
-| +1&&@19|║+0&&|@|║|.@18|║|@|║
-| +1&&@19|╚+0&&|═|╝|.@18|╚|═|╝
-| +1&&@19|.+0&&@24
+|╔+0#ffffff16#e000002|═|╗|.+0#0000000#ffffff0@38|╔+0#ffffff16#e000002|═|╗
+|║|@|║|.+0#0000000#ffffff0@38|║+0#ffffff16#e000002|@|║
+|╚|═|╝|.+0#0000000#ffffff0@38|╚+0#ffffff16#e000002|═|╝
+|.+0#0000000#ffffff0@8|a+0#00e0003&|t|c|u|r|s|o|r|.+0#0000000&@27
+@9>.@35
+@45
+@45
+@45
+@45
 | @44
diff --git a/src/testdir/dumps/Test_tabpanel_drawing_with_popupwin_1.dump b/src/testdir/dumps/Test_tabpanel_drawing_with_popupwin_1.dump
new file mode 100644
index 0000000..72cf385
--- /dev/null
+++ b/src/testdir/dumps/Test_tabpanel_drawing_with_popupwin_1.dump
@@ -0,0 +1,10 @@
+|[+8#0000001#e0e0e08|N|o| |N|a|m|e|]| @10|╔+0#ffffff16#e000002|═|╗|.+0#0000000#ffffff0@18|╔+0#ffffff16#e000002|═|╗
+|[+2#0000000#ffffff0|S|c|r|a|t|c|h|]| @10|║+0#ffffff16#e000002|@|║|.+0#0000000#ffffff0@18|║+0#ffffff16#e000002|@|║
+| +1#0000000#ffffff0@19|╚+0#ffffff16#e000002|═|╝|.+0#0000000#ffffff0@18|╚+0#ffffff16#e000002|═|╝
+| +1#0000000#ffffff0@19|a+0#00e0003&|t|c|u|r|s|o|r|.+0#0000000&@16
+| +1&&@19|.+0&&@8>.@15
+| +1&&@19|.+0&&@24
+| +1&&@19|.+0&&@24
+| +1&&@19|.+0&&@24
+| +1&&@19|.+0&&@24
+| @44
diff --git a/src/testdir/dumps/Test_tabpanel_drawing_with_popupwin_2.dump b/src/testdir/dumps/Test_tabpanel_drawing_with_popupwin_2.dump
new file mode 100644
index 0000000..bee1803
--- /dev/null
+++ b/src/testdir/dumps/Test_tabpanel_drawing_with_popupwin_2.dump
@@ -0,0 +1,10 @@
+|╔+0#ffffff16#e000002|═|╗|.+0#0000000#ffffff0@18|╔+0#ffffff16#e000002|═|╗|[+8#0000001#e0e0e08|N|o| |N|a|m|e|]| @10
+|║+0#ffffff16#e000002|@|║|.+0#0000000#ffffff0@18|║+0#ffffff16#e000002|@|║|[+2#0000000#ffffff0|S|c|r|a|t|c|h|]| @10
+|╚+0#ffffff16#e000002|═|╝|.+0#0000000#ffffff0@18|╚+0#ffffff16#e000002|═|╝| +1#0000000#ffffff0@19
+|.+0&&@8|a+0#00e0003&|t|c|u|r|s|o|r|.+0#0000000&@7| +1&&@19
+|.+0&&@8>.@15| +1&&@19
+|.+0&&@24| +1&&@19
+|.+0&&@24| +1&&@19
+|.+0&&@24| +1&&@19
+|.+0&&@24| +1&&@19
+| +0&&@44
diff --git a/src/testdir/dumps/Test_tabpanel_eval_tabpanel_statusline_tabline_0.dump b/src/testdir/dumps/Test_tabpanel_eval_tabpanel_statusline_tabline_0.dump
index 9214434..dd930c4 100644
--- a/src/testdir/dumps/Test_tabpanel_eval_tabpanel_statusline_tabline_0.dump
+++ b/src/testdir/dumps/Test_tabpanel_eval_tabpanel_statusline_tabline_0.dump
@@ -1,10 +1,10 @@
-|$+8#0000001#e0e0e08| |[|a@2|]| |$|│+1#0000000#ffffff0|$| @13|[|c@2|]| @13|$
-|$+8#0000001#e0e0e08| |[|b@2|]| |$|│+1#0000000#ffffff0> +0&&@34
-|$+2&&| |[|c@2|]| |$|│+1&&|~+0#4040ff13&| @33
-| +1#0000000&@8|│|~+0#4040ff13&| @33
-| +1#0000000&@8|│|~+0#4040ff13&| @33
-| +1#0000000&@8|│|~+0#4040ff13&| @33
-| +1#0000000&@8|│|~+0#4040ff13&| @33
-| +1#0000000&@8|│|~+0#4040ff13&| @33
-| +1#0000000&@8|│|$+3&&| @13|[|c@2|]| @13|$
+|$+8#0000001#e0e0e08| |[|a@2|]| |$||+1#0000000#ffffff0|$| @13|[|c@2|]| @13|$
+|$+8#0000001#e0e0e08| |[|b@2|]| |$||+1#0000000#ffffff0> +0&&@34
+|$+2&&| |[|c@2|]| |$||+1&&|~+0#4040ff13&| @33
+| +1#0000000&@8|||~+0#4040ff13&| @33
+| +1#0000000&@8|||~+0#4040ff13&| @33
+| +1#0000000&@8|||~+0#4040ff13&| @33
+| +1#0000000&@8|||~+0#4040ff13&| @33
+| +1#0000000&@8|||~+0#4040ff13&| @33
+| +1#0000000&@8|||$+3&&| @13|[|c@2|]| @13|$
 |"+0&&|c@2|"| |[|N|e|w|]| @33
diff --git a/src/testdir/dumps/Test_tabpanel_eval_tabpanel_statusline_tabline_1.dump b/src/testdir/dumps/Test_tabpanel_eval_tabpanel_statusline_tabline_1.dump
index dae0d0b..21bb63b 100644
--- a/src/testdir/dumps/Test_tabpanel_eval_tabpanel_statusline_tabline_1.dump
+++ b/src/testdir/dumps/Test_tabpanel_eval_tabpanel_statusline_tabline_1.dump
@@ -1,10 +1,10 @@
-|$+1&#ffffff0| @13|[|c@2|]| @13|$|│|$+8#0000001#e0e0e08| |[|a@2|]| |$
-> +0#0000000#ffffff0@34|│+1&&|$+8#0000001#e0e0e08| |[|b@2|]| |$
-|~+0#4040ff13#ffffff0| @33|│+1#0000000&|$+2&&| |[|c@2|]| |$
-|~+0#4040ff13&| @33|│+1#0000000&| @8
-|~+0#4040ff13&| @33|│+1#0000000&| @8
-|~+0#4040ff13&| @33|│+1#0000000&| @8
-|~+0#4040ff13&| @33|│+1#0000000&| @8
-|~+0#4040ff13&| @33|│+1#0000000&| @8
-|$+3&&| @13|[|c@2|]| @13|$|│+1&&| @8
+|$+1&#ffffff0| @13|[|c@2|]| @13|$|||$+8#0000001#e0e0e08| |[|a@2|]| |$
+> +0#0000000#ffffff0@34||+1&&|$+8#0000001#e0e0e08| |[|b@2|]| |$
+|~+0#4040ff13#ffffff0| @33||+1#0000000&|$+2&&| |[|c@2|]| |$
+|~+0#4040ff13&| @33||+1#0000000&| @8
+|~+0#4040ff13&| @33||+1#0000000&| @8
+|~+0#4040ff13&| @33||+1#0000000&| @8
+|~+0#4040ff13&| @33||+1#0000000&| @8
+|~+0#4040ff13&| @33||+1#0000000&| @8
+|$+3&&| @13|[|c@2|]| @13|$||+1&&| @8
 |:+0&&|s|e|t| |t|a|b|p|a|n|e|l|o|p|t|+|=|a|l|i|g|n|:|r|i|g|h|t| @15
diff --git a/src/testdir/dumps/Test_tabpanel_eval_tabpanel_with_linebreaks_0.dump b/src/testdir/dumps/Test_tabpanel_eval_tabpanel_with_linebreaks_0.dump
index dd55218..b062f21 100644
--- a/src/testdir/dumps/Test_tabpanel_eval_tabpanel_with_linebreaks_0.dump
+++ b/src/testdir/dumps/Test_tabpanel_eval_tabpanel_with_linebreaks_0.dump
@@ -7,4 +7,4 @@
 |t+2#0000000&|o|p| @6|~+0#4040ff13&| @33
 |$+2#0000000&| |[|c@2|]| @1|$|~+0#4040ff13&| @33
 |b+2#0000000&|o|t@1|o|m| @3|~+0#4040ff13&| @33
-|"+0#0000000&|c@2|"| |[|N|e|w|]| @25|0|,|0|-|1| @2
+|"+0#0000000&|c@2|"| |[|N|e|w|]| @33
diff --git a/src/testdir/dumps/Test_tabpanel_eval_tabpanel_with_linebreaks_1.dump b/src/testdir/dumps/Test_tabpanel_eval_tabpanel_with_linebreaks_1.dump
index 84bf683..4e5a3fb 100644
--- a/src/testdir/dumps/Test_tabpanel_eval_tabpanel_with_linebreaks_1.dump
+++ b/src/testdir/dumps/Test_tabpanel_eval_tabpanel_with_linebreaks_1.dump
@@ -7,4 +7,4 @@
 |~+0#4040ff13#ffffff0| @33|t+2#0000000&|o|p| @6
 |~+0#4040ff13&| @33|$+2#0000000&| |[|c@2|]| @1|$
 |~+0#4040ff13&| @33|b+2#0000000&|o|t@1|o|m| @3
-|:+0&&|s|e|t| |t|a|b|p|a|n|e|l|o|p|t|+|=|a|l|i|g|n|:|r|i|g|0|,|0|-|1| @8|A|l@1| 
+|:+0&&|s|e|t| |t|a|b|p|a|n|e|l|o|p|t|+|=|a|l|i|g|n|:|r|i|g|h|t| @15
diff --git a/src/testdir/dumps/Test_tabpanel_many_tabpages_0.dump b/src/testdir/dumps/Test_tabpanel_many_tabpages_0.dump
index e974381..d5a0e4a 100644
--- a/src/testdir/dumps/Test_tabpanel_many_tabpages_0.dump
+++ b/src/testdir/dumps/Test_tabpanel_many_tabpages_0.dump
@@ -7,4 +7,4 @@
 |7+8#0000001#e0e0e08|:|t|a|b| @4|~+0#4040ff13#ffffff0| @33
 |8+8#0000001#e0e0e08|:|t|a|b| @4|~+0#4040ff13#ffffff0| @33
 |9+8#0000001#e0e0e08|:|t|a|b| @4|~+0#4040ff13#ffffff0| @33
-| +0#0000000&@36|0|,|0|-|1| @2
+| +0#0000000&@26|0|,|0|-|1| @8|A|l@1| 
diff --git a/src/testdir/dumps/Test_tabpanel_many_tabpages_1.dump b/src/testdir/dumps/Test_tabpanel_many_tabpages_1.dump
index 3ac3dde..d946a31 100644
--- a/src/testdir/dumps/Test_tabpanel_many_tabpages_1.dump
+++ b/src/testdir/dumps/Test_tabpanel_many_tabpages_1.dump
@@ -7,4 +7,4 @@
 |7+8#0000001#e0e0e08|:|t|a|b| @4|~+0#4040ff13#ffffff0| @33
 |8+8#0000001#e0e0e08|:|t|a|b| @4|~+0#4040ff13#ffffff0| @33
 |9+8#0000001#e0e0e08|:|t|a|b| @4|~+0#4040ff13#ffffff0| @33
-| +0#0000000&@36|0|,|0|-|1| @2
+| +0#0000000&@26|0|,|0|-|1| @8|A|l@1| 
diff --git a/src/testdir/dumps/Test_tabpanel_many_tabpages_2.dump b/src/testdir/dumps/Test_tabpanel_many_tabpages_2.dump
index 7b980e6..74b2b7b 100644
--- a/src/testdir/dumps/Test_tabpanel_many_tabpages_2.dump
+++ b/src/testdir/dumps/Test_tabpanel_many_tabpages_2.dump
@@ -7,4 +7,4 @@
 |7+8#0000001#e0e0e08|:|t|a|b| @4|~+0#4040ff13#ffffff0| @33
 |8+8#0000001#e0e0e08|:|t|a|b| @4|~+0#4040ff13#ffffff0| @33
 |9+8#0000001#e0e0e08|:|t|a|b| @4|~+0#4040ff13#ffffff0| @33
-| +0#0000000&@36|0|,|0|-|1| @2
+| +0#0000000&@26|0|,|0|-|1| @8|A|l@1| 
diff --git a/src/testdir/dumps/Test_tabpanel_many_tabpages_3.dump b/src/testdir/dumps/Test_tabpanel_many_tabpages_3.dump
index fa3c09c..037a53a 100644
--- a/src/testdir/dumps/Test_tabpanel_many_tabpages_3.dump
+++ b/src/testdir/dumps/Test_tabpanel_many_tabpages_3.dump
@@ -7,4 +7,4 @@
 |7+8#0000001#e0e0e08|:|t|a|b| @4|~+0#4040ff13#ffffff0| @33
 |8+8#0000001#e0e0e08|:|t|a|b| @4|~+0#4040ff13#ffffff0| @33
 |9+8#0000001#e0e0e08|:|t|a|b| @4|~+0#4040ff13#ffffff0| @33
-| +0#0000000&@36|0|,|0|-|1| @2
+| +0#0000000&@26|0|,|0|-|1| @8|A|l@1| 
diff --git a/src/testdir/dumps/Test_tabpanel_many_tabpages_4.dump b/src/testdir/dumps/Test_tabpanel_many_tabpages_4.dump
index 07ff180..70905a6 100644
--- a/src/testdir/dumps/Test_tabpanel_many_tabpages_4.dump
+++ b/src/testdir/dumps/Test_tabpanel_many_tabpages_4.dump
@@ -7,4 +7,4 @@
 |1+8#0000001#e0e0e08|6|:|t|a|b| @3|~+0#4040ff13#ffffff0| @33
 |1+8#0000001#e0e0e08|7|:|t|a|b| @3|~+0#4040ff13#ffffff0| @33
 |1+8#0000001#e0e0e08|8|:|t|a|b| @3|~+0#4040ff13#ffffff0| @33
-|:+0#0000000&|t|a|b|n|e|x|t| |-|3| @25|0|,|0|-|1| @2
+|:+0#0000000&|t|a|b|n|e|x|t| |-|3| @15|0|,|0|-|1| @8|A|l@1| 
diff --git a/src/testdir/dumps/Test_tabpanel_noeval_tabpanel_statusline_tabline_0.dump b/src/testdir/dumps/Test_tabpanel_noeval_tabpanel_statusline_tabline_0.dump
index 9214434..dd930c4 100644
--- a/src/testdir/dumps/Test_tabpanel_noeval_tabpanel_statusline_tabline_0.dump
+++ b/src/testdir/dumps/Test_tabpanel_noeval_tabpanel_statusline_tabline_0.dump
@@ -1,10 +1,10 @@
-|$+8#0000001#e0e0e08| |[|a@2|]| |$|│+1#0000000#ffffff0|$| @13|[|c@2|]| @13|$
-|$+8#0000001#e0e0e08| |[|b@2|]| |$|│+1#0000000#ffffff0> +0&&@34
-|$+2&&| |[|c@2|]| |$|│+1&&|~+0#4040ff13&| @33
-| +1#0000000&@8|│|~+0#4040ff13&| @33
-| +1#0000000&@8|│|~+0#4040ff13&| @33
-| +1#0000000&@8|│|~+0#4040ff13&| @33
-| +1#0000000&@8|│|~+0#4040ff13&| @33
-| +1#0000000&@8|│|~+0#4040ff13&| @33
-| +1#0000000&@8|│|$+3&&| @13|[|c@2|]| @13|$
+|$+8#0000001#e0e0e08| |[|a@2|]| |$||+1#0000000#ffffff0|$| @13|[|c@2|]| @13|$
+|$+8#0000001#e0e0e08| |[|b@2|]| |$||+1#0000000#ffffff0> +0&&@34
+|$+2&&| |[|c@2|]| |$||+1&&|~+0#4040ff13&| @33
+| +1#0000000&@8|||~+0#4040ff13&| @33
+| +1#0000000&@8|||~+0#4040ff13&| @33
+| +1#0000000&@8|||~+0#4040ff13&| @33
+| +1#0000000&@8|||~+0#4040ff13&| @33
+| +1#0000000&@8|||~+0#4040ff13&| @33
+| +1#0000000&@8|||$+3&&| @13|[|c@2|]| @13|$
 |"+0&&|c@2|"| |[|N|e|w|]| @33
diff --git a/src/testdir/dumps/Test_tabpanel_noeval_tabpanel_statusline_tabline_1.dump b/src/testdir/dumps/Test_tabpanel_noeval_tabpanel_statusline_tabline_1.dump
index dae0d0b..21bb63b 100644
--- a/src/testdir/dumps/Test_tabpanel_noeval_tabpanel_statusline_tabline_1.dump
+++ b/src/testdir/dumps/Test_tabpanel_noeval_tabpanel_statusline_tabline_1.dump
@@ -1,10 +1,10 @@
-|$+1&#ffffff0| @13|[|c@2|]| @13|$|│|$+8#0000001#e0e0e08| |[|a@2|]| |$
-> +0#0000000#ffffff0@34|│+1&&|$+8#0000001#e0e0e08| |[|b@2|]| |$
-|~+0#4040ff13#ffffff0| @33|│+1#0000000&|$+2&&| |[|c@2|]| |$
-|~+0#4040ff13&| @33|│+1#0000000&| @8
-|~+0#4040ff13&| @33|│+1#0000000&| @8
-|~+0#4040ff13&| @33|│+1#0000000&| @8
-|~+0#4040ff13&| @33|│+1#0000000&| @8
-|~+0#4040ff13&| @33|│+1#0000000&| @8
-|$+3&&| @13|[|c@2|]| @13|$|│+1&&| @8
+|$+1&#ffffff0| @13|[|c@2|]| @13|$|||$+8#0000001#e0e0e08| |[|a@2|]| |$
+> +0#0000000#ffffff0@34||+1&&|$+8#0000001#e0e0e08| |[|b@2|]| |$
+|~+0#4040ff13#ffffff0| @33||+1#0000000&|$+2&&| |[|c@2|]| |$
+|~+0#4040ff13&| @33||+1#0000000&| @8
+|~+0#4040ff13&| @33||+1#0000000&| @8
+|~+0#4040ff13&| @33||+1#0000000&| @8
+|~+0#4040ff13&| @33||+1#0000000&| @8
+|~+0#4040ff13&| @33||+1#0000000&| @8
+|$+3&&| @13|[|c@2|]| @13|$||+1&&| @8
 |:+0&&|s|e|t| |t|a|b|p|a|n|e|l|o|p|t|+|=|a|l|i|g|n|:|r|i|g|h|t| @15
diff --git a/src/testdir/dumps/Test_tabpanel_quitall_0.dump b/src/testdir/dumps/Test_tabpanel_quitall_0.dump
new file mode 100644
index 0000000..7399ca1
--- /dev/null
+++ b/src/testdir/dumps/Test_tabpanel_quitall_0.dump
@@ -0,0 +1,10 @@
+|[+8#0000001#e0e0e08|N|o| |N|a|m|e|]| @11|[|N|o| |N|a|m|e|]| | +2#0000000#ffffff0|+| |N|o| |N|a|m|e|]| | +1&&|X+8#0000001#e0e0e08
+|++2#0000000#ffffff0| |[|N|o| |N|a|m|e|]| @8>a+0&&@2| @21
+| +1&&@19|~+0#4040ff13&| @23
+| +1#0000000&@19|~+0#4040ff13&| @23
+| +1#0000000&@19|~+0#4040ff13&| @23
+| +1#0000000&@19|~+0#4040ff13&| @23
+| +1#0000000&@19|~+0#4040ff13&| @23
+| +1#0000000&@19|~+0#4040ff13&| @23
+| +1#0000000&@19|<+3&&|o| |N|a|m|e|]| |[|+|]| |1|,|1| @5|A|l@1
+| +0&&@44
diff --git a/src/testdir/dumps/Test_tabpanel_ruler_0.dump b/src/testdir/dumps/Test_tabpanel_ruler_0.dump
new file mode 100644
index 0000000..d1e2d75
--- /dev/null
+++ b/src/testdir/dumps/Test_tabpanel_ruler_0.dump
@@ -0,0 +1,10 @@
+|[+8#0000001#e0e0e08|N|o| |N|a|m|e|]| @11|[|N|o| |N|a|m|e|]| | +2#0000000#ffffff0|[|N|o| |N|a|m|e|]| | +1&&@1|X+8#0000001#e0e0e08
+|[+2#0000000#ffffff0|N|o| |N|a|m|e|]| @10> +0&&@24
+| +1&&@19|~+0#4040ff13&| @23
+| +1#0000000&@19|~+0#4040ff13&| @23
+| +1#0000000&@19|~+0#4040ff13&| @23
+| +1#0000000&@19|~+0#4040ff13&| @23
+| +1#0000000&@19|~+0#4040ff13&| @23
+| +1#0000000&@19|~+0#4040ff13&| @23
+| +1#0000000&@19|~+0#4040ff13&| @23
+| +0#0000000&@26|0|,|0|-|1| @8|A|l@1| 
diff --git a/src/testdir/dumps/Test_tabpanel_stpl_eq_1_0.dump b/src/testdir/dumps/Test_tabpanel_stpl_eq_1_0.dump
new file mode 100644
index 0000000..4c75895
--- /dev/null
+++ b/src/testdir/dumps/Test_tabpanel_stpl_eq_1_0.dump
@@ -0,0 +1,10 @@
+> +0&#ffffff0@77
+|~+0#4040ff13&| @76
+|~| @76
+|~| @76
+|~| @76
+|~| @76
+|~| @76
+|~| @76
+|~| @76
+| +0#0000000&@77
diff --git a/src/testdir/dumps/Test_tabpanel_stpl_eq_1_1.dump b/src/testdir/dumps/Test_tabpanel_stpl_eq_1_1.dump
new file mode 100644
index 0000000..ac61649
--- /dev/null
+++ b/src/testdir/dumps/Test_tabpanel_stpl_eq_1_1.dump
@@ -0,0 +1,10 @@
+|[+8#0000001#e0e0e08|N|o| |N|a|m|e|]| @11|[|N|o| |N|a|m|e|]| | +2#0000000#ffffff0|[|N|o| |N|a|m|e|]| | +1&&@34|X+8#0000001#e0e0e08
+|[+2#0000000#ffffff0|N|o| |N|a|m|e|]| @10> +0&&@57
+| +1&&@19|~+0#4040ff13&| @56
+| +1#0000000&@19|~+0#4040ff13&| @56
+| +1#0000000&@19|~+0#4040ff13&| @56
+| +1#0000000&@19|~+0#4040ff13&| @56
+| +1#0000000&@19|~+0#4040ff13&| @56
+| +1#0000000&@19|~+0#4040ff13&| @56
+| +1#0000000&@19|~+0#4040ff13&| @56
+| +0#0000000&@77
diff --git a/src/testdir/dumps/Test_tabpanel_stpl_eq_1_2.dump b/src/testdir/dumps/Test_tabpanel_stpl_eq_1_2.dump
new file mode 100644
index 0000000..6199036
--- /dev/null
+++ b/src/testdir/dumps/Test_tabpanel_stpl_eq_1_2.dump
@@ -0,0 +1,10 @@
+|2+2#e000e06#ffffff0| +2#0000000&|[|N|o| |N|a|m|e|]| @9|2+2#e000e06&| +2#0000000&|[|N|o| |N|a|m|e|]| | +8#0000001#e0e0e08|[|N|o| |N|a|m|e|]| | +1#0000000#ffffff0@32|X+8#0000001#e0e0e08
+|[|N|o| |N|a|m|e|]| @10> +0#0000000#ffffff0@28||+1&&| +0&&@27
+| +1&&@19|~+0#4040ff13&| @27||+1#0000000&|~+0#4040ff13&| @26
+| +1#0000000&@19|~+0#4040ff13&| @27||+1#0000000&|~+0#4040ff13&| @26
+| +1#0000000&@19|~+0#4040ff13&| @27||+1#0000000&|~+0#4040ff13&| @26
+| +1#0000000&@19|~+0#4040ff13&| @27||+1#0000000&|~+0#4040ff13&| @26
+| +1#0000000&@19|~+0#4040ff13&| @27||+1#0000000&|~+0#4040ff13&| @26
+| +1#0000000&@19|~+0#4040ff13&| @27||+1#0000000&|~+0#4040ff13&| @26
+| +1#0000000&@19|[+3&&|N|o| |N|a|m|e|]| @20|[+1&&|N|o| |N|a|m|e|]| @18
+| +0&&@77
diff --git a/src/testdir/dumps/Test_tabpanel_stpl_eq_1_3.dump b/src/testdir/dumps/Test_tabpanel_stpl_eq_1_3.dump
new file mode 100644
index 0000000..6311208
--- /dev/null
+++ b/src/testdir/dumps/Test_tabpanel_stpl_eq_1_3.dump
@@ -0,0 +1,10 @@
+| +8#0000001#e0e0e08|[|N|o| |N|a|m|e|]| | +2#0000000#ffffff0|[|N|o| |N|a|m|e|]| | +1&&@35|[+8#0000001#e0e0e08|N|o| |N|a|m|e|]| @10
+> +0#0000000#ffffff0@57|[+2&&|N|o| |N|a|m|e|]| @10
+|~+0#4040ff13&| @56| +1#0000000&@19
+|~+0#4040ff13&| @56| +1#0000000&@19
+|~+0#4040ff13&| @56| +1#0000000&@19
+|~+0#4040ff13&| @56| +1#0000000&@19
+|~+0#4040ff13&| @56| +1#0000000&@19
+|~+0#4040ff13&| @56| +1#0000000&@19
+|~+0#4040ff13&| @56| +1#0000000&@19
+| +0&&@77
diff --git a/src/testdir/dumps/Test_tabpanel_stpl_eq_1_4.dump b/src/testdir/dumps/Test_tabpanel_stpl_eq_1_4.dump
new file mode 100644
index 0000000..3c88269
--- /dev/null
+++ b/src/testdir/dumps/Test_tabpanel_stpl_eq_1_4.dump
@@ -0,0 +1,10 @@
+| +2&#ffffff0|2+2#e000e06&| +2#0000000&|[|N|o| |N|a|m|e|]| | +8#0000001#e0e0e08|[|N|o| |N|a|m|e|]| | +1#0000000#ffffff0@33|2+2#e000e06&| +2#0000000&|[|N|o| |N|a|m|e|]| @8
+> +0&&@28||+1&&| +0&&@27|[+8#0000001#e0e0e08|N|o| |N|a|m|e|]| @10
+|~+0#4040ff13#ffffff0| @27||+1#0000000&|~+0#4040ff13&| @26| +1#0000000&@19
+|~+0#4040ff13&| @27||+1#0000000&|~+0#4040ff13&| @26| +1#0000000&@19
+|~+0#4040ff13&| @27||+1#0000000&|~+0#4040ff13&| @26| +1#0000000&@19
+|~+0#4040ff13&| @27||+1#0000000&|~+0#4040ff13&| @26| +1#0000000&@19
+|~+0#4040ff13&| @27||+1#0000000&|~+0#4040ff13&| @26| +1#0000000&@19
+|~+0#4040ff13&| @27||+1#0000000&|~+0#4040ff13&| @26| +1#0000000&@19
+|[+3&&|N|o| |N|a|m|e|]| @20|[+1&&|N|o| |N|a|m|e|]| @38
+| +0&&@77
diff --git a/src/testdir/dumps/Test_tabpanel_tabline_and_tabpanel_0.dump b/src/testdir/dumps/Test_tabpanel_tabline_and_tabpanel_0.dump
index fdca7f1..14400e5 100644
--- a/src/testdir/dumps/Test_tabpanel_tabline_and_tabpanel_0.dump
+++ b/src/testdir/dumps/Test_tabpanel_tabline_and_tabpanel_0.dump
@@ -7,4 +7,4 @@
 | +1#0000000&@8|│|~+0#4040ff13&| @33
 | +1#0000000&@8|│|~+0#4040ff13&| @33
 | +1#0000000&@8|│|~+0#4040ff13&| @33
-|"+0#0000000&|c@2|.|t|x|t|"| |[|N|e|w|]| @21|0|,|0|-|1| @2
+|"+0#0000000&|c@2|.|t|x|t|"| |[|N|e|w|]| @11|0|,|0|-|1| @8|A|l@1| 
diff --git a/src/testdir/dumps/Test_tabpanel_vert_is_multibytes_left_0.dump b/src/testdir/dumps/Test_tabpanel_vert_is_multibytes_left_0.dump
index a50355f..284e23a 100644
--- a/src/testdir/dumps/Test_tabpanel_vert_is_multibytes_left_0.dump
+++ b/src/testdir/dumps/Test_tabpanel_vert_is_multibytes_left_0.dump
@@ -7,4 +7,4 @@
 | +1#0000000&@8|│|~+0#4040ff13&| @33
 | +1#0000000&@8|│|~+0#4040ff13&| @33
 | +1#0000000&@8|│|~+0#4040ff13&| @33
-| +0#0000000&@36|0|,|0|-|1| @2
+| +0#0000000&@26|0|,|0|-|1| @8|A|l@1| 
diff --git a/src/testdir/dumps/Test_tabpanel_vert_is_multibytes_left_1.dump b/src/testdir/dumps/Test_tabpanel_vert_is_multibytes_left_1.dump
index e347c7e..d3fec73 100644
--- a/src/testdir/dumps/Test_tabpanel_vert_is_multibytes_left_1.dump
+++ b/src/testdir/dumps/Test_tabpanel_vert_is_multibytes_left_1.dump
@@ -7,4 +7,4 @@
 |│+1#0000000&|~+0#4040ff13&| @42
 |│+1#0000000&|~+0#4040ff13&| @42
 |│+1#0000000&|~+0#4040ff13&| @42
-|:+0#0000000&|s|e|t| |t|a|b|p|a|n|e|l|o|p|t|=|c|o|l|u|m|n|s|:|1|,|v|0|,|0|-|1| @8|A|l@1
+|:+0#0000000&|s|e|t| |t|a|b|p|a|n|e|l|o|p|t|=|c|o|l|u|m|n|s|:|1|,|0|,|0|-|1| @8|A|l@1| 
diff --git a/src/testdir/dumps/Test_tabpanel_vert_is_multibytes_left_2.dump b/src/testdir/dumps/Test_tabpanel_vert_is_multibytes_left_2.dump
index d1c5b92..fc0b17a 100644
--- a/src/testdir/dumps/Test_tabpanel_vert_is_multibytes_left_2.dump
+++ b/src/testdir/dumps/Test_tabpanel_vert_is_multibytes_left_2.dump
@@ -7,4 +7,4 @@
 | +1#0000000&@8|│|~+0#4040ff13&| @33
 | +1#0000000&@8|│|~+0#4040ff13&| @33
 | +1#0000000&@8|│|~+0#4040ff13&| @33
-|:+0#0000000&|s|e|t| |t|a|b|p|a|n|e|l|o|p|t|=|c|o|l|u|m|n|s|:|1|0|,|v|e|r|t| @4|0|,|0|-|1| @2
+|:+0#0000000&|s|e|t| |t|a|b|p|a|n|e|l|o|p|t|=|c|o|l|u|m|n|s|:|1|0@1|,|0|-|1| @8|A|l@1| 
diff --git a/src/testdir/dumps/Test_tabpanel_vert_is_multibytes_left_3.dump b/src/testdir/dumps/Test_tabpanel_vert_is_multibytes_left_3.dump
index fc84c0b..24db3dd 100644
--- a/src/testdir/dumps/Test_tabpanel_vert_is_multibytes_left_3.dump
+++ b/src/testdir/dumps/Test_tabpanel_vert_is_multibytes_left_3.dump
@@ -7,4 +7,4 @@
 | +1#0000000&|│|~+0#4040ff13&| @41
 | +1#0000000&|│|~+0#4040ff13&| @41
 | +1#0000000&|│|~+0#4040ff13&| @41
-|:+0#0000000&|s|e|t| |t|a|b|p|a|n|e|l|o|p|t|=|c|o|l|u|m|n|s|:|2|,|v|e|0|,|0|-|1| @8|A|l
+|:+0#0000000&|s|e|t| |t|a|b|p|a|n|e|l|o|p|t|=|c|o|l|u|m|n|s|:|2|,|0|,|0|-|1| @8|A|l@1| 
diff --git a/src/testdir/dumps/Test_tabpanel_visual_0.dump b/src/testdir/dumps/Test_tabpanel_visual_0.dump
index af7ba65..14d50af 100644
--- a/src/testdir/dumps/Test_tabpanel_visual_0.dump
+++ b/src/testdir/dumps/Test_tabpanel_visual_0.dump
@@ -7,4 +7,4 @@
 | +1#0000000&@9|~+0#4040ff13&| @33
 | +1#0000000&@9|~+0#4040ff13&| @33
 | +1#0000000&@9|~+0#4040ff13&| @33
-|-+2#0000000&@1| |V|I|S|U|A|L| |-@1| +0&&@4|1@1| @17|1|,|1@1| @3
+|-+2#0000000&@1| |V|I|S|U|A|L| |-@1| +0&&@4|1@1| @7|1|,|1@1| @9|A|l@1| 
diff --git a/src/testdir/dumps/Test_tabpanel_visual_1.dump b/src/testdir/dumps/Test_tabpanel_visual_1.dump
index 0cdc5f2..5d4a660 100644
--- a/src/testdir/dumps/Test_tabpanel_visual_1.dump
+++ b/src/testdir/dumps/Test_tabpanel_visual_1.dump
@@ -7,4 +7,4 @@
 | +1#0000000&@9|~+0#4040ff13&| @33
 | +1#0000000&@9|~+0#4040ff13&| @33
 | +1#0000000&@9|~+0#4040ff13&| @33
-|-+2#0000000&@1| |V|I|S|U|A|L| |-@1| +0&&@4|9| @18|2|,|1|4| @3
+|-+2#0000000&@1| |V|I|S|U|A|L| |-@1| +0&&@4|9| @8|2|,|1|4| @9|A|l@1| 
diff --git a/src/testdir/dumps/Test_tabpanel_visual_2.dump b/src/testdir/dumps/Test_tabpanel_visual_2.dump
index 9a307c1..c800684 100644
--- a/src/testdir/dumps/Test_tabpanel_visual_2.dump
+++ b/src/testdir/dumps/Test_tabpanel_visual_2.dump
@@ -7,4 +7,4 @@
 | +1#0000000&@9|~+0#4040ff13&| @33
 | +1#0000000&@9|~+0#4040ff13&| @33
 | +1#0000000&@9|~+0#4040ff13&| @33
-|b+0#0000000&@2|2| |c@2|2| @27|2|,|6| @4
+|b+0#0000000&@2|2| |c@2|2| @17|2|,|6| @10|A|l@1| 
diff --git a/src/testdir/dumps/Test_tabpanel_with_vsplit_0.dump b/src/testdir/dumps/Test_tabpanel_with_vsplit_0.dump
new file mode 100644
index 0000000..836e07b
--- /dev/null
+++ b/src/testdir/dumps/Test_tabpanel_with_vsplit_0.dump
@@ -0,0 +1,10 @@
+|[+8#0000001#e0e0e08|N|o| |N|a|m|e|]| @10> +0#0000000#ffffff0@57
+|[+2&&|N|o| |N|a|m|e|]| @10|~+0#4040ff13&| @56
+| +1#0000000&@19|~+0#4040ff13&| @56
+| +1#0000000&@19|~+0#4040ff13&| @56
+| +1#0000000&@19|~+0#4040ff13&| @56
+| +1#0000000&@19|~+0#4040ff13&| @56
+| +1#0000000&@19|~+0#4040ff13&| @56
+| +1#0000000&@19|~+0#4040ff13&| @56
+| +1#0000000&@19|~+0#4040ff13&| @56
+| +0#0000000&@59|0|,|0|-|1| @8|A|l@1| 
diff --git a/src/testdir/dumps/Test_tabpanel_with_vsplit_1.dump b/src/testdir/dumps/Test_tabpanel_with_vsplit_1.dump
new file mode 100644
index 0000000..81653d7
--- /dev/null
+++ b/src/testdir/dumps/Test_tabpanel_with_vsplit_1.dump
@@ -0,0 +1,10 @@
+|[+8#0000001#e0e0e08|N|o| |N|a|m|e|]| @10> +0#0000000#ffffff0@28||+1&&| +0&&@27
+|2+2#e000e06&| +2#0000000&|[|N|o| |N|a|m|e|]| @8|~+0#4040ff13&| @27||+1#0000000&|~+0#4040ff13&| @26
+| +1#0000000&@19|~+0#4040ff13&| @27||+1#0000000&|~+0#4040ff13&| @26
+| +1#0000000&@19|~+0#4040ff13&| @27||+1#0000000&|~+0#4040ff13&| @26
+| +1#0000000&@19|~+0#4040ff13&| @27||+1#0000000&|~+0#4040ff13&| @26
+| +1#0000000&@19|~+0#4040ff13&| @27||+1#0000000&|~+0#4040ff13&| @26
+| +1#0000000&@19|~+0#4040ff13&| @27||+1#0000000&|~+0#4040ff13&| @26
+| +1#0000000&@19|~+0#4040ff13&| @27||+1#0000000&|~+0#4040ff13&| @26
+| +1#0000000&@19|[+3&&|N|o| |N|a|m|e|]| @5|0|,|0|-|1| @5|A|l@1| |[+1&&|N|o| |N|a|m|e|]| @4|0|,|0|-|1| @5|A|l@1
+|:+0&&|v|s|p|l|i|t| @70
diff --git a/src/testdir/dumps/Test_tabpanel_with_vsplit_2.dump b/src/testdir/dumps/Test_tabpanel_with_vsplit_2.dump
new file mode 100644
index 0000000..82d3356
--- /dev/null
+++ b/src/testdir/dumps/Test_tabpanel_with_vsplit_2.dump
@@ -0,0 +1,10 @@
+|[+8#0000001#e0e0e08|N|o| |N|a|m|e|]| @10> +0#0000000#ffffff0@19||+1&&| +0&&@17||+1&&| +0&&@17
+|3+2#e000e06&| +2#0000000&|[|N|o| |N|a|m|e|]| @8|~+0#4040ff13&| @18||+1#0000000&|~+0#4040ff13&| @16||+1#0000000&|~+0#4040ff13&| @16
+| +1#0000000&@19|~+0#4040ff13&| @18||+1#0000000&|~+0#4040ff13&| @16||+1#0000000&|~+0#4040ff13&| @16
+| +1#0000000&@19|~+0#4040ff13&| @18||+1#0000000&|~+0#4040ff13&| @16||+1#0000000&|~+0#4040ff13&| @16
+| +1#0000000&@19|~+0#4040ff13&| @18||+1#0000000&|~+0#4040ff13&| @16||+1#0000000&|~+0#4040ff13&| @16
+| +1#0000000&@19|~+0#4040ff13&| @18||+1#0000000&|~+0#4040ff13&| @16||+1#0000000&|~+0#4040ff13&| @16
+| +1#0000000&@19|~+0#4040ff13&| @18||+1#0000000&|~+0#4040ff13&| @16||+1#0000000&|~+0#4040ff13&| @16
+| +1#0000000&@19|~+0#4040ff13&| @18||+1#0000000&|~+0#4040ff13&| @16||+1#0000000&|~+0#4040ff13&| @16
+| +1#0000000&@19|<+3&&|N|o| |N|a|m|e|]| |0|,|0|-|1| @1|A|l@1| |<+1&&|o| |N|a|m|e|]| |0|,|0|-|1| |A|l@1| |<|o| |N|a|m|e|]| |0|,|0|-|1| |A|l@1
+|:+0&&|v|s|p|l|i|t| @70
diff --git a/src/testdir/dumps/Test_tabpanel_with_vsplit_3.dump b/src/testdir/dumps/Test_tabpanel_with_vsplit_3.dump
new file mode 100644
index 0000000..6e5f8e4
--- /dev/null
+++ b/src/testdir/dumps/Test_tabpanel_with_vsplit_3.dump
@@ -0,0 +1,10 @@
+> +0&#ffffff0@57||+1&&|[+8#0000001#e0e0e08|N|o| |N|a|m|e|]| @9
+|~+0#4040ff13#ffffff0| @56||+1#0000000&|[+2&&|N|o| |N|a|m|e|]| @9
+|~+0#4040ff13&| @56||+1#0000000&| @18
+|~+0#4040ff13&| @56||+1#0000000&| @18
+|~+0#4040ff13&| @56||+1#0000000&| @18
+|~+0#4040ff13&| @56||+1#0000000&| @18
+|~+0#4040ff13&| @56||+1#0000000&| @18
+|~+0#4040ff13&| @56||+1#0000000&| @18
+|~+0#4040ff13&| @56||+1#0000000&| @18
+|:+0&&|s|e|t| |t|a|b|p|a|n|e|l|o|p|t|=|a|l|i|g|n|:|r|i|g|h|t|,|v|e|r|t| @26|0|,|0|-|1| @8|A|l@1| 
diff --git a/src/testdir/dumps/Test_tabpanel_with_vsplit_4.dump b/src/testdir/dumps/Test_tabpanel_with_vsplit_4.dump
new file mode 100644
index 0000000..7978943
--- /dev/null
+++ b/src/testdir/dumps/Test_tabpanel_with_vsplit_4.dump
@@ -0,0 +1,10 @@
+> +0&#ffffff0@28||+1&&| +0&&@27||+1&&|[+8#0000001#e0e0e08|N|o| |N|a|m|e|]| @9
+|~+0#4040ff13#ffffff0| @27||+1#0000000&|~+0#4040ff13&| @26||+1#0000000&|2+2#e000e06&| +2#0000000&|[|N|o| |N|a|m|e|]| @7
+|~+0#4040ff13&| @27||+1#0000000&|~+0#4040ff13&| @26||+1#0000000&| @18
+|~+0#4040ff13&| @27||+1#0000000&|~+0#4040ff13&| @26||+1#0000000&| @18
+|~+0#4040ff13&| @27||+1#0000000&|~+0#4040ff13&| @26||+1#0000000&| @18
+|~+0#4040ff13&| @27||+1#0000000&|~+0#4040ff13&| @26||+1#0000000&| @18
+|~+0#4040ff13&| @27||+1#0000000&|~+0#4040ff13&| @26||+1#0000000&| @18
+|~+0#4040ff13&| @27||+1#0000000&|~+0#4040ff13&| @26||+1#0000000&| @18
+|[+3&&|N|o| |N|a|m|e|]| @5|0|,|0|-|1| @5|A|l@1| |[+1&&|N|o| |N|a|m|e|]| @4|0|,|0|-|1| @5|A|l@1||| @18
+|:+0&&|v|s|p|l|i|t| @70
diff --git a/src/testdir/dumps/Test_tabpanel_with_vsplit_5.dump b/src/testdir/dumps/Test_tabpanel_with_vsplit_5.dump
new file mode 100644
index 0000000..5744d13
--- /dev/null
+++ b/src/testdir/dumps/Test_tabpanel_with_vsplit_5.dump
@@ -0,0 +1,10 @@
+> +0&#ffffff0@19||+1&&| +0&&@17||+1&&| +0&&@17||+1&&|[+8#0000001#e0e0e08|N|o| |N|a|m|e|]| @9
+|~+0#4040ff13#ffffff0| @18||+1#0000000&|~+0#4040ff13&| @16||+1#0000000&|~+0#4040ff13&| @16||+1#0000000&|3+2#e000e06&| +2#0000000&|[|N|o| |N|a|m|e|]| @7
+|~+0#4040ff13&| @18||+1#0000000&|~+0#4040ff13&| @16||+1#0000000&|~+0#4040ff13&| @16||+1#0000000&| @18
+|~+0#4040ff13&| @18||+1#0000000&|~+0#4040ff13&| @16||+1#0000000&|~+0#4040ff13&| @16||+1#0000000&| @18
+|~+0#4040ff13&| @18||+1#0000000&|~+0#4040ff13&| @16||+1#0000000&|~+0#4040ff13&| @16||+1#0000000&| @18
+|~+0#4040ff13&| @18||+1#0000000&|~+0#4040ff13&| @16||+1#0000000&|~+0#4040ff13&| @16||+1#0000000&| @18
+|~+0#4040ff13&| @18||+1#0000000&|~+0#4040ff13&| @16||+1#0000000&|~+0#4040ff13&| @16||+1#0000000&| @18
+|~+0#4040ff13&| @18||+1#0000000&|~+0#4040ff13&| @16||+1#0000000&|~+0#4040ff13&| @16||+1#0000000&| @18
+|<+3&&|N|o| |N|a|m|e|]| |0|,|0|-|1| @1|A|l@1| |<+1&&|o| |N|a|m|e|]| |0|,|0|-|1| |A|l@1| |<|o| |N|a|m|e|]| |0|,|0|-|1| |A|l@1||| @18
+|:+0&&|v|s|p|l|i|t| @70
diff --git a/src/testdir/test_tabpanel.vim b/src/testdir/test_tabpanel.vim
index e0a6a8c..c3288f8 100644
--- a/src/testdir/test_tabpanel.vim
+++ b/src/testdir/test_tabpanel.vim
@@ -10,6 +10,64 @@
   set showtabpanel&
 endfunc
 
+function Test_tabpanel_showtabpanel_eq_1()
+  CheckScreendump
+
+  let lines =<< trim END
+    set showtabpanel=1
+    set noruler
+  END
+  call writefile(lines, 'XTest_tabpanel_stpl_eq_1', 'D')
+
+  let buf = RunVimInTerminal('-S XTest_tabpanel_stpl_eq_1', {'rows': 10, 'cols': 78})
+  call term_sendkeys(buf, "\<C-L>")
+  call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_0', {})
+  call term_sendkeys(buf, ":tabnew\<CR>\<C-L>")
+  call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_1', {})
+  call term_sendkeys(buf, ":tabfirst\<CR>:vsplit\<CR>\<C-L>")
+  call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_2', {})
+  call term_sendkeys(buf, ":tabclose\<CR>\<C-L>")
+  call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_0', {})
+
+  call term_sendkeys(buf, ":set tabpanelopt=align:right\<CR>\<C-L>")
+  call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_0', {})
+  call term_sendkeys(buf, ":tabnew\<CR>\<C-L>")
+  call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_3', {})
+  call term_sendkeys(buf, ":tabfirst\<CR>:vsplit\<CR>\<C-L>")
+  call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_4', {})
+  call term_sendkeys(buf, ":tabclose\<CR>\<C-L>")
+  call VerifyScreenDump(buf, 'Test_tabpanel_stpl_eq_1_0', {})
+  call StopVimInTerminal(buf)
+endfunc
+
+function Test_tabpanel_with_vsplit()
+  CheckScreendump
+
+  let lines =<< trim END
+    set showtabpanel=2
+    set tabpanelopt=columns:20
+    set showtabline=0
+    tabnew
+  END
+  call writefile(lines, 'XTest_tabpanel_with_vsplit', 'D')
+
+  let buf = RunVimInTerminal('-S XTest_tabpanel_with_vsplit', {'rows': 10, 'cols': 78})
+  call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_0', {})
+  call term_sendkeys(buf, ":vsplit\<CR>")
+  call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_1', {})
+  call term_sendkeys(buf, ":vsplit\<CR>")
+  call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_2', {})
+
+  call term_sendkeys(buf, ":only\<CR>")
+  call term_sendkeys(buf, ":set tabpanelopt=align:right,vert\<CR>")
+  call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_3', {})
+  call term_sendkeys(buf, ":vsplit\<CR>")
+  call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_4', {})
+  call term_sendkeys(buf, ":vsplit\<CR>")
+  call VerifyScreenDump(buf, 'Test_tabpanel_with_vsplit_5', {})
+  call StopVimInTerminal(buf)
+endfunc
+
 function Test_tabpanel_mouse()
   let save_showtabline = &showtabline
   let save_mouse = &mouse
@@ -37,7 +95,8 @@
   call feedkeys("\<LeftMouse>", 'xt')
   call test_setmouse(2, 3)
   let pos = getmousepos()
-  call assert_equal(2, pos['winrow'])
+  call assert_equal(0, pos['winid'])
+  call assert_equal(0, pos['winrow'])
   call assert_equal(0, pos['wincol'])
   call assert_equal(2, pos['screenrow'])
   call assert_equal(3, pos['screencol'])
@@ -45,6 +104,7 @@
   call test_setmouse(1, 11)
   call feedkeys("\<LeftMouse>", 'xt')
   let pos = getmousepos()
+  call assert_notequal(0, pos['winid'])
   call assert_equal(1, pos['winrow'])
   call assert_equal(1, pos['wincol'])
   call assert_equal(1, pos['screenrow'])
@@ -56,6 +116,7 @@
   call test_setmouse(10, 11)
   call feedkeys("\<LeftMouse>", 'xt')
   let pos = getmousepos()
+  call assert_notequal(0, pos['winid'])
   call assert_equal(10, pos['winrow'])
   call assert_equal(1, pos['wincol'])
   call assert_equal(10, pos['screenrow'])
@@ -113,37 +174,39 @@
 function Test_tabpanel_drawing_with_popupwin()
   CheckScreendump
 
+  let tcols = 45
   let lines =<< trim END
-    set showtabpanel=2
+    set showtabpanel=0
     set tabpanelopt=columns:20
     set showtabline=0
+    set nowrap
+    set noruler
     tabnew
     setlocal buftype=nofile
-    call setbufline(bufnr(), 1, repeat([repeat('.', &columns - 20)], &lines))
-    highlight TestingForTabPanelPopupwin guibg=#7777ff guifg=#000000
-    for line in [1, &lines]
-      for col in [1, &columns - 20 - 2]
-        call popup_create([
-          \   '@',
-          \ ], {
-          \   'line': line,
-          \   'col': col,
-          \   'border': [],
-          \   'highlight': 'TestingForTabPanelPopupwin',
-          \ })
-      endfor
+    call setbufline(bufnr(), 1, repeat([repeat('.', &columns)], &lines - &ch))
+    for col in [1, &columns - 2]
+      call popup_create(['@'],
+            \ {
+            \   'line': 1,
+            \   'col': col,
+            \   'border': [],
+            \   'highlight': 'ErrorMsg',
+            \ })
     endfor
-    call cursor(4, 10)
+    call cursor(5, 10)
     call popup_atcursor('atcursor', {
-      \   'highlight': 'TestingForTabPanelPopupwin',
+      \   'highlight': 'Question',
       \ })
   END
   call writefile(lines, 'XTest_tabpanel_with_popupwin', 'D')
-
-  let buf = RunVimInTerminal('-S XTest_tabpanel_with_popupwin', {'rows': 10, 'cols': 45})
-
+  let buf = RunVimInTerminal('-S XTest_tabpanel_with_popupwin', {'rows': 10, 'cols': tcols})
   call VerifyScreenDump(buf, 'Test_tabpanel_drawing_with_popupwin_0', {})
-
+  call term_sendkeys(buf, ":set showtabpanel=2\<CR>\<C-L>")
+  call VerifyScreenDump(buf, 'Test_tabpanel_drawing_with_popupwin_1', {})
+  call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>\<C-L>")
+  call VerifyScreenDump(buf, 'Test_tabpanel_drawing_with_popupwin_2', {})
+  call term_sendkeys(buf, ":set showtabpanel=0\<CR>\<C-L>")
+  call VerifyScreenDump(buf, 'Test_tabpanel_drawing_with_popupwin_0', {})
   call StopVimInTerminal(buf)
 endfunc
 
@@ -186,12 +249,20 @@
 
   let buf = RunVimInTerminal('-S XTest_tabpanel_pum', {'rows': 10, 'cols': 45})
 
-  call term_sendkeys(buf, "i\<C-x>\<C-v>")
+  call term_sendkeys(buf, "i\<CR>aa\<CR>aaaa\<CR>aaac\<CR>aaab\<CR>\<Esc>")
+  call term_sendkeys(buf, "ggi\<C-X>\<C-N>")
   call VerifyScreenDump(buf, 'Test_tabpanel_drawing_pum_0', {})
 
-  call term_sendkeys(buf, "\<CR>  ab\<C-x>\<C-v>")
+  call term_sendkeys(buf, "\<Esc>Go  a\<C-X>\<C-P>")
   call VerifyScreenDump(buf, 'Test_tabpanel_drawing_pum_1', {})
 
+  call term_sendkeys(buf, "\<C-U>\<CR>\<Esc>")
+  call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
+  let num = 45 - 20 - 2  " term-win-width - tabpanel-columns - 2
+  call term_sendkeys(buf, num .. "a \<Esc>")
+  call term_sendkeys(buf, "a\<C-X>\<C-N>")
+  call VerifyScreenDump(buf, 'Test_tabpanel_drawing_pum_2', {})
+
   call StopVimInTerminal(buf)
 endfunc
 
@@ -338,59 +409,59 @@
   call StopVimInTerminal(buf)
 endfunc
 
-function Test_tabpanel_dont_vert_is_multibytes_left()
-  CheckScreendump
+"""function Test_tabpanel_dont_vert_is_multibytes_left()
+"""  CheckScreendump
+"""
+"""  let lines =<< trim END
+"""    set showtabpanel=2
+"""    set tabpanelopt=columns:10,vert
+"""    set fillchars=tpl_vert:│
+"""    set showtabline=2
+"""    tabnew
+"""  END
+"""  call writefile(lines, 'XTest_tabpanel_vert_is_multibyte_lefts', 'D')
+"""
+"""  let buf = RunVimInTerminal('-S XTest_tabpanel_vert_is_multibyte_lefts', {'rows': 10, 'cols': 45})
+"""  call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_0', {})
+"""
+"""  call term_sendkeys(buf, ":set tabpanelopt=columns:1,vert\<CR>")
+"""  call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_1', {})
+"""
+"""  call term_sendkeys(buf, ":set tabpanelopt=columns:10,vert\<CR>")
+"""  call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_2', {})
+"""
+"""  call term_sendkeys(buf, ":set tabpanelopt=columns:2,vert\<CR>")
+"""  call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_3', {})
+"""
+"""  call StopVimInTerminal(buf)
+"""endfunc
 
-  let lines =<< trim END
-    set showtabpanel=2
-    set tabpanelopt=columns:10,vert
-    set fillchars=tpl_vert:│
-    set showtabline=2
-    tabnew
-  END
-  call writefile(lines, 'XTest_tabpanel_vert_is_multibyte_lefts', 'D')
-
-  let buf = RunVimInTerminal('-S XTest_tabpanel_vert_is_multibyte_lefts', {'rows': 10, 'cols': 45})
-  call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_0', {})
-
-  call term_sendkeys(buf, ":set tabpanelopt=columns:1,vert\<CR>")
-  call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_1', {})
-
-  call term_sendkeys(buf, ":set tabpanelopt=columns:10,vert\<CR>")
-  call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_2', {})
-
-  call term_sendkeys(buf, ":set tabpanelopt=columns:2,vert\<CR>")
-  call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_left_3', {})
-
-  call StopVimInTerminal(buf)
-endfunc
-
-function Test_tabpanel_dont_vert_is_multibytes_right()
-  CheckScreendump
-
-  let lines =<< trim END
-    set showtabpanel=2
-    set tabpanelopt=align:right,columns:10,vert
-    set fillchars=tpl_vert:│
-    set showtabline=2
-    tabnew
-  END
-  call writefile(lines, 'XTest_tabpanel_vert_is_multibytes_right', 'D')
-
-  let buf = RunVimInTerminal('-S XTest_tabpanel_vert_is_multibytes_right', {'rows': 10, 'cols': 45})
-  call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_0', {})
-
-  call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:1,vert\<CR>")
-  call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_1', {})
-
-  call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:10,vert\<CR>")
-  call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_2', {})
-
-  call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:2,vert\<CR>")
-  call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_3', {})
-
-  call StopVimInTerminal(buf)
-endfunc
+"""function Test_tabpanel_dont_vert_is_multibytes_right()
+"""  CheckScreendump
+"""
+"""  let lines =<< trim END
+"""    set showtabpanel=2
+"""    set tabpanelopt=align:right,columns:10,vert
+"""    set fillchars=tpl_vert:│
+"""    set showtabline=2
+"""    tabnew
+"""  END
+"""  call writefile(lines, 'XTest_tabpanel_vert_is_multibytes_right', 'D')
+"""
+"""  let buf = RunVimInTerminal('-S XTest_tabpanel_vert_is_multibytes_right', {'rows': 10, 'cols': 45})
+"""  call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_0', {})
+"""
+"""  call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:1,vert\<CR>")
+"""  call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_1', {})
+"""
+"""  call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:10,vert\<CR>")
+"""  call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_2', {})
+"""
+"""  call term_sendkeys(buf, ":set tabpanelopt=align:right,columns:2,vert\<CR>")
+"""  call VerifyScreenDump(buf, 'Test_tabpanel_vert_is_multibytes_right_3', {})
+"""
+"""  call StopVimInTerminal(buf)
+"""endfunc
 
 function Test_tabpanel_eval_tabpanel_statusline_tabline()
   CheckScreendump
@@ -406,7 +477,6 @@
     set tabline=%!Expr()
     set tabpanel=%!Expr()
     set tabpanelopt=columns:10,vert
-    set fillchars=tpl_vert:│
     e aaa
     tabnew
     e bbb
@@ -434,7 +504,6 @@
     set tabline=$%=[%f]%=$
     set tabpanel=$%=[%f]%=$
     set tabpanelopt=columns:10,vert
-    set fillchars=tpl_vert:│
     e aaa
     tabnew
     e bbb
@@ -461,6 +530,7 @@
     set showtabpanel=2
     set tabpanel=%!Expr()
     set tabpanelopt=columns:10
+    set noruler
     e aaa
     tabnew
     e bbb
@@ -521,6 +591,42 @@
   call StopVimInTerminal(buf)
 endfunc
 
+function Test_tabpanel_quitall()
+  CheckScreendump
+
+  let lines =<< trim END
+    tabnew
+    set showtabpanel=1
+    set laststatus=2
+    call setline(1, 'aaa')
+    normal gt
+    silent! quitall
+  END
+  call writefile(lines, 'XTest_tabpanel_quitall', 'D')
+
+  let buf = RunVimInTerminal('-S XTest_tabpanel_quitall', {'rows': 10, 'cols': 45})
+  call VerifyScreenDump(buf, 'Test_tabpanel_quitall_0', {})
+
+  call StopVimInTerminal(buf)
+endfunc
+
+function Test_tabpanel_ruler()
+  CheckScreendump
+
+  let lines =<< trim END
+    tabnew
+    set statusline& laststatus=0
+    set rulerformat& ruler
+    set showtabpanel=1
+  END
+  call writefile(lines, 'XTest_tabpanel_ruler', 'D')
+
+  let buf = RunVimInTerminal('-S XTest_tabpanel_ruler', {'rows': 10, 'cols': 45})
+  call VerifyScreenDump(buf, 'Test_tabpanel_ruler_0', {})
+
+  call StopVimInTerminal(buf)
+endfunc
+
 function Test_tabpanel_error()
   set tabpanel=%!NonExistingFunc()
   try
@@ -540,5 +646,4 @@
   set tabpanel&vim
   set showtabpanel&vim
 endfunc
-
 " vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 7bc3a49..df6eb58 100644
--- a/src/version.c
+++ b/src/version.c
@@ -710,6 +710,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1425,
+/**/
     1424,
 /**/
     1423,
@@ -4110,7 +4112,7 @@
 
     // start displaying the message lines after half of the blank lines
     row = blanklines / 2;
-    if ((row >= 2 && COLUMNS_WITHOUT_TPL() >= 50) || colon)
+    if ((row >= 2 && topframe->fr_width >= 50) || colon)
     {
 	for (i = 0; i < (int)ARRAY_LENGTH(lines); ++i)
 	{
@@ -4193,7 +4195,7 @@
 	}
 	col += (int)STRLEN(vers);
     }
-    col = (COLUMNS_WITHOUT_TPL() - col) / 2;
+    col = (topframe->fr_width - col) / 2;
     if (col < 0)
 	col = 0;
 
@@ -4212,14 +4214,14 @@
 	    else
 		clen += byte2cells(p[l]);
 	}
-	screen_puts_len(p, l, row, col + TPL_LCOL(NULL),
+	screen_puts_len(p, l, row, col + firstwin->w_wincol,
 		*p == '<' ? HL_ATTR(HLF_8) : attr);
 	col += clen;
     }
 
     // Add the version number to the version line.
     if (add_version)
-	screen_puts(vers, row, col + TPL_LCOL(NULL), 0);
+	screen_puts(vers, row, col + firstwin->w_wincol, 0);
 }
 
 /*
diff --git a/src/vim.h b/src/vim.h
index 26adc18..58ebad3 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -2089,7 +2089,6 @@
 #define IN_STATUS_LINE		2	// on status or command line
 #define IN_SEP_LINE		4	// on vertical separator line
 #define IN_OTHER_WIN		8	// in other window but can't go there
-#define IN_TABPANEL		16	// in tabpanel
 #define CURSOR_MOVED		0x100
 #define MOUSE_FOLD_CLOSE	0x200	// clicked on '-' in fold column
 #define MOUSE_FOLD_OPEN		0x400	// clicked on '+' in fold column
diff --git a/src/window.c b/src/window.c
index 8543758..f3b23e8 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1385,8 +1385,8 @@
 	// width and column of new window is same as current window
 	if (flags & (WSP_TOP | WSP_BOT))
 	{
-	    wp->w_wincol = 0;
-	    win_new_width(wp, COLUMNS_WITHOUT_TPL());
+	    wp->w_wincol = firstwin->w_wincol;
+	    win_new_width(wp, topframe->fr_width);
 	    wp->w_vsep_width = 0;
 	}
 	else
@@ -2085,8 +2085,8 @@
     if (dir == 0)
 	dir = *p_ead;
     win_equal_rec(next_curwin == NULL ? curwin : next_curwin, current,
-		      topframe, dir, 0, tabline_height(),
-		      (int)COLUMNS_WITHOUT_TPL(), topframe->fr_height);
+		      topframe, dir, firstwin->w_wincol, tabline_height(),
+		      topframe->fr_width, topframe->fr_height);
     if (!is_aucmd_win(next_curwin))
 	win_fix_scroll(TRUE);
 }
@@ -2144,7 +2144,7 @@
 	    // frame.
 	    n = frame_minwidth(topfr, NOWIN);
 	    // add one for the rightmost window, it doesn't have a separator
-	    if (col + width == COLUMNS_WITHOUT_TPL())
+	    if (col + width >= firstwin->w_wincol + topframe->fr_width)
 		extra_sep = 1;
 	    else
 		extra_sep = 0;
@@ -2619,14 +2619,14 @@
     // Since goto_tabpage_tp above did not trigger *Enter autocommands, do
     // that now.
     apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf);
-    apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf);
-    apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf);
-    if (old_curbuf != curbuf)
-	apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf);
 #if defined(FEAT_TABPANEL)
     if (p_stpl > 0)
 	shell_new_columns();
 #endif
+    apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf);
+    apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf);
+    if (old_curbuf != curbuf)
+	apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf);
     return TRUE;
 }
 
@@ -4596,8 +4596,7 @@
     firstwin->w_height = ROWS_AVAIL;
     firstwin->w_prev_height = ROWS_AVAIL;
     topframe->fr_height = ROWS_AVAIL;
-    firstwin->w_width = COLUMNS_WITHOUT_TPL();
-    topframe->fr_width = COLUMNS_WITHOUT_TPL();
+    firstwin->w_width = topframe->fr_width;
 }
 
 /*
@@ -4696,6 +4695,9 @@
     tabpage_T	*prev_tp = curtab;
     tabpage_T	*newtp;
     int		n;
+#if defined(FEAT_TABPANEL)
+    int prev_columns = COLUMNS_WITHOUT_TPL();
+#endif
 
     if (cmdwin_type != 0)
     {
@@ -4763,7 +4765,22 @@
 #ifdef FEAT_JOB_CHANNEL
 	entering_window(curwin);
 #endif
+#if defined(FEAT_TABPANEL)
+	if (prev_columns != COLUMNS_WITHOUT_TPL())
+	{
+	    tabpage_T *save_curtab = curtab;
 
+	    unuse_tabpage(curtab);
+	    use_tabpage(prev_tp);
+	    shell_new_rows();
+	    shell_new_columns();
+
+	    unuse_tabpage(curtab);
+	    use_tabpage(save_curtab);
+	    shell_new_rows();
+	    shell_new_columns();
+	}
+#endif
 	redraw_all_later(UPD_NOT_VALID);
 	apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf);
 	apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf);
@@ -4971,7 +4988,7 @@
     tp->tp_lastwin = lastwin;
     tp->tp_old_Rows = Rows;
     if (tp->tp_old_Columns != -1)
-	tp->tp_old_Columns = COLUMNS_WITHOUT_TPL();
+	tp->tp_old_Columns = topframe->fr_width;
     firstwin = NULL;
     lastwin = NULL;
     return OK;
@@ -5034,12 +5051,12 @@
 #endif
 		))
 	shell_new_rows();
-    if (curtab->tp_old_Columns != COLUMNS_WITHOUT_TPL())
+    if (curtab->tp_old_Columns != topframe->fr_width)
     {
 	if (starting == 0)
 	{
 	    shell_new_columns();	// update window widths
-	    curtab->tp_old_Columns = COLUMNS_WITHOUT_TPL();
+	    curtab->tp_old_Columns = topframe->fr_width;
 	}
 	else
 	    curtab->tp_old_Columns = -1;  // update window widths later
@@ -5805,7 +5822,7 @@
      */
     if (!hidden)
 	win_append(after, new_wp);
-    new_wp->w_wincol = 0;
+    new_wp->w_wincol = TPL_LCOL(NULL);
     new_wp->w_width = COLUMNS_WITHOUT_TPL();
 
     // position the display and the cursor at the top of the file.
@@ -6164,8 +6181,8 @@
     if (h < frame_minheight(topframe, NULL))
 	h = frame_minheight(topframe, NULL);
 
-    // First try setting the heights of windows with 'winfixheight'.  If
-    // that doesn't result in the right height, forget about that option.
+    // First try setting the heights of windows with 'winfixheight'.  If that
+    // doesn't result in the right height, forget about that option.
     frame_new_height(topframe, h, FALSE, TRUE, FALSE);
     if (!frame_check_height(topframe, h))
 	frame_new_height(topframe, h, FALSE, FALSE, FALSE);
@@ -6177,6 +6194,10 @@
     if (!skip_win_fix_scroll)
 	win_fix_scroll(TRUE);
 
+    redraw_tabline = TRUE;
+#if defined(FEAT_TABPANEL)
+    redraw_tabpanel = TRUE;
+#endif
 #if 0
     // Disabled: don't want making the screen smaller make a window larger.
     if (p_ea)
@@ -6193,13 +6214,23 @@
     if (firstwin == NULL)	// not initialized yet
 	return;
 
+    int w = COLUMNS_WITHOUT_TPL();
+
     // First try setting the widths of windows with 'winfixwidth'.  If that
     // doesn't result in the right width, forget about that option.
-    frame_new_width(topframe, COLUMNS_WITHOUT_TPL(), FALSE, TRUE);
-    if (!frame_check_width(topframe, COLUMNS_WITHOUT_TPL()))
-	frame_new_width(topframe, COLUMNS_WITHOUT_TPL(), FALSE, FALSE);
+    frame_new_width(topframe, w, FALSE, TRUE);
+    if (!frame_check_width(topframe, w))
+	frame_new_width(topframe, w, FALSE, FALSE);
 
     (void)win_comp_pos();		// recompute w_winrow and w_wincol
+
+    if (!skip_win_fix_scroll)
+	win_fix_scroll(TRUE);
+
+    redraw_tabline = TRUE;
+#if defined(FEAT_TABPANEL)
+    redraw_tabpanel = TRUE;
+#endif
 #if 0
     // Disabled: don't want making the screen smaller make a window larger.
     if (p_ea)
@@ -6269,7 +6300,7 @@
 win_comp_pos(void)
 {
     int		row = tabline_height();
-    int		col = 0;
+    int		col = TPL_LCOL(NULL);
 
     frame_comp_pos(topframe, &row, &col);
     return row;
@@ -6439,7 +6470,7 @@
 		if (frp != curfrp)
 		    room -= frame_minheight(frp, NULL);
 	    }
-	    if (curfrp->fr_width != COLUMNS_WITHOUT_TPL())
+	    if (curfrp->fr_width != topframe->fr_width)
 		room_cmdline = 0;
 	    else
 	    {
@@ -6452,7 +6483,7 @@
 
 	    if (height <= room + room_cmdline)
 		break;
-	    if (run == 2 || curfrp->fr_width == COLUMNS_WITHOUT_TPL())
+	    if (run == 2 || curfrp->fr_width == topframe->fr_width)
 	    {
 		height = room + room_cmdline;
 		break;
@@ -6757,7 +6788,7 @@
     // loop until there is a 'winminheight' that is possible
     while (p_wmw > 0)
     {
-	room = Columns;
+	room = topframe->fr_width;
 	needed = frame_minwidth(topframe, NULL);
 	if (room >= needed)
 	    break;
@@ -7347,7 +7378,7 @@
 
     // Find bottom frame with width of screen.
     frame_T *frp = lastwin->w_frame;
-    while (frp->fr_width != COLUMNS_WITHOUT_TPL() && frp->fr_parent != NULL)
+    while (frp->fr_width != topframe->fr_width && frp->fr_parent != NULL)
 	frp = frp->fr_parent;
 
     // Avoid changing the height of a window with 'winfixheight' set.
@@ -7667,7 +7698,7 @@
 	    if (wp->w_save_cursor.w_topline_corr == wp->w_topline
 				  && wp->w_save_cursor.w_topline_save != 0)
 		wp->w_topline = wp->w_save_cursor.w_topline_save;
-	   if (wp->w_save_cursor.w_topline_save > wp->w_buffer->b_ml.ml_line_count)
+	    if (wp->w_save_cursor.w_topline_save > wp->w_buffer->b_ml.ml_line_count)
 		wp->w_valid &= ~VALID_TOPLINE;
 	}
 }