Skip to content

Commit bf9679a

Browse files
committed
patch 8.1.0492: "Edit with existing Vim" list can get long
Problem: "Edit with existing Vim" list can get long. Solution: Move the list to a submenu. (Ken Takata, closes #3561)
1 parent 0fd6be7 commit bf9679a

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

src/GvimExt/gvimext.cpp

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -708,11 +708,26 @@ STDMETHODIMP CShellExt::QueryContextMenu(HMENU hMenu,
708708
m_edit_existing_off = 1;
709709
}
710710

711+
HMENU hSubMenu = NULL;
712+
if (m_cntOfHWnd > 1)
713+
{
714+
hSubMenu = CreatePopupMenu();
715+
mii.fMask |= MIIM_SUBMENU;
716+
mii.wID = idCmd;
717+
mii.dwTypeData = _("Edit with existing Vim");
718+
mii.cch = lstrlen(mii.dwTypeData);
719+
mii.hSubMenu = hSubMenu;
720+
InsertMenuItem(hMenu, indexMenu++, TRUE, &mii);
721+
mii.fMask = mii.fMask & ~MIIM_SUBMENU;
722+
mii.hSubMenu = NULL;
723+
}
711724
// Now display all the vim instances
712725
for (int i = 0; i < m_cntOfHWnd; i++)
713726
{
714727
char title[BUFSIZE];
715728
char temp[BUFSIZE];
729+
int index;
730+
HMENU hmenu;
716731

717732
// Obtain window title, continue if can not
718733
if (GetWindowText(m_hWnd[i], title, BUFSIZE - 1) == 0)
@@ -726,15 +741,30 @@ STDMETHODIMP CShellExt::QueryContextMenu(HMENU hMenu,
726741
*pos = 0;
727742
}
728743
// Now concatenate
729-
strncpy(temp, _("Edit with existing Vim - "), BUFSIZE - 1);
730-
temp[BUFSIZE - 1] = '\0';
744+
if (m_cntOfHWnd > 1)
745+
temp[0] = '\0';
746+
else
747+
{
748+
strncpy(temp, _("Edit with existing Vim - "), BUFSIZE - 1);
749+
temp[BUFSIZE - 1] = '\0';
750+
}
731751
strncat(temp, title, BUFSIZE - 1 - strlen(temp));
732752
temp[BUFSIZE - 1] = '\0';
733753

734754
mii.wID = idCmd++;
735755
mii.dwTypeData = temp;
736756
mii.cch = lstrlen(mii.dwTypeData);
737-
InsertMenuItem(hMenu, indexMenu++, TRUE, &mii);
757+
if (m_cntOfHWnd > 1)
758+
{
759+
hmenu = hSubMenu;
760+
index = i;
761+
}
762+
else
763+
{
764+
hmenu = hMenu;
765+
index = indexMenu++;
766+
}
767+
InsertMenuItem(hmenu, index, TRUE, &mii);
738768
}
739769
// InsertMenu(hMenu, indexMenu++, MF_SEPARATOR|MF_BYPOSITION, 0, NULL);
740770

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+
492,
795797
/**/
796798
491,
797799
/**/

0 commit comments

Comments
 (0)