diff --git a/native/atom_application.h b/native/atom_application.h index 32ea81361..95350506e 100644 --- a/native/atom_application.h +++ b/native/atom_application.h @@ -6,6 +6,7 @@ class AtomCefClient; @interface AtomApplication : NSApplication { NSWindowController *_backgroundWindowController; NSDictionary *_arguments; + BOOL _filesOpened; BOOL handlingSendEvent_; } @@ -22,4 +23,4 @@ class AtomCefClient; @property (nonatomic, retain) NSDictionary *arguments; -@end \ No newline at end of file +@end diff --git a/native/atom_application.mm b/native/atom_application.mm index 2a10aff0f..949f59b7d 100644 --- a/native/atom_application.mm +++ b/native/atom_application.mm @@ -174,24 +174,31 @@ # pragma mark NSApplicationDelegate +- (BOOL)shouldOpenFiles { + if ([self.arguments objectForKey:@"benchmark"]) { + return NO; + } + if ([self.arguments objectForKey:@"test"]) { + return NO; + } + return YES; +} + - (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames { - for (int i = 0; i < [filenames count]; i++) { - NSString *path = [filenames objectAtIndex:i]; - path = [[self class] standardizePathToOpen:path withArguments:self.arguments]; - [self open:path]; + if ([self shouldOpenFiles]) { + for (int i = 0; i < [filenames count]; i++) { + NSString *path = [filenames objectAtIndex:i]; + path = [[self class] standardizePathToOpen:path withArguments:self.arguments]; + [self open:path]; + } + if ([filenames count] > 0) { + _filesOpened = YES; + } } } -- (void)applicationWillFinishLaunching:(NSNotification *)notification { - _backgroundWindowController = [[AtomWindowController alloc] initInBackground]; - - if ([self.arguments objectForKey:@"benchmark"]) { - [self runBenchmarksThenExit:true]; - } - else if ([self.arguments objectForKey:@"test"]) { - [self runSpecsThenExit:true]; - } - else { +- (void)applicationDidFinishLaunching:(NSNotification *)notification { + if (!_filesOpened && [self shouldOpenFiles]) { NSString *path = [self.arguments objectForKey:@"path"]; // Just a hack to open the Atom src by default when we run from xcode @@ -203,6 +210,16 @@ } } +- (void)applicationWillFinishLaunching:(NSNotification *)notification { + _backgroundWindowController = [[AtomWindowController alloc] initInBackground]; + if ([self.arguments objectForKey:@"benchmark"]) { + [self runBenchmarksThenExit:true]; + } + else if ([self.arguments objectForKey:@"test"]) { + [self runSpecsThenExit:true]; + } +} + - (void)applicationWillTerminate:(NSNotification *)notification { for (NSWindow *window in [self windows]) { [window performClose:self];