patch 9.1.1394: tabpanel not correctly redrawn on tabonly

Problem:  tabpanel not correctly redrawn on tabonly
          (Maxim Kim, after v9.1.1391)
Solution: force redraw of the tabpanel, tweak style
          (Hirohito Higashi)

fixes: #17322
closes: #17330

Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/proto/tabpanel.pro b/src/proto/tabpanel.pro
index 3cbaa2f..34c3e52 100644
--- a/src/proto/tabpanel.pro
+++ b/src/proto/tabpanel.pro
@@ -1,6 +1,6 @@
 /* tabpanel.c */
 int tabpanel_width(void);
-int tabpanel_leftcol(win_T	*wp);
+int tabpanel_leftcol(win_T *wp);
 int tabpanelopt_changed(void);
 void draw_tabpanel(void);
 int get_tabpagenr_on_tabpanel(void);
diff --git a/src/tabpanel.c b/src/tabpanel.c
index f4bed4b..0472e6b 100644
--- a/src/tabpanel.c
+++ b/src/tabpanel.c
@@ -16,7 +16,7 @@
 #if defined(FEAT_TABPANEL) || defined(PROTO)
 
 static void do_by_tplmode(int tplmode, int col_start, int col_end,
-	int* pcurtab_row, int* ptabpagenr);
+	int *pcurtab_row, int *ptabpagenr);
 
 // set pcurtab_row. don't redraw tabpanel.
 #define TPLMODE_GET_CURTAB_ROW	0
@@ -29,10 +29,6 @@
 
 #define VERT_LEN		1
 
-// tpl_vert's values
-#define VERT_OFF		0
-#define VERT_ON			1
-
 // tpl_align's values
 #define ALIGN_LEFT		0
 #define ALIGN_RIGHT		1
@@ -41,7 +37,7 @@
 static int opt_scope = OPT_LOCAL;
 static int tpl_align = ALIGN_LEFT;
 static int tpl_columns = 20;
-static int tpl_vert = VERT_OFF;
+static int tpl_is_vert = FALSE;
 
 typedef struct {
     win_T   *wp;
@@ -62,7 +58,7 @@
     char_u	*p;
     int		new_align = ALIGN_LEFT;
     int		new_columns = 20;
-    int		new_vert = VERT_OFF;
+    int		new_is_vert = FALSE;
 
     p = p_tplo;
     while (*p != NUL)
@@ -85,7 +81,7 @@
 	else if (STRNCMP(p, "vert", 4) == 0)
 	{
 	    p += 4;
-	    new_vert = VERT_ON;
+	    new_is_vert = TRUE;
 	}
 
 	if (*p != ',' && *p != NUL)
@@ -96,7 +92,7 @@
 
     tpl_align = new_align;
     tpl_columns = new_columns;
-    tpl_vert = new_vert;
+    tpl_is_vert = new_is_vert;
 
     return OK;
 }
