From d45adf2fed519e1afffcffc4d4ccdf6055ef1c23 Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Tue, 9 Apr 2013 17:16:51 +0700 Subject: [PATCH] Ask for confirmation to skip session restore Sometimes shift is held down while TextMate is being launched for other reasons than to skip session restore, so to be safe, we are now asking the user to confirm their intent. --- Applications/TextMate/src/AppController.mm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Applications/TextMate/src/AppController.mm b/Applications/TextMate/src/AppController.mm index b7a2e109..526de4e4 100644 --- a/Applications/TextMate/src/AppController.mm +++ b/Applications/TextMate/src/AppController.mm @@ -192,9 +192,15 @@ BOOL HasDocumentWindow (NSArray* windows) [[BundlesManager sharedInstance] loadBundlesIndex]; [[TMPlugInController sharedInstance] loadAllPlugIns:nil]; - BOOL disableSessionRestoreKeyDown = ([NSEvent modifierFlags] & NSShiftKeyMask) == NSShiftKeyMask; - BOOL disableSessionRestorePrefs = [[NSUserDefaults standardUserDefaults] boolForKey:kUserDefaultsDisableSessionRestoreKey]; - if(!disableSessionRestoreKeyDown && !disableSessionRestorePrefs) + BOOL restoreSession = ![[NSUserDefaults standardUserDefaults] boolForKey:kUserDefaultsDisableSessionRestoreKey]; + if(restoreSession && ([NSEvent modifierFlags] & NSShiftKeyMask)) + { + NSInteger choice = NSRunAlertPanel(@"Disable Session Restore?", @"By holding down shift (⇧) you have indicated that you wish to disable restoring the documents which were open in last session.", @"Disable", @"Restore Documents", nil); + if(choice == NSAlertDefaultReturn) // "Disable" + restoreSession = NO; + } + + if(restoreSession) [DocumentController restoreSession]; }