Skip to content

Commit 2954719

Browse files
committed
patch 8.1.0577: tabpage right-click menu never shows "Close tab"
Problem: Tabpage right-click menu never shows "Close tab". Solution: Always create the "Close tab" item but ignore the event if there is only one tab.
1 parent 30700cd commit 2954719

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

src/gui.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3865,10 +3865,14 @@ send_tabline_menu_event(int tabidx, int event)
38653865
{
38663866
char_u string[3];
38673867

3868-
/* Don't put events in the input queue now. */
3868+
// Don't put events in the input queue now.
38693869
if (hold_gui_events)
38703870
return;
38713871

3872+
// Cannot close the last tabpage.
3873+
if (event == TABLINE_MENU_CLOSE && first_tabpage->tp_next == NULL)
3874+
return;
3875+
38723876
string[0] = CSI;
38733877
string[1] = KS_TABMENU;
38743878
string[2] = KE_FILLER;

src/gui_gtk_x11.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3337,9 +3337,7 @@ create_tabline_menu(void)
33373337
GtkWidget *menu;
33383338

33393339
menu = gtk_menu_new();
3340-
if (first_tabpage->tp_next != NULL)
3341-
add_tabline_menu_item(menu, (char_u *)_("Close tab"),
3342-
TABLINE_MENU_CLOSE);
3340+
add_tabline_menu_item(menu, (char_u *)_("Close tab"), TABLINE_MENU_CLOSE);
33433341
add_tabline_menu_item(menu, (char_u *)_("New tab"), TABLINE_MENU_NEW);
33443342
add_tabline_menu_item(menu, (char_u *)_("Open Tab..."), TABLINE_MENU_OPEN);
33453343

src/gui_mac.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6705,8 +6705,7 @@ initialise_tabline(void)
67056705

67066706
// create tabline popup menu required by vim docs (see :he tabline-menu)
67076707
CreateNewMenu(kTabContextMenuId, 0, &contextMenu);
6708-
if (first_tabpage->tp_next != NULL)
6709-
AppendMenuItemTextWithCFString(contextMenu, CFSTR("Close Tab"), 0,
6708+
AppendMenuItemTextWithCFString(contextMenu, CFSTR("Close Tab"), 0,
67106709
TABLINE_MENU_CLOSE, NULL);
67116710
AppendMenuItemTextWithCFString(contextMenu, CFSTR("New Tab"), 0,
67126711
TABLINE_MENU_NEW, NULL);

src/gui_motif.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -514,21 +514,18 @@ gui_x11_create_widgets(void)
514514
XtVaSetValues(scroller, XmNwidth, 0, XmNresizable, False,
515515
XmNtraversalOn, False, NULL);
516516

517-
/* Create the tabline popup menu */
517+
// Create the tabline popup menu
518518
tabLine_menu = XmCreatePopupMenu(tabLine, "tabline popup", NULL, 0);
519519

520-
/* Add the buttons to the menu */
521-
if (first_tabpage->tp_next != NULL)
522-
{
523-
n = 0;
524-
XtSetArg(args[n], XmNuserData, TABLINE_MENU_CLOSE); n++;
525-
xms = XmStringCreate((char *)"Close tab", STRING_TAG);
526-
XtSetArg(args[n], XmNlabelString, xms); n++;
527-
button = XmCreatePushButton(tabLine_menu, "Close", args, n);
528-
XtAddCallback(button, XmNactivateCallback,
529-
(XtCallbackProc)tabline_button_cb, NULL);
530-
XmStringFree(xms);
531-
}
520+
// Add the buttons to the tabline popup menu
521+
n = 0;
522+
XtSetArg(args[n], XmNuserData, TABLINE_MENU_CLOSE); n++;
523+
xms = XmStringCreate((char *)"Close tab", STRING_TAG);
524+
XtSetArg(args[n], XmNlabelString, xms); n++;
525+
button = XmCreatePushButton(tabLine_menu, "Close", args, n);
526+
XtAddCallback(button, XmNactivateCallback,
527+
(XtCallbackProc)tabline_button_cb, NULL);
528+
XmStringFree(xms);
532529

533530
n = 0;
534531
XtSetArg(args[n], XmNuserData, TABLINE_MENU_NEW); n++;

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,8 @@ static char *(features[]) =
792792

793793
static int included_patches[] =
794794
{ /* Add new patch number below this line */
795+
/**/
796+
577,
795797
/**/
796798
576,
797799
/**/

0 commit comments

Comments
 (0)