diff src/popupmnu.c @ 15375:6012cc6936f7 v8.1.0695

patch 8.1.0695: internal error when using :popup commit https://github.com/vim/vim/commit/f42b45d719e03218735b3c2845a74dca9c0efd60 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 6 13:11:05 2019 +0100 patch 8.1.0695: internal error when using :popup Problem: Internal error when using :popup. Solution: When a menu only exists in Terminal mode give an error. (Naruhiko Nishino, closes #3765)
author Bram Moolenaar <Bram@vim.org>
date Sun, 06 Jan 2019 13:15:09 +0100
parents 605b9c42a8c5
children 55ccc2d353bd
line wrap: on
line diff
--- a/src/popupmnu.c
+++ b/src/popupmnu.c
@@ -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;