]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0397: tabpanel: double-click opens a new tab v9.2.0397
authorYasuhiro Matsumoto <mattn.jp@gmail.com>
Sun, 26 Apr 2026 16:47:08 +0000 (16:47 +0000)
committerChristian Brabandt <cb@256bit.org>
Sun, 26 Apr 2026 16:53:58 +0000 (16:53 +0000)
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>
runtime/doc/tabpage.txt
runtime/doc/tags
src/mouse.c
src/version.c

index 50836189178ceca29d613e3fa4315b8860418fd0..7fc09c54518ccf6ccaadda89f664fc69b69fcd6b 100644 (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*
 
index 80b1d18becd47d74d12d953c18c031543b92445d..65edb2c31cfd9106422b2984c72ad5f47e5fcccc 100644 (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-!*
index 93fdd31824ceb5557c71f6a4b411b9fcb712bc0c..ddd94fffcf0e1f7b69cd072f28456dfb330e994b 100644 (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);
index e714ddc2a3cc1935f1bbbaf830d715e2774a7fb8..1649c0ff8e5e655769bc80d925eda16a6e81dc20 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    397,
 /**/
     396,
 /**/