@@ -22,16 +22,15 @@ @implementation SCMiniMapView
2222
2323- (id )initWithFrame : (NSRect )frame
2424{
25- self = [super initWithFrame: frame];
26- if (self)
25+ if (self = [super initWithFrame: frame])
2726 {
2827 /* Configure ScrollView */
2928 [self setWantsLayer: YES ];
3029 [self setAutoresizingMask: NSViewMinXMargin | NSViewHeightSizable];
3130 [self setDrawsBackground: NO ];
3231 [self setHorizontalScrollElasticity: NSScrollElasticityNone];
3332 [self setVerticalScrollElasticity: NSScrollElasticityNone];
34-
33+
3534 /* Subscribe to show/hide notifications */
3635 [[NSNotificationCenter defaultCenter ] addObserver: self
3736 selector: @selector (show )
@@ -65,7 +64,7 @@ - (NSTextView *)textView
6564 [_textView setBackgroundColor: [NSColor clearColor ]];
6665
6766 [_textView.textContainer setLineFragmentPadding: 0 .0f ];
68-
67+
6968 [_textView.layoutManager setDelegate: self ];
7069
7170 [_textView setAllowsUndo: NO ];
@@ -78,7 +77,7 @@ - (NSTextView *)textView
7877 [_textView setAutomaticTextReplacementEnabled: NO ];
7978 [_textView setContinuousSpellCheckingEnabled: NO ];
8079 [_textView setDisplaysLinkToolTips: NO ];
81- [_textView setEditable: NO ];
80+ [_textView setEditable: NO ];
8281 [_textView setRichText: YES ];
8382 [_textView setSelectable: NO ];
8483
@@ -103,7 +102,7 @@ - (SCSelectionView *)selectionView
103102
104103- (NSFont *)font
105104{
106- if (_font == nil ) {
105+ if (_font == nil ) {
107106 _font = [NSFont fontWithName: @" Menlo" size: 11 * kDefaultZoomLevel ];
108107
109108 Class DVTFontAndColorThemeClass = NSClassFromString (@" DVTFontAndColorTheme" );
@@ -135,7 +134,7 @@ - (NSColor *)backgroundColor
135134 }
136135 }
137136 }
138-
137+
139138 return _backgroundColor;
140139}
141140
@@ -144,7 +143,7 @@ - (NSColor *)backgroundColor
144143- (void )show
145144{
146145 self.hidden = NO ;
147-
146+
148147 NSRect editorTextViewFrame = self.editorScrollView .frame ;
149148 editorTextViewFrame.size .width = self.editorScrollView .superview .frame .size .width - self.bounds .size .width ;
150149 self.editorScrollView .frame = editorTextViewFrame;
@@ -156,7 +155,7 @@ - (void)show
156155- (void )hide
157156{
158157 self.hidden = YES ;
159-
158+
160159 NSRect editorTextViewFrame = self.editorScrollView .frame ;
161160 editorTextViewFrame.size .width = self.editorScrollView .superview .frame .size .width ;
162161 self.editorScrollView .frame = editorTextViewFrame;
@@ -178,24 +177,26 @@ - (void)updateTextView
178177 if ([self isHidden ]) {
179178 return ;
180179 }
181-
180+
182181 NSMutableAttributedString *mutableAttributedString = [self .editorTextView.textStorage mutableCopy ];
183-
182+
184183 if (mutableAttributedString == nil ) {
185184 return ;
186185 }
187186
188- __block NSMutableParagraphStyle *style;
189187 [mutableAttributedString enumerateAttribute: NSParagraphStyleAttributeName
190188 inRange: NSMakeRange (0 , mutableAttributedString.length)
191189 options: 0
192190 usingBlock: ^(id value, NSRange range, BOOL *stop) {
193- style = [value mutableCopy ];
191+
192+ NSMutableParagraphStyle *style = [value mutableCopy ];
193+ [style setTabStops: @[]];
194+ [style setDefaultTabInterval: style.defaultTabInterval * kDefaultZoomLevel ];
195+ [mutableAttributedString addAttributes: @{NSParagraphStyleAttributeName :style} range: range];
194196 }];
195- [style setTabStops: @[]];
196- [style setDefaultTabInterval: style.defaultTabInterval * kDefaultZoomLevel ];
197-
198- [mutableAttributedString setAttributes: @{NSFontAttributeName : self.font , NSParagraphStyleAttributeName : style} range: NSMakeRange (0 , mutableAttributedString.length)];
197+
198+ [mutableAttributedString setAttributes: @{NSFontAttributeName : self.font } range: NSMakeRange (0 , mutableAttributedString.length)];
199+
199200 [self .textView.textStorage setAttributedString: mutableAttributedString];
200201}
201202
@@ -210,22 +211,22 @@ - (void)updateSelectionView
210211 if ([self isHidden ]) {
211212 return ;
212213 }
213-
214+
214215 NSRect selectionViewFrame = NSMakeRect (0 ,
215216 0 ,
216217 self.bounds .size .width ,
217218 self.editorScrollView .visibleRect .size .height * kDefaultZoomLevel );
218-
219-
219+
220+
220221 CGFloat editorContentHeight = [self .editorScrollView.documentView frame ].size .height - self.editorScrollView .bounds .size .height ;
221-
222+
222223 if (editorContentHeight == 0 ) {
223224 selectionViewFrame.origin .y = 0 ;
224225 }
225226 else {
226227 CGFloat ratio = ([self .documentView frame ].size .height - self.bounds .size .height ) / editorContentHeight;
227228 [self .contentView scrollToPoint: NSMakePoint (0 , floorf (self .editorScrollView.contentView.bounds.origin.y * ratio))];
228-
229+
229230 CGFloat textHeight = [self .textView.layoutManager usedRectForTextContainer: self .textView.textContainer].size .height ;
230231 ratio = (textHeight - self.selectionView .bounds .size .height ) / editorContentHeight;
231232 selectionViewFrame.origin .y = self.editorScrollView .contentView .bounds .origin .y * ratio;
@@ -300,11 +301,11 @@ - (void)goAtRelativePosition:(NSPoint)position
300301 CGFloat documentHeight = [self .editorScrollView.documentView frame ].size .height ;
301302 CGSize boundsSize = self.editorScrollView .bounds .size ;
302303 CGFloat maxOffset = documentHeight - boundsSize.height ;
303-
304+
304305 CGFloat offset = floor (documentHeight * position.y - boundsSize.height /2 );
305-
306+
306307 offset = MIN (MAX (0 , offset), maxOffset);
307-
308+
308309 [self .editorTextView scrollRectToVisible: NSMakeRect (0 , offset, boundsSize.width, boundsSize.height)];
309310}
310311
0 commit comments