Skip to content

Commit 2760686

Browse files
authored
Merge pull request #911 from eirnym/bracket-menu
Hide MNU_HIDDEN_CHAR prefix from menu title if present
2 parents 0cbfb73 + 4849c20 commit 2760686

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

src/MacVim/MMVimController.m

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242

4343
static const NSString * const MMToolbarMenuName = @"ToolBar";
4444
static const NSString * const MMTouchbarMenuName = @"TouchBar";
45+
static const NSString * const MMPopUpMenuPrefix = @"PopUp";
46+
static const NSString * const MMUserPopUpMenuPrefix = @"]";
4547

4648
// NOTE: By default a message sent to the backend will be dropped if it cannot
4749
// be delivered instantly; otherwise there is a possibility that MacVim will
@@ -1056,14 +1058,18 @@ - (void)alertDidEnd:(MMAlert *)alert code:(int)code context:(void *)context
10561058
pid, identifier, ex);
10571059
}
10581060
}
1059-
1061+
+ (bool) hasPopupPrefix: (NSString *) menuName
1062+
{
1063+
return [menuName hasPrefix:MMPopUpMenuPrefix] || [menuName hasPrefix:MMUserPopUpMenuPrefix];
1064+
}
10601065
- (NSMenuItem *)menuItemForDescriptor:(NSArray *)desc
10611066
{
10621067
if (!(desc && [desc count] > 0)) return nil;
10631068

10641069
NSString *rootName = [desc objectAtIndex:0];
1065-
NSArray *rootItems = [rootName hasPrefix:@"PopUp"] ? popupMenuItems
1066-
: [mainMenu itemArray];
1070+
bool popup = [MMVimController hasPopupPrefix:rootName];
1071+
NSArray *rootItems = popup ? popupMenuItems
1072+
: [mainMenu itemArray];
10671073

10681074
NSMenuItem *item = nil;
10691075
int i, count = [rootItems count];
@@ -1089,8 +1095,9 @@ - (NSMenu *)parentMenuForDescriptor:(NSArray *)desc
10891095
if (!(desc && [desc count] > 0)) return nil;
10901096

10911097
NSString *rootName = [desc objectAtIndex:0];
1092-
NSArray *rootItems = [rootName hasPrefix:@"PopUp"] ? popupMenuItems
1093-
: [mainMenu itemArray];
1098+
bool popup = [MMVimController hasPopupPrefix:rootName];
1099+
NSArray *rootItems = popup ? popupMenuItems
1100+
: [mainMenu itemArray];
10941101

10951102
NSMenu *menu = nil;
10961103
int i, count = [rootItems count];
@@ -1172,7 +1179,7 @@ - (void)addMenuWithDescriptor:(NSArray *)desc atIndex:(int)idx
11721179
[item setSubmenu:menu];
11731180

11741181
NSMenu *parent = [self parentMenuForDescriptor:desc];
1175-
if (!parent && [rootName hasPrefix:@"PopUp"]) {
1182+
if (!parent && [MMVimController hasPopupPrefix:rootName]) {
11761183
if ([popupMenuItems count] <= idx) {
11771184
[popupMenuItems addObject:item];
11781185
} else {

0 commit comments

Comments
 (0)