mirror of
https://github.com/textmate/textmate.git
synced 2026-02-15 08:55:01 -05:00
If opening an already open folder, bring window to front
This is mainly for calling ‘mate «directory»’. Reference http://lists.macromates.com/textmate/2012-August/035164.html
This commit is contained in:
committed by
Allan Odgaard
parent
2beac7080b
commit
db294ba346
@@ -77,6 +77,7 @@ namespace bundles { struct item_t; typedef std::tr1::shared_ptr<item_t> item_ptr
|
||||
@property (nonatomic, readonly) NSString* untitledSavePath;
|
||||
|
||||
+ (DocumentController*)controllerForDocument:(document::document_ptr const&)aDocument;
|
||||
+ (DocumentController*)controllerForPath:(std::string const&)aPath;
|
||||
+ (DocumentController*)controllerForUUID:(oak::uuid_t const&)aUUID;
|
||||
|
||||
- (id)init;
|
||||
|
||||
@@ -216,10 +216,16 @@ NSString* const kUserDefaultsFileBrowserPlacementKey = @"fileBrowserPlacement";
|
||||
bring_to_front([[DocumentController alloc] initWithDocuments:documents]);
|
||||
}
|
||||
}
|
||||
else if(DocumentController* delegate = [DocumentController controllerForPath:browserPath])
|
||||
{
|
||||
if(!documents.empty())
|
||||
[delegate addDocuments:documents andSelect:kSelectDocumentFirst closeOther:NO pruneTabBar:YES];
|
||||
bring_to_front(delegate);
|
||||
}
|
||||
else // if(browserPath != NULL_STR)
|
||||
{
|
||||
close_scratch_project();
|
||||
DocumentController* delegate = documents.empty() ? [[DocumentController alloc] init] : [[DocumentController alloc] initWithDocuments:documents];
|
||||
delegate = documents.empty() ? [[DocumentController alloc] init] : [[DocumentController alloc] initWithDocuments:documents];
|
||||
[delegate window];
|
||||
delegate.fileBrowserHidden = NO;
|
||||
[delegate->fileBrowser showURL:[NSURL fileURLWithPath:[NSString stringWithCxxString:path::resolve(browserPath)]]];
|
||||
@@ -422,6 +428,22 @@ NSString* const kUserDefaultsFileBrowserPlacementKey = @"fileBrowserPlacement";
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (DocumentController*)controllerForPath:(std::string const&)aPath
|
||||
{
|
||||
NSURL* url = [NSURL fileURLWithPath:[NSString stringWithCxxString:path::resolve(aPath)]];
|
||||
NSString* path = [url isFileURL] ? [url path] : nil;
|
||||
for(NSWindow* window in [NSApp orderedWindows])
|
||||
{
|
||||
DocumentController* delegate = (DocumentController*)[window delegate];
|
||||
if([delegate isKindOfClass:self])
|
||||
{
|
||||
if(!delegate.fileBrowserHidden && [path isEqualToString:delegate.fileBrowserPath])
|
||||
return delegate;
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (DocumentController*)controllerForUUID:(oak::uuid_t const&)aUUID
|
||||
{
|
||||
for(NSWindow* window in [NSApp orderedWindows])
|
||||
|
||||
Reference in New Issue
Block a user