adium 2797:5dd8e46268e8: Only validate "Restore default formatti...

commits at adium.im commits at adium.im
Wed Oct 28 15:09:44 UTC 2009


details:	http://hg.adium.im/adium/rev/5dd8e46268e8
revision:	2797:5dd8e46268e8
author:		Zachary West <zacw at adium.im>
date:		Wed Oct 28 11:09:20 2009 -0400

Only validate "Restore default formatting" if the attributes our defaults specify are modified in the current typing attributes. There's a whole mess of other attributes that the NSTextView may have, very few of which are specified as defaults.

Refs #13154.

diffs (21 lines):

diff -r 341c96961054 -r 5dd8e46268e8 Source/AdiumFormatting.m
--- a/Source/AdiumFormatting.m	Wed Oct 28 10:49:09 2009 -0400
+++ b/Source/AdiumFormatting.m	Wed Oct 28 11:09:20 2009 -0400
@@ -128,8 +128,15 @@
 {
 	NSResponder *responder = [[NSApp mainWindow] firstResponder];
 
-	return (([responder isKindOfClass:[NSTextView class]]) &&
-			(![[(NSTextView *)responder typingAttributes] isEqualToDictionary:[self defaultFormattingAttributes]]));
+	if (![responder isKindOfClass:[NSTextView class]]) {
+		return NO;
+	}
+	
+	NSDictionary *defaultAttributes = [self defaultFormattingAttributes];
+	NSSet *defaultAttributeKeysSet = [NSSet setWithArray:[defaultAttributes allKeys]];
+	NSDictionary *typingAttributes = [[(NSTextView *)responder typingAttributes] dictionaryWithIntersectionWithSetOfKeys:defaultAttributeKeysSet];
+	
+	return (![typingAttributes isEqualToDictionary:defaultAttributes]);
 }
 
 @end




More information about the commits mailing list