Skip to content
Snippets Groups Projects
Commit 50c3ce18 authored by George Nachman's avatar George Nachman
Browse files

Do not warn before multiline paste when not at shell prompt.

parent 293dea73
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -154,5 +154,6 @@
+ (BOOL)showYellowMarkForJobStoppedBySignal;
+ (double)slowFrameRate;
+ (BOOL)useColorfgbgFallback;
+ (BOOL)promptForPasteWhenNotAtPrompt;
 
@end
Loading
Loading
@@ -188,6 +188,7 @@ DEFINE_BOOL(copyWithStylesByDefault, NO, @"Pasteboard: Copy to pasteboard on sel
DEFINE_INT(pasteHistoryMaxOptions, 20, @"Pasteboard: Number of entires to save in Paste History.\n.");
DEFINE_BOOL(disallowCopyEmptyString, NO, @"Pasteboard: Disallow copying empty string to pasteboard.\nIf enabled, selecting an empty string (or all whitespace if trimming is enabled) will not erase the contents of the pasteboard.");
DEFINE_BOOL(typingClearsSelection, YES, @"Pasteboard: Pressing a key will remove the selection.");
DEFINE_BOOL(promptForPasteWhenNotAtPrompt, NO, @"Pasteboard: Warn before pasting when not at shell prompt?");
 
#pragma mark - Tip of the day
 
Loading
Loading
Loading
Loading
@@ -443,7 +443,34 @@ static BOOL hasBecomeActive = NO;
[alert runModal];
}
}
- (void)warnAboutChangeToDefaultPasteBehavior {
static NSString *const kHaveWarnedAboutPasteConfirmationChange = @"NoSyncHaveWarnedAboutPasteConfirmationChange";
if ([[NSUserDefaults standardUserDefaults] boolForKey:kHaveWarnedAboutPasteConfirmationChange]) {
// Safety check that we definitely don't show this twice.
return;
}
NSString *identifier = [iTermAdvancedSettingsModel noSyncDoNotWarnBeforeMultilinePasteUserDefaultsKey];
if ([iTermWarning identifierIsSilenced:identifier]) {
return;
}
NSArray *warningList = @[ @"3.0.0", @"3.0.1", @"3.0.2", @"3.0.3", @"3.0.4", @"3.0.5", @"3.0.6", @"3.0.7", @"3.0.8", @"3.0.9", @"3.0.10" ];
if ([warningList containsObject:[iTermPreferences appVersionBeforeThisLaunch]]) {
[iTermWarning showWarningWithTitle:@"iTerm2 no longer warns before a multi-line paste, unless you are at the shell prompt."
actions:@[ @"OK" ]
accessory:nil
identifier:nil
silenceable:kiTermWarningTypePersistent
heading:@"Important Change"];
}
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:kHaveWarnedAboutPasteConfirmationChange];
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
[self warnAboutChangeToDefaultPasteBehavior];
if ([self shouldNotifyAboutIncompatibleSoftware]) {
[self notifyAboutIncompatibleSoftware];
}
Loading
Loading
Loading
Loading
@@ -504,11 +504,13 @@ const int kNumberOfSpacesPerTabNoConversion = -1;
[actions addObject:paste];
[actions addObject:cancel];
NSString *identifier = [iTermAdvancedSettingsModel noSyncDoNotWarnBeforeMultilinePasteUserDefaultsKey];
BOOL prompt = YES;
if (lines.count > 1) {
if (atShellPrompt) {
theTitle = [NSString stringWithFormat:@"OK to paste %d lines at shell prompt?",
(int)[lines count]];
} else {
prompt = [iTermAdvancedSettingsModel promptForPasteWhenNotAtPrompt];
theTitle = [NSString stringWithFormat:@"OK to paste %d lines?",
(int)[lines count]];
}
Loading
Loading
@@ -518,10 +520,14 @@ const int kNumberOfSpacesPerTabNoConversion = -1;
identifier = [iTermAdvancedSettingsModel noSyncDoNotWarnBeforePastingOneLineEndingInNewlineAtShellPromptUserDefaultsKey];
theTitle = @"OK to paste one line ending in a newline at shell prompt?";
} else {
prompt = [iTermAdvancedSettingsModel promptForPasteWhenNotAtPrompt];
theTitle = @"OK to paste one line ending in a newline?";
}
}
if (!prompt) {
return YES;
}
// Issue 5115
[iTermWarning unsilenceIdentifier:identifier ifSelectionEquals:[actions indexOfObjectIdenticalTo:cancel]];
Loading
Loading
Loading
Loading
@@ -151,6 +151,9 @@ extern NSString *const kPreferenceKeyShowFullscreenTabBar;
// settings and update the last-used version number.
+ (void)initializeUserDefaults;
 
// Last app version launched, if any.
+ (NSString *)appVersionBeforeThisLaunch;
+ (void)setObject:(id)object forKey:(NSString *)key;
+ (NSObject *)objectForKey:(NSString *)key;
 
Loading
Loading
Loading
Loading
@@ -98,7 +98,7 @@ NSString *const kPreferenceKeyFocusFollowsMouse = @"FocusFollowsMouse";
NSString *const kPreferenceKeyTripleClickSelectsFullWrappedLines = @"TripleClickSelectsFullWrappedLines";
NSString *const kPreferenceKeyDoubleClickPerformsSmartSelection = @"DoubleClickPerformsSmartSelection";
 
NSString *const kPreferenceKeyAppVersion = @"iTerm Version";
NSString *const kPreferenceKeyAppVersion = @"iTerm Version"; // Excluded from syncing
NSString *const kPreferenceAutoCommandHistory = @"AutoCommandHistory";
 
NSString *const kPreferenceKeyPasteSpecialChunkSize = @"PasteSpecialChunkSize";
Loading
Loading
@@ -120,9 +120,14 @@ NSString *const kPreferenceKeyPasteWarningNumberOfSpacesPerTab = @"PasteTabToStr
NSString *const kPreferenceKeyShowFullscreenTabBar = @"ShowFullScreenTabBar";
 
static NSMutableDictionary *gObservers;
static NSString *sPreviousVersion;
 
@implementation iTermPreferences
 
+ (NSString *)appVersionBeforeThisLaunch {
return sPreviousVersion;
}
+ (void)initializeUserDefaults {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
 
Loading
Loading
@@ -140,6 +145,7 @@ static NSMutableDictionary *gObservers;
 
// Store the current app version in prefs
NSDictionary *infoDictionary = [[NSBundle bundleForClass:[self class]] infoDictionary];
sPreviousVersion = [[userDefaults objectForKey:kPreferenceKeyAppVersion] copy];
[userDefaults setObject:infoDictionary[@"CFBundleVersion"] forKey:kPreferenceKeyAppVersion];
 
// Disable under-titlebar mirror view.
Loading
Loading
Loading
Loading
@@ -53,6 +53,7 @@ typedef void(^iTermWarningActionBlock)(iTermWarningSelection);
 
// Used to unsilence a particular selection (e.g., when you have a bug and silence the Cancel selection).
+ (void)unsilenceIdentifier:(NSString *)identifier ifSelectionEquals:(iTermWarningSelection)problemSelection;
+ (BOOL)identifierIsSilenced:(NSString *)identifier;
 
// Tests can use this to prevent warning popups.
+ (void)setWarningHandler:(id<iTermWarningHandler>)handler;
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment