mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Treat commit window action command names as format strings
Presently the ‘TM_DISPLAYNAME’ is conditionally available, allowing the name to contain the file name which it will work with. Also fix a potential “out of range” exception. The validateMenuItem: could be called for a cached menu item (e.g. when the system resolves key equivalents) where we had no selection (nor did click any item), so we would access the row at index -1.
This commit is contained in:
@@ -546,10 +546,17 @@ static NSUInteger const kOakCommitWindowCommitMessagesMax = 5;
|
||||
NSInteger row = [_tableView clickedColumn] == -1 || [_tableView clickedRow] == -1 ? [_tableView selectedRow] : [_tableView clickedRow];
|
||||
if([menuItem action] == @selector(performActionCommand:))
|
||||
{
|
||||
if(row == -1)
|
||||
return NO;
|
||||
|
||||
CWItem* cwItem = [[_arrayController arrangedObjects] objectAtIndex:row];
|
||||
actionCommandObj* cmd = [menuItem representedObject];
|
||||
if(![cmd.targetStatuses containsObject:cwItem.scmStatus])
|
||||
active = NO;
|
||||
|
||||
std::map<std::string, std::string> variables;
|
||||
if(active = [cmd.targetStatuses containsObject:cwItem.scmStatus])
|
||||
variables = { { "TM_DISPLAYNAME", path::display_name(to_s(cwItem.path)) } };
|
||||
|
||||
menuItem.title = [NSString stringWithCxxString:format_string::expand(to_s(cmd.name), variables)];
|
||||
}
|
||||
return active;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user