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.
This commit is contained in:
Allan Odgaard
2013-04-09 17:16:51 +07:00
parent ee4f7a48a2
commit d45adf2fed

View File

@@ -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];
}