Skip to content

Commit 9b9fcfa

Browse files
committed
More safety checks and cleanup.
1 parent 1e12839 commit 9b9fcfa

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

SCXcodeMinimap/SCXcodeMinimap.m

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,26 +78,11 @@ - (void)updateMiniMapTextView:(NSTextView*)textView withAttributedString:(NSAttr
7878
[mutableAttributedString enumerateAttributesInRange:NSMakeRange(0, mutableAttributedString.length) options:NSAttributedStringEnumerationReverse usingBlock:
7979
^(NSDictionary *attributes, NSRange range, BOOL *stop) {
8080

81-
NSMutableParagraphStyle *newParagraphStyle = [[attributes objectForKey:NSParagraphStyleAttributeName] mutableCopy];
82-
newParagraphStyle.minimumLineHeight *= kDefaultZoomLevel;
83-
newParagraphStyle.maximumLineHeight *= kDefaultZoomLevel;
84-
newParagraphStyle.paragraphSpacing *= kDefaultZoomLevel;
85-
newParagraphStyle.paragraphSpacingBefore *= kDefaultZoomLevel;
86-
newParagraphStyle.firstLineHeadIndent *= kDefaultZoomLevel;
87-
newParagraphStyle.headIndent *= kDefaultZoomLevel;
88-
newParagraphStyle.tailIndent *= kDefaultZoomLevel;
89-
newParagraphStyle.tighteningFactorForTruncation *= kDefaultZoomLevel;
90-
9181
NSFont *font = [attributes objectForKey:NSFontAttributeName];
9282
NSFont *newFont = [NSFont fontWithName:font.familyName size:font.pointSize * kDefaultZoomLevel];
9383

94-
NSObject *DVTFontAndColorTheme = [NSClassFromString(@"DVTFontAndColorTheme") performSelector:@selector(currentTheme)];
95-
NSColor *textColor = [DVTFontAndColorTheme performSelector:@selector(sourcePlainTextColor)];
96-
9784
NSMutableDictionary *mutableAttributes = [NSMutableDictionary dictionaryWithDictionary:attributes];
98-
[mutableAttributes setObject:newParagraphStyle forKey:NSParagraphStyleAttributeName];
9985
[mutableAttributes setObject:newFont forKey:NSFontAttributeName];
100-
[mutableAttributes setObject:textColor forKey:NSForegroundColorAttributeName];
10186
[mutableAttributedString setAttributes:mutableAttributes range:range];
10287
}];
10388

@@ -194,9 +179,18 @@ - (void)onDidFinishSetup:(NSNotification*)sender
194179
[miniMapScrollView setDocumentView:miniMapTextView];
195180
[miniMapTextView release];
196181

197-
NSObject *DVTFontAndColorTheme = [NSClassFromString(@"DVTFontAndColorTheme") performSelector:@selector(currentTheme)];
198-
NSColor *backgroundColor = [DVTFontAndColorTheme performSelector:@selector(sourceTextBackgroundColor)];
199-
[miniMapTextView setBackgroundColor:[backgroundColor shadowWithLevel:kDefaultShadowLevel]];
182+
NSColor *miniMapBackgroundColor = [NSColor clearColor];
183+
Class DVTFontAndColorThemeClass = NSClassFromString(@"DVTFontAndColorTheme");
184+
if([DVTFontAndColorThemeClass respondsToSelector:@selector(currentTheme)]) {
185+
NSObject *theme = [DVTFontAndColorThemeClass performSelector:@selector(currentTheme)];
186+
187+
if([theme respondsToSelector:@selector(sourceTextBackgroundColor)]) {
188+
miniMapBackgroundColor = [theme performSelector:@selector(sourceTextBackgroundColor)];
189+
190+
}
191+
}
192+
193+
[miniMapTextView setBackgroundColor:[miniMapBackgroundColor shadowWithLevel:kDefaultShadowLevel]];
200194

201195
objc_setAssociatedObject(editorDocument, &kKeyMiniMapTextView, miniMapTextView, OBJC_ASSOCIATION_ASSIGN);
202196
objc_setAssociatedObject(editorScrollView, &kKeyMiniMapTextView, miniMapTextView, OBJC_ASSOCIATION_ASSIGN);

0 commit comments

Comments
 (0)