diff --git a/Applications/TextMate/src/AppController Documents.mm b/Applications/TextMate/src/AppController Documents.mm index aef65729..535ae495 100644 --- a/Applications/TextMate/src/AppController Documents.mm +++ b/Applications/TextMate/src/AppController Documents.mm @@ -77,6 +77,7 @@ static NSString* const OakGlobalSessionInfo = @"OakGlobalSessionInfo"; { std::map 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); } } diff --git a/Frameworks/DocumentWindow/src/DocumentController.h b/Frameworks/DocumentWindow/src/DocumentController.h index 8120c326..4e86817f 100644 --- a/Frameworks/DocumentWindow/src/DocumentController.h +++ b/Frameworks/DocumentWindow/src/DocumentController.h @@ -71,6 +71,7 @@ namespace bundles { struct item_t; typedef std::tr1::shared_ptr item_ptr @property (nonatomic, readonly) NSString* identifier; @property (nonatomic, assign) BOOL fileBrowserHidden; @property (nonatomic, readonly) NSString* documentPath; +@property (nonatomic, readonly) NSString* documentFilePath; @property (nonatomic, readonly) NSString* fileBrowserPath; @property (nonatomic, readonly) NSString* projectPath; @property (nonatomic, readonly) NSString* untitledSavePath; diff --git a/Frameworks/DocumentWindow/src/DocumentController.mm b/Frameworks/DocumentWindow/src/DocumentController.mm index 6f0c0bb5..3104aa57 100644 --- a/Frameworks/DocumentWindow/src/DocumentController.mm +++ b/Frameworks/DocumentWindow/src/DocumentController.mm @@ -1160,6 +1160,11 @@ static std::string parent_or_home (std::string const& path) return [NSString stringWithCxxString:documentTabs.empty() ? NULL_STR : parent_or_home([self selectedDocument]->path())]; } +- (NSString*)documentFilePath +{ + return [NSString stringWithCxxString:documentTabs.empty() ? NULL_STR : [self selectedDocument]->path()]; +} + - (NSString*)projectPath { settings_t const& settings = documentTabs.empty() || [self selectedDocument]->path() == NULL_STR ? settings_for_path(NULL_STR, "", to_s(self.fileBrowserPath)) : [self selectedDocument]->settings();