mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Use current document when no URL given in txmt URL
Brings TM2 in line with the promises in http://manual.macromates.com/en/using_textmate_from_terminal.html Could probably be written nicer, I just don't get C++!
This commit is contained in:
committed by
Allan Odgaard
parent
aa234b723d
commit
2beac7080b
@@ -77,6 +77,7 @@ static NSString* const OakGlobalSessionInfo = @"OakGlobalSessionInfo";
|
||||
{
|
||||
std::map<std::string, std::string> parameters;
|
||||
|
||||
BOOL hadURL = NO;
|
||||
NSArray* components = [[aURL query] componentsSeparatedByString:@"&"];
|
||||
for(NSString* part in components)
|
||||
{
|
||||
@@ -86,6 +87,19 @@ static NSString* const OakGlobalSessionInfo = @"OakGlobalSessionInfo";
|
||||
std::string key = to_s([[keyValue firstObject] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]);
|
||||
NSURL* fileURL = key == "url" ? [NSURL URLWithString:[keyValue lastObject]] : nil;
|
||||
parameters[key] = to_s([fileURL isFileURL] ? [fileURL path] : [[keyValue lastObject] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]);
|
||||
hadURL |= (key == "url");
|
||||
}
|
||||
}
|
||||
|
||||
if(!hadURL && [[NSApp orderedWindows]count] > 0)
|
||||
{
|
||||
NSWindow* window=[[NSApp orderedWindows]objectAtIndex:0];
|
||||
DocumentController* controller = (DocumentController*)[window delegate];
|
||||
if([controller isKindOfClass:[DocumentController class]] && !controller->documentTabs.empty())
|
||||
{
|
||||
NSString* path=[controller documentFilePath];
|
||||
|
||||
if(path && [path length] > 0) parameters["url"] = to_s(path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user