0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

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.
This commit is contained in:
Bram Moolenaar 2018-12-11 20:39:19 +01:00
parent 30700cd5ff
commit 295471920d
5 changed files with 19 additions and 19 deletions

View File

@ -3865,10 +3865,14 @@ send_tabline_menu_event(int tabidx, int event)
{ {
char_u string[3]; char_u string[3];
/* Don't put events in the input queue now. */ // Don't put events in the input queue now.
if (hold_gui_events) if (hold_gui_events)
return; return;
// Cannot close the last tabpage.
if (event == TABLINE_MENU_CLOSE && first_tabpage->tp_next == NULL)
return;
string[0] = CSI; string[0] = CSI;
string[1] = KS_TABMENU; string[1] = KS_TABMENU;
string[2] = KE_FILLER; string[2] = KE_FILLER;

View File

@ -3337,9 +3337,7 @@ create_tabline_menu(void)
GtkWidget *menu; GtkWidget *menu;
menu = gtk_menu_new(); menu = gtk_menu_new();
if (first_tabpage->tp_next != NULL) add_tabline_menu_item(menu, (char_u *)_("Close tab"), TABLINE_MENU_CLOSE);
add_tabline_menu_item(menu, (char_u *)_("Close tab"),
TABLINE_MENU_CLOSE);
add_tabline_menu_item(menu, (char_u *)_("New tab"), TABLINE_MENU_NEW); add_tabline_menu_item(menu, (char_u *)_("New tab"), TABLINE_MENU_NEW);
add_tabline_menu_item(menu, (char_u *)_("Open Tab..."), TABLINE_MENU_OPEN); add_tabline_menu_item(menu, (char_u *)_("Open Tab..."), TABLINE_MENU_OPEN);

View File

@ -6705,7 +6705,6 @@ initialise_tabline(void)
// create tabline popup menu required by vim docs (see :he tabline-menu) // create tabline popup menu required by vim docs (see :he tabline-menu)
CreateNewMenu(kTabContextMenuId, 0, &contextMenu); CreateNewMenu(kTabContextMenuId, 0, &contextMenu);
if (first_tabpage->tp_next != NULL)
AppendMenuItemTextWithCFString(contextMenu, CFSTR("Close Tab"), 0, AppendMenuItemTextWithCFString(contextMenu, CFSTR("Close Tab"), 0,
TABLINE_MENU_CLOSE, NULL); TABLINE_MENU_CLOSE, NULL);
AppendMenuItemTextWithCFString(contextMenu, CFSTR("New Tab"), 0, AppendMenuItemTextWithCFString(contextMenu, CFSTR("New Tab"), 0,

View File

@ -514,12 +514,10 @@ gui_x11_create_widgets(void)
XtVaSetValues(scroller, XmNwidth, 0, XmNresizable, False, XtVaSetValues(scroller, XmNwidth, 0, XmNresizable, False,
XmNtraversalOn, False, NULL); XmNtraversalOn, False, NULL);
/* Create the tabline popup menu */ // Create the tabline popup menu
tabLine_menu = XmCreatePopupMenu(tabLine, "tabline popup", NULL, 0); tabLine_menu = XmCreatePopupMenu(tabLine, "tabline popup", NULL, 0);
/* Add the buttons to the menu */ // Add the buttons to the tabline popup menu
if (first_tabpage->tp_next != NULL)
{
n = 0; n = 0;
XtSetArg(args[n], XmNuserData, TABLINE_MENU_CLOSE); n++; XtSetArg(args[n], XmNuserData, TABLINE_MENU_CLOSE); n++;
xms = XmStringCreate((char *)"Close tab", STRING_TAG); xms = XmStringCreate((char *)"Close tab", STRING_TAG);
@ -528,7 +526,6 @@ gui_x11_create_widgets(void)
XtAddCallback(button, XmNactivateCallback, XtAddCallback(button, XmNactivateCallback,
(XtCallbackProc)tabline_button_cb, NULL); (XtCallbackProc)tabline_button_cb, NULL);
XmStringFree(xms); XmStringFree(xms);
}
n = 0; n = 0;
XtSetArg(args[n], XmNuserData, TABLINE_MENU_NEW); n++; XtSetArg(args[n], XmNuserData, TABLINE_MENU_NEW); n++;

View File

@ -792,6 +792,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
577,
/**/ /**/
576, 576,
/**/ /**/