diff --git a/src/MacVim/MMAppController.m b/src/MacVim/MMAppController.m index d3755fc444..c3588683e5 100644 --- a/src/MacVim/MMAppController.m +++ b/src/MacVim/MMAppController.m @@ -292,10 +292,8 @@ static int executeInLoginShell(NSString *path, NSArray *args); // Don't add files that are being edited remotely (using ODB). if ([arguments objectForKey:@"remoteID"]) continue; - NSURL *url = [NSURL fileURLWithPath:[filenames objectAtIndex:i]]; - if (!url) continue; [[NSDocumentController sharedDocumentController] - noteNewRecentDocumentURL:url]; + noteNewRecentFilePath:[filenames objectAtIndex:i]]; } if ((openInTabs && (vc = [self topmostVimController])) diff --git a/src/MacVim/MMVimController.m b/src/MacVim/MMVimController.m index 7cb5ac8980..fb5d00aa72 100644 --- a/src/MacVim/MMVimController.m +++ b/src/MacVim/MMVimController.m @@ -922,9 +922,15 @@ static NSTimeInterval MMResendInterval = 0.5; - (void)savePanelDidEnd:(NSSavePanel *)panel code:(int)code context:(void *)context { - NSString *string = (code == NSOKButton) ? [panel filename] : nil; + NSString *path = (code == NSOKButton) ? [panel filename] : nil; @try { - [backendProxy setDialogReturn:string]; + [backendProxy setDialogReturn:path]; + + // Add file to the "Recent Files" menu (this ensures that files that + // are opened/saved from a :browse command are added to this menu). + if (path) + [[NSDocumentController sharedDocumentController] + noteNewRecentFilePath:path]; } @catch (NSException *e) { NSLog(@"Exception caught in %s %@", _cmd, e); diff --git a/src/MacVim/MacVim.h b/src/MacVim/MacVim.h index aa49fc23f8..7862fff8a8 100644 --- a/src/MacVim/MacVim.h +++ b/src/MacVim/MacVim.h @@ -277,6 +277,13 @@ NSString *buildSearchTextCommand(NSString *searchText); +@interface NSDocumentController (MMExtras) +- (void)noteNewRecentFilePath:(NSString *)path; +@end + + + + // ODB Editor Suite Constants (taken from ODBEditorSuite.h) #define keyFileSender 'FSnd' #define keyFileSenderToken 'FTok' diff --git a/src/MacVim/MacVim.m b/src/MacVim/MacVim.m index b702b542c5..50d5d727e3 100644 --- a/src/MacVim/MacVim.m +++ b/src/MacVim/MacVim.m @@ -294,3 +294,17 @@ buildSearchTextCommand(NSString *searchText) @end // NSColor (MMExtras) + + + +@implementation NSDocumentController (MMExtras) + +- (void)noteNewRecentFilePath:(NSString *)path +{ + NSURL *url = [NSURL fileURLWithPath:path]; + if (url) + [self noteNewRecentDocumentURL:url]; +} + +@end // NSDocumentController (MMExtras) +