patch 9.2.0397: tabpanel: double-click opens a new tab

Problem:  tabpanel: double-click opens a new tab page
Solution: Do not create a new tab page when using a double click
          (Yasuhiro Matsumoto).

The tabpanel click handler inherited the tabline behavior where a
double-click opens a new, empty tab page.  Unlike the tabline, the
tabpanel has no "empty area": every row maps to some tab, so this
fires on any double-click in the tabpanel and can generate stray
empty tabs.  The behavior is also not documented for the tabpanel.

Skip the new-tab branch when the click originated in the tabpanel
and fall through to the regular tab-switch path instead.  The
tabline behavior is unchanged.

closes: #20044

Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Yasuhiro Matsumoto
2026-04-26 16:47:08 +00:00
committed by Christian Brabandt
parent 076366bd4e
commit 22aedc4a90
4 changed files with 20 additions and 3 deletions
+11 -1
View File
@@ -1,4 +1,4 @@
*tabpage.txt* For Vim version 9.2. Last change: 2026 Apr 25
*tabpage.txt* For Vim version 9.2. Last change: 2026 Apr 26
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -513,6 +513,16 @@ The scrollbar uses the |hl-PmenuSbar| highlight group for the track and
The scroll offset is remembered across redraws but is reset when "scroll" or
"scrollbar" is toggled off and back on.
MOUSE CLICKS IN THE TABPANEL: *tabpanel-mouse*
A left click on a row in the tabpanel selects the tab page that the row
belongs to. Unlike the tabline, a double click in the tabpanel does not
open a new, empty tab page; it is treated the same as a single click.
For finer-grained control, the 'tabpanel' value may contain |stl-%[FuncName]|
click regions. Clicks on those regions are dispatched to the callback
function instead of falling through to tab selection.
==============================================================================
6. Setting 'guitablabel' *setting-guitablabel*
+1
View File
@@ -10893,6 +10893,7 @@ tabpagebuflist() builtin.txt /*tabpagebuflist()*
tabpagenr() builtin.txt /*tabpagenr()*
tabpagewinnr() builtin.txt /*tabpagewinnr()*
tabpanel tabpage.txt /*tabpanel*
tabpanel-mouse tabpage.txt /*tabpanel-mouse*
tabpanel-scroll tabpage.txt /*tabpanel-scroll*
tag tagsrch.txt /*tag*
tag-! tagsrch.txt /*tag-!*
+6 -2
View File
@@ -591,9 +591,13 @@ do_mouse(
c1 = tp_label.nr;
if (c1 >= 0)
{
if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK)
if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK
&& !tp_label.is_panel)
{
// double click opens new page
// Double-click on the tabline opens a new, empty tab page.
// The tabpanel has no "empty area" (every row maps to a tab)
// and this behavior is not documented for tabpanel, so fall
// through to the regular tab-switch path there.
end_visual_mode_keep_button();
tabpage_new();
tabpage_move(c1 == 0 ? 9999 : c1 - 1);
+2
View File
@@ -729,6 +729,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
397,
/**/
396,
/**/