@@ -130,9 +126,7 @@
     int
 tabpanel_leftcol(win_T *wp)
 {
-    if (cmdline_pum_active())
-	return 0;
-    else if (wp != NULL && WIN_IS_POPUP(wp))
+    if (cmdline_pum_active() || (wp != NULL && WIN_IS_POPUP(wp)))
 	return 0;
     else
 	return tpl_align == ALIGN_RIGHT ? 0 : tabpanel_width();
@@ -156,7 +150,7 @@
 int		vsrow = 0;
     int		is_right = tpl_align == ALIGN_RIGHT;
 
-    if (0 == maxwidth)
+    if (maxwidth == 0)
 	return;
 
 #ifndef MSWIN
@@ -168,8 +162,7 @@
 	else
 	    off = LineOffset[row];
 
-	vim_memset(ScreenLines + off, ' ',
-		(size_t)maxwidth * sizeof(schar_T));
+	vim_memset(ScreenLines + off, ' ', (size_t)maxwidth * sizeof(schar_T));
 	if (enc_utf8)
 	    vim_memset(ScreenLinesUC + off, -1,
 		(size_t)maxwidth * sizeof(u8char_T));
@@ -179,7 +172,7 @@
     // Reset got_int to avoid build_stl_str_hl() isn't evaluted.
     got_int = FALSE;
 
-    if (tpl_vert == VERT_ON)
+    if (tpl_is_vert)
     {
 	if (is_right)
 	{
@@ -237,7 +230,7 @@
     int		curtab_row = 0;
     int		tabpagenr = 0;
 
-    if (0 == maxwidth)
+    if (maxwidth == 0)
 	return -1;
 
     do_by_tplmode(TPLMODE_GET_CURTAB_ROW, 0, maxwidth, &curtab_row, NULL);
@@ -260,7 +253,7 @@
 	int	attr)
 {
     int is_right = tpl_align == ALIGN_RIGHT;
-    if (TPLMODE_REDRAW == tplmode)
+    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,
@@ -282,19 +275,19 @@
     int		chlen;
     int		chcells;
     char_u	buf[IOSIZE];
-    char_u*	temp;
+    char_u	*temp;
 
     for (j = 0; j < len;)
     {
-	if ((TPLMODE_GET_CURTAB_ROW != tplmode)
-		&& (pargs->maxrow <= (*pargs->prow - pargs->offsetrow)))
+	if (tplmode != TPLMODE_GET_CURTAB_ROW
+		&& pargs->maxrow <= *pargs->prow - pargs->offsetrow)
 	    break;
 
-	if ((p[j] == '\n') || (p[j] == '\r'))
+	if (p[j] == '\n' || p[j] == '\r')
 	{
 	    // fill the tailing area of current row.
-	    if (0 <= (*pargs->prow - pargs->offsetrow)
-		    && (*pargs->prow - pargs->offsetrow) < pargs->maxrow)
+	    if (*pargs->prow - pargs->offsetrow >= 0
+		    && *pargs->prow - pargs->offsetrow < pargs->maxrow)
 		screen_fill_tailing_area(tplmode,
 			*pargs->prow - pargs->offsetrow,
 			*pargs->prow - pargs->offsetrow + 1,
@@ -331,8 +324,8 @@
 	    if (pargs->col_end < (*pargs->pcol) + chcells)
 	    {
 		// fill the tailing area of current row.
-		if (0 <= (*pargs->prow - pargs->offsetrow)
-			&& (*pargs->prow - pargs->offsetrow) < pargs->maxrow)
+		if (*pargs->prow - pargs->offsetrow >= 0
+			&& *pargs->prow - pargs->offsetrow < pargs->maxrow)
 		    screen_fill_tailing_area(tplmode,
 			    *pargs->prow - pargs->offsetrow,
 			    *pargs->prow - pargs->offsetrow + 1,
@@ -343,17 +336,17 @@
 		    break;
 	    }
 
-	    if ((*pargs->pcol) + chcells <= pargs->col_end)
+	    if (*pargs->pcol + chcells <= pargs->col_end)
 	    {
 		int off = (tpl_align == ALIGN_RIGHT)
 			? COLUMNS_WITHOUT_TPL()
 			: 0;
-		if ((TPLMODE_REDRAW == tplmode)
-			&& (0 <= (*pargs->prow - pargs->offsetrow)
-			&& (*pargs->prow - pargs->offsetrow) < pargs->maxrow))
+		if (TPLMODE_REDRAW == tplmode
+			&& (*pargs->prow - pargs->offsetrow >= 0
+			&& *pargs->prow - pargs->offsetrow < pargs->maxrow))
 		    screen_puts(buf, *pargs->prow - pargs->offsetrow,
 			    *pargs->pcol + off, attr);
-		(*pargs->pcol) += chcells;
+		*pargs->pcol += chcells;
 	    }
 	}
     }
@@ -376,9 +369,9 @@
 	if (bufIsChanged(pargs->wp->w_buffer))
 	    modified = TRUE;
 
-    if (modified || 1 < wincount)
+    if (modified || wincount > 1)
     {
-	if (1 < wincount)
+	if (wincount > 1)
 	{
 	    vim_snprintf((char *)NameBuff, MAXPATHL, "%d", wincount);
 	    len = (int)STRLEN(NameBuff);
@@ -406,8 +399,8 @@
     screen_puts_len_for_tabpanel(tplmode, NameBuff, len, pargs->attr, pargs);
 
     // fill the tailing area of current row.
-    if (0 <= (*pargs->prow - pargs->offsetrow)
-	    && (*pargs->prow - pargs->offsetrow) < pargs->maxrow)
+    if (*pargs->prow - pargs->offsetrow >= 0
+	    && *pargs->prow - pargs->offsetrow < pargs->maxrow)
 	screen_fill_tailing_area(tplmode, *pargs->prow - pargs->offsetrow,
 		*pargs->prow - pargs->offsetrow + 1,
 		*pargs->pcol, pargs->col_end, pargs->attr);
@@ -473,8 +466,8 @@
     screen_puts_len_for_tabpanel(tplmode, p, (int)STRLEN(p), curattr, pargs);
 
     // fill the tailing area of current row.
-    if (0 <= (*pargs->prow - pargs->offsetrow)
-	    && (*pargs->prow - pargs->offsetrow) < pargs->maxrow)
+    if (*pargs->prow - pargs->offsetrow >= 0
+	    && *pargs->prow - pargs->offsetrow < pargs->maxrow)
 	screen_fill_tailing_area(tplmode, *pargs->prow - pargs->offsetrow,
 		*pargs->prow - pargs->offsetrow + 1, *pargs->pcol,
 		pargs->col_end, curattr);
@@ -501,7 +494,7 @@
 
     // When the format starts with "%!" then evaluate it as an expression and
     // use the result as the actual format string.
-    if (1 < len && usefmt[0] == '%' && usefmt[1] == '!')
+    if (len > 1 && usefmt[0] == '%' && usefmt[1] == '!')
     {
 	typval_T	tv;
 	char_u		*p = NULL;
@@ -539,24 +532,23 @@
     int		row = 0;
     tabpage_T	*tp = NULL;
     typval_T	v;
-    tabpanel_T    args;
+    tabpanel_T	args;
 
     args.maxrow = cmdline_row;
     args.offsetrow = 0;
     args.col_start = col_start;
     args.col_end = col_end;
 
-    if (TPLMODE_GET_CURTAB_ROW != tplmode)
-	if (0 < args.maxrow)
-	    while (args.offsetrow + args.maxrow <= *pcurtab_row)
-		args.offsetrow += args.maxrow;
+    if (tplmode != TPLMODE_GET_CURTAB_ROW && args.maxrow > 0)
+	while (args.offsetrow + args.maxrow <= *pcurtab_row)
+	    args.offsetrow += args.maxrow;
 
     tp = first_tabpage;
 
     for (row = 0; tp != NULL; row++)
     {
-	if ((TPLMODE_GET_CURTAB_ROW != tplmode)
-		&& (args.maxrow <= (row - args.offsetrow)))
+	if (tplmode != TPLMODE_GET_CURTAB_ROW
+		&& args.maxrow <= row - args.offsetrow)
 	    break;
 
 	col = col_start;
@@ -568,7 +560,7 @@
 	if (tp->tp_topframe == topframe)
 	{
 	    args.attr = attr_tpls;
-	    if (TPLMODE_GET_CURTAB_ROW == tplmode)
+	    if (tplmode == TPLMODE_GET_CURTAB_ROW)
 	    {
 		*pcurtab_row = row;
 		break;
@@ -588,20 +580,20 @@
 	    args.wp = tp->tp_firstwin;
 	}
 
-	char_u*	usefmt = starts_with_percent_and_bang(&args);
+	char_u *usefmt = starts_with_percent_and_bang(&args);
 	if (usefmt != NULL)
 	{
 	    char_u	buf[IOSIZE];
 	    char_u	*p = usefmt;
 	    size_t	i = 0;
 
-	    while (p[i] != '\0')
+	    while (p[i] != NUL)
 	    {
-		while ((p[i] == '\n') || (p[i] == '\r'))
+		while (p[i] == '\n' || p[i] == '\r')
 		{
 		    // fill the tailing area of current row.
-		    if (0 <= (row - args.offsetrow)
-			    && (row - args.offsetrow) < args.maxrow)
+		    if (row - args.offsetrow >= 0
+			    && row - args.offsetrow < args.maxrow)
 			screen_fill_tailing_area(tplmode,
 				row - args.offsetrow,
 				row - args.offsetrow + 1,
@@ -611,15 +603,14 @@
 		    p++;
 		}
 
-		while ((p[i] != '\n') && (p[i] != '\r')
-			&& (p[i] != '\0'))
+		while (p[i] != '\n' && p[i] != '\r' && (p[i] != NUL))
 		{
 		    if (i + 1 >= sizeof(buf))
 			break;
 		    buf[i] = p[i];
 		    i++;
 		}
-		buf[i] = '\0';
+		buf[i] = NUL;
 
 		args.user_defined = buf;
 		args.prow = &row;
@@ -644,7 +635,7 @@
 
 	tp = tp->tp_next;
 
-	if ((TPLMODE_GET_TABPAGENR == tplmode)
+	if ((tplmode == TPLMODE_GET_TABPAGENR)
 		&& (mouse_row <= (row - args.offsetrow)))
 	{
 	    *ptabpagenr = v.vval.v_number;
diff --git a/src/testdir/dumps/Test_tabpanel_only_0.dump b/src/testdir/dumps/Test_tabpanel_only_0.dump
new file mode 100644
index 0000000..3d54f94
--- /dev/null
+++ b/src/testdir/dumps/Test_tabpanel_only_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|2+2#e000e06&|++2#0000000&| |[|N|o| |N|a|m|e|]| | +1&&@31|X+8#0000001#e0e0e08
+|2+2#e000e06#ffffff0|++2#0000000&| |[|N|o| |N|a|m|e|]| @7|a+0&&|s|d|f| @25||+1&&|a+0&&|s|d|f| @22
+| +1&&@19|a+0&&|s|d|f| @25||+1&&|a+0&&|s|d|f| @22
+| +1&&@19|a+0&&|s|d|f| @25||+1&&|a+0&&|s|d|f| @22
+| +1&&@19|a+0&&|s|d|f| @25||+1&&|a+0&&|s|d|f| @22
+| +1&&@19|a+0&&|s|d|f| @25||+1&&|a+0&&|s|d|f| @22
+| +1&&@19|a+0&&|s|d|f| @25||+1&&|a+0&&|s|d|f| @22
+| +1&&@19|a+0&&|s|d>f| @25||+1&&|a+0&&|s|d|f| @22
+| +1&&@19|[+3&&|N|o| |N|a|m|e|]| |[|+|]| @1|1|0|1|,|4| @6|B|o|t| |<+1&&|N|o| |N|a|m|e|]| |[|+|]| |1|0|1|,|4| @4|B|o|t
+| +0&&@77
diff --git a/src/testdir/dumps/Test_tabpanel_only_1.dump b/src/testdir/dumps/Test_tabpanel_only_1.dump
new file mode 100644
index 0000000..94879c0
--- /dev/null
+++ b/src/testdir/dumps/Test_tabpanel_only_1.dump
@@ -0,0 +1,10 @@
+|a+0&#ffffff0|s|d|f| @25||+1&&|a+0&&|s|d|f| @42
+|a|s|d|f| @25||+1&&|a+0&&|s|d|f| @42
+|a|s|d|f| @25||+1&&|a+0&&|s|d|f| @42
+|a|s|d|f| @25||+1&&|a+0&&|s|d|f| @42
+|a|s|d|f| @25||+1&&|a+0&&|s|d|f| @42
+|a|s|d|f| @25||+1&&|a+0&&|s|d|f| @42
+|a|s|d|f| @25||+1&&|a+0&&|s|d|f| @42
+|a|s|d>f| @25||+1&&|a+0&&|s|d|f| @42
+|[+3&&|N|o| |N|a|m|e|]| |[|+|]| @1|1|0|1|,|4| @6|B|o|t| |[+1&&|N|o| |N|a|m|e|]| |[|+|]| @15|1|0|1|,|4| @9|B|o|t
+|:+0&&|t|a|b|o|n|l|y| @69
diff --git a/src/testdir/test_tabpanel.vim b/src/testdir/test_tabpanel.vim
index 630226f..cb3c42f 100644
--- a/src/testdir/test_tabpanel.vim
+++ b/src/testdir/test_tabpanel.vim
@@ -4,13 +4,13 @@
 source screendump.vim
 CheckFeature tabpanel
 
-function! s:reset()
+function s:reset()
   set tabpanel&
   set tabpanelopt&
   set showtabpanel&
 endfunc
 
-function! Test_tabpanel_mouse()
+function Test_tabpanel_mouse()
   let save_showtabline = &showtabline
   let save_mouse = &mouse
   set showtabline=0 mouse=a
@@ -67,11 +67,11 @@
   let &showtabline = save_showtabline
 endfunc
 
-function! Test_tabpanel_drawing()
+function Test_tabpanel_drawing()
   CheckScreendump
 
   let lines =<< trim END
-    function! MyTabPanel()
+    function MyTabPanel()
       let n = g:actual_curtabpage
       let hi = n == tabpagenr() ? 'TabLineSel' : 'TabLine'
       let label = printf("\n%%#%sTabNumber#%d:%%#%s#", hi, n, hi)
@@ -110,7 +110,7 @@
   call StopVimInTerminal(buf)
 endfunc
 
-function! Test_tabpanel_drawing_with_popupwin()
+function Test_tabpanel_drawing_with_popupwin()
   CheckScreendump
 
   let lines =<< trim END
@@ -147,7 +147,7 @@
   call StopVimInTerminal(buf)
 endfunc
 
-function! Test_tabpanel_drawing_fill_tailing()
+function Test_tabpanel_drawing_fill_tailing()
   CheckScreendump
 
   let lines =<< trim END
@@ -171,7 +171,7 @@
   call StopVimInTerminal(buf)
 endfunc
 
-function! Test_tabpanel_drawing_pum()
+function Test_tabpanel_drawing_pum()
   CheckScreendump
 
   let lines =<< trim END
@@ -189,13 +189,13 @@
   call term_sendkeys(buf, "i\<C-x>\<C-v>")
   call VerifyScreenDump(buf, 'Test_tabpanel_drawing_pum_0', {})
 
-  call term_sendkeys(buf, "\<cr>  ab\<C-x>\<C-v>")
+  call term_sendkeys(buf, "\<CR>  ab\<C-x>\<C-v>")
   call VerifyScreenDump(buf, 'Test_tabpanel_drawing_pum_1', {})
 
   call StopVimInTerminal(buf)
 endfunc
 
-function! Test_tabpanel_scrolling()
+function Test_tabpanel_scrolling()
   CheckScreendump
 
   let lines =<< trim END
@@ -216,7 +216,7 @@
   let buf = RunVimInTerminal('-S XTest_tabpanel_scrolling', {'rows': 10, 'cols': 45})
   let n = 0
   for c in ['H', 'J', 'K', 'L']
-    call term_sendkeys(buf, ":wincmd " .. c ..  "\<cr>")
+    call term_sendkeys(buf, ":wincmd " .. c ..  "\<CR>")
     call term_sendkeys(buf, "\<C-d>\<C-d>")
     call term_sendkeys(buf, "r@")
     call VerifyScreenDump(buf, 'Test_tabpanel_drawing_scrolling_' .. n, {})
@@ -226,7 +226,7 @@
   call StopVimInTerminal(buf)
 endfunc
 
-function! Test_tabpanel_many_tabpages()
+function Test_tabpanel_many_tabpages()
   CheckScreendump
 
   let lines =<< trim END
@@ -243,14 +243,14 @@
     call term_sendkeys(buf, "gt")
     call VerifyScreenDump(buf, 'Test_tabpanel_many_tabpages_' .. n, {})
   endfor
-  call term_sendkeys(buf, ":tabnext +10\<cr>")
-  call term_sendkeys(buf, ":tabnext -3\<cr>")
+  call term_sendkeys(buf, ":tabnext +10\<CR>")
+  call term_sendkeys(buf, ":tabnext -3\<CR>")
   call VerifyScreenDump(buf, 'Test_tabpanel_many_tabpages_4', {})
 
   call StopVimInTerminal(buf)
 endfunc
 
-function! Test_tabpanel_visual()
+function Test_tabpanel_visual()
   CheckScreendump
 
   let lines =<< trim END
@@ -265,16 +265,16 @@
   let buf = RunVimInTerminal('-S XTest_tabpanel_visual', {'rows': 10, 'cols': 45})
   call term_sendkeys(buf, "v2w")
   call VerifyScreenDump(buf, 'Test_tabpanel_visual_0', {})
-  call term_sendkeys(buf, "\<esc>0jw")
+  call term_sendkeys(buf, "\<Esc>0jw")
   call term_sendkeys(buf, "v2wge")
   call VerifyScreenDump(buf, 'Test_tabpanel_visual_1', {})
-  call term_sendkeys(buf, "y:echo @\"\<cr>")
+  call term_sendkeys(buf, "y:echo @\"\<CR>")
   call VerifyScreenDump(buf, 'Test_tabpanel_visual_2', {})
 
   call StopVimInTerminal(buf)
 endfunc
 
-function! Test_tabpanel_commandline()
+function Test_tabpanel_commandline()
   CheckScreendump
 
   let lines =<< trim END
@@ -286,18 +286,18 @@
   call writefile(lines, 'XTest_tabpanel_commandline', 'D')
 
   let buf = RunVimInTerminal('-S XTest_tabpanel_commandline', {'rows': 10, 'cols': 45})
-  call term_sendkeys(buf, ":ab\<tab>")
+  call term_sendkeys(buf, ":ab\<Tab>")
   call VerifyScreenDump(buf, 'Test_tabpanel_commandline_0', {})
 
-  call term_sendkeys(buf, "\<esc>")
-  call term_sendkeys(buf, ":set wildoptions=pum\<cr>")
-  call term_sendkeys(buf, ":ab\<tab>")
+  call term_sendkeys(buf, "\<Esc>")
+  call term_sendkeys(buf, ":set wildoptions=pum\<CR>")
+  call term_sendkeys(buf, ":ab\<Tab>")
   call VerifyScreenDump(buf, 'Test_tabpanel_commandline_1', {})
 
   call StopVimInTerminal(buf)
 endfunc
 
-function! Test_tabpanel_tabline_and_tabpanel()
+function Test_tabpanel_tabline_and_tabpanel()
   CheckScreendump
 
   let lines =<< trim END
@@ -319,7 +319,7 @@
   call StopVimInTerminal(buf)
 endfunc
 
-function! Test_tabpanel_dont_overflow_into_tabpanel()
+function Test_tabpanel_dont_overflow_into_tabpanel()
   CheckScreendump
 
   let lines =<< trim END
@@ -338,7 +338,7 @@
   call StopVimInTerminal(buf)
 endfunc
 
-function! Test_tabpanel_dont_vert_is_multibytes_left()
+function Test_tabpanel_dont_vert_is_multibytes_left()
   CheckScreendump
 
   let lines =<< trim END
@@ -353,19 +353,19 @@
   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 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 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 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()
+function Test_tabpanel_dont_vert_is_multibytes_right()
   CheckScreendump
 
   let lines =<< trim END
@@ -380,23 +380,23 @@
   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 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 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 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()
+function Test_tabpanel_eval_tabpanel_statusline_tabline()
   CheckScreendump
 
   let lines =<< trim END
-    function! Expr()
+    function Expr()
       return "$%=[%f]%=$"
     endfunction
     set laststatus=2
@@ -417,13 +417,13 @@
 
   let buf = RunVimInTerminal('-S XTest_tabpanel_eval_tabpanel_statusline_tabline', {'rows': 10, 'cols': 45})
   call VerifyScreenDump(buf, 'Test_tabpanel_eval_tabpanel_statusline_tabline_0', {})
-  call term_sendkeys(buf, ":set tabpanelopt+=align:right\<cr>")
+  call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
   call VerifyScreenDump(buf, 'Test_tabpanel_eval_tabpanel_statusline_tabline_1', {})
 
   call StopVimInTerminal(buf)
 endfunc
 
-function! Test_tabpanel_noeval_tabpanel_statusline_tabline()
+function Test_tabpanel_noeval_tabpanel_statusline_tabline()
   CheckScreendump
 
   let lines =<< trim END
@@ -445,17 +445,17 @@
 
   let buf = RunVimInTerminal('-S XTest_tabpanel_noeval_tabpanel_statusline_tabline', {'rows': 10, 'cols': 45})
   call VerifyScreenDump(buf, 'Test_tabpanel_noeval_tabpanel_statusline_tabline_0', {})
-  call term_sendkeys(buf, ":set tabpanelopt+=align:right\<cr>")
+  call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
   call VerifyScreenDump(buf, 'Test_tabpanel_noeval_tabpanel_statusline_tabline_1', {})
 
   call StopVimInTerminal(buf)
 endfunc
 
-function! Test_tabpanel_eval_tabpanel_with_linebreaks()
+function Test_tabpanel_eval_tabpanel_with_linebreaks()
   CheckScreendump
 
   let lines =<< trim END
-    function! Expr()
+    function Expr()
       return "top\n$%=[%f]%=$\nbottom"
     endfunction
     set showtabpanel=2
@@ -471,10 +471,29 @@
 
   let buf = RunVimInTerminal('-S XTest_tabpanel_eval_tabpanel_with_linebreaks', {'rows': 10, 'cols': 45})
   call VerifyScreenDump(buf, 'Test_tabpanel_eval_tabpanel_with_linebreaks_0', {})
-  call term_sendkeys(buf, ":set tabpanelopt+=align:right\<cr>")
+  call term_sendkeys(buf, ":set tabpanelopt+=align:right\<CR>")
   call VerifyScreenDump(buf, 'Test_tabpanel_eval_tabpanel_with_linebreaks_1', {})
 
   call StopVimInTerminal(buf)
 endfunc
 
+function Test_tabpanel_tabonly()
+  CheckScreendump
+
+  let lines =<< trim END
+    tabnew
+    set showtabpanel=1
+    norm 100oasdf
+    vsplit
+  END
+  call writefile(lines, 'XTest_tabpanel_tabonly', 'D')
+
+  let buf = RunVimInTerminal('-S XTest_tabpanel_tabonly', {'rows': 10, 'cols': 80})
+  call VerifyScreenDump(buf, 'Test_tabpanel_only_0', {})
+  call term_sendkeys(buf, ":tabonly\<CR>")
+  call VerifyScreenDump(buf, 'Test_tabpanel_only_1', {})
+
+  call StopVimInTerminal(buf)
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index ffcfccb..4e85670 100644
--- a/src/version.c
+++ b/src/version.c
@@ -710,6 +710,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1394,
+/**/
     1393,
 /**/
     1392,
diff --git a/src/window.c b/src/window.c
index c7fea12..8543758 100644
--- a/src/window.c
+++ b/src/window.c
@@ -2086,7 +2086,7 @@
 	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);
+		      (int)COLUMNS_WITHOUT_TPL(), topframe->fr_height);
     if (!is_aucmd_win(next_curwin))
 	win_fix_scroll(TRUE);
 }
@@ -3463,6 +3463,10 @@
 	redraw_tabline = TRUE;
 	if (h != tabline_height())
 	    shell_new_rows();
+#if defined(FEAT_TABPANEL)
+	redraw_tabpanel = TRUE;
+#endif
+	shell_new_columns();
     }
 
     // Free the memory used for the window.