]> granicus.if.org Git - vim/commitdiff
patch 8.1.0695: internal error when using :popup v8.1.0695
authorBram Moolenaar <Bram@vim.org>
Sun, 6 Jan 2019 12:11:05 +0000 (13:11 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 6 Jan 2019 12:11:05 +0000 (13:11 +0100)
Problem:    Internal error when using :popup.
Solution:   When a menu only exists in Terminal mode give an error. (Naruhiko
            Nishino, closes #3765)

runtime/doc/gui.txt
src/globals.h
src/menu.c
src/popupmnu.c
src/testdir/test_popup.vim
src/version.c

index 565f8a518f9c792146fab0ebc594ee337ac4fe73..5df8f533b6da4ebbb526aebd6f97a9c982afe5f7 100644 (file)
@@ -1,4 +1,4 @@
-*gui.txt*       For Vim version 8.1.  Last change: 2018 Mar 06
+*gui.txt*       For Vim version 8.1.  Last change: 2019 Jan 06
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -914,7 +914,9 @@ may be used to complete the name of the menu item for the appropriate mode.
 To remove all menus use:                       *:unmenu-all*  >
        :unmenu *       " remove all menus in Normal and visual mode
        :unmenu! *      " remove all menus in Insert and Command-line mode
-       :aunmenu *      " remove all menus in all modes
+       :aunmenu *      " remove all menus in all modes, except for Terminal
+                       " mode
+       :tlunmenu *     " remove all menus in Terminal mode
 
 If you want to get rid of the menu bar: >
        :set guioptions-=m
index 2a7ecd17b528ae1f20b16e2d71c8279ba8fcbef8..3f67d1377fb8a8c93b2f8564d6b69a2a7354f3b6 100644 (file)
@@ -1583,6 +1583,9 @@ EXTERN char_u e_invalidreg[]    INIT(= N_("E850: Invalid register name"));
 #endif
 EXTERN char_u e_dirnotf[]      INIT(= N_("E919: Directory not found in '%s': \"%s\""));
 EXTERN char_u e_au_recursive[] INIT(= N_("E952: Autocommand caused recursive behavior"));
+#ifdef FEAT_MENU
+EXTERN char_u e_menuothermode[] INIT(= N_("E328: Menu only exists in another mode"));
+#endif
 
 #ifdef FEAT_GUI_MAC
 EXTERN short disallow_gui      INIT(= FALSE);
index 782235a11c25342f2da21211c4b923055828b5aa..944211844ca158c533e388fe8e59a1ccd9db048f 100644 (file)
@@ -61,7 +61,6 @@ static char_u *menu_translate_tab_and_shift(char_u *arg_start);
 static char *menu_mode_chars[] = {"n", "v", "s", "o", "i", "c", "tl", "t"};
 
 static char_u e_notsubmenu[] = N_("E327: Part of menu-item path is not sub-menu");
-static char_u e_othermode[] = N_("E328: Menu only exists in another mode");
 static char_u e_nomenu[] = N_("E329: No menu \"%s\"");
 
 #ifdef FEAT_TOOLBAR
@@ -956,7 +955,7 @@ remove_menu(
            else if (*name != NUL)
            {
                if (!silent)
-                   EMSG(_(e_othermode));
+                   EMSG(_(e_menuothermode));
                return FAIL;
            }
 
@@ -1130,7 +1129,7 @@ show_menus(char_u *path_name, int modes)
                }
                else if ((menu->modes & modes) == 0x0)
                {
-                   EMSG(_(e_othermode));
+                   EMSG(_(e_menuothermode));
                    vim_free(path_name);
                    return FAIL;
                }
index 6ef0af92a2653ce0e645d0a25eec730680525890..962a59a1bf386bdd3e87581c405f37fa360872d2 100644 (file)
@@ -1195,6 +1195,14 @@ pum_show_popupmenu(vimmenu_T *menu)
                || (mp->modes & mp->enabled & mode))
            ++pum_size;
 
+    // When there are only Terminal mode menus, using "popup Edit" results in
+    // pum_size being zero.
+    if (pum_size <= 0)
+    {
+       EMSG(e_menuothermode);
+       return;
+    }
+
     array = (pumitem_T *)alloc_clear((unsigned)sizeof(pumitem_T) * pum_size);
     if (array == NULL)
        return;
index 287d59d9018d2dc46d9289e641a5f12e9fe9ef57..663a6a8e0192d277d9d187b799487d6799797dd7 100644 (file)
@@ -882,5 +882,18 @@ func Test_complete_o_tab()
   delfunc s:act_on_text_changed
 endfunc
 
+func Test_menu_only_exists_in_terminal()
+  if !exists(':tlmenu') || has('gui_running')
+    return
+  endif
+  tlnoremenu  &Edit.&Paste<Tab>"+gP  <C-W>"+
+  aunmenu *
+  try
+    popup Edit
+    call assert_false(1, 'command should have failed')
+  catch
+    call assert_exception('E328:')
+  endtry
+endfunc
 
 " vim: shiftwidth=2 sts=2 expandtab
index 3450325e78a48dca1c8ce6cde7c295105eefc187..790c4f7706afa5a6563a891a3f0e41e44bcf11ef 100644 (file)
@@ -799,6 +799,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    695,
 /**/
     694,
 /**/