1313
1414@interface SCMiniMapView ()
1515
16- @property (nonatomic , retain ) NSColor *backgroundColor;
17- @property (nonatomic , retain ) NSFont *font;
16+ @property (nonatomic , strong ) NSColor *backgroundColor;
17+ @property (nonatomic , strong ) NSFont *font;
1818
1919@end
2020
@@ -54,12 +54,6 @@ - (id)initWithFrame:(NSRect)frame
5454- (void )dealloc
5555{
5656 [[NSNotificationCenter defaultCenter ] removeObserver: self ];
57-
58- [_selectionView release ];
59- [_textView release ];
60- [_backgroundColor release ];
61- [_font release ];
62- [super dealloc ];
6357}
6458
6559#pragma mark - Lazy Initialization
@@ -73,7 +67,7 @@ - (NSTextView *)textView
7367 [_textView.textContainer setLineFragmentPadding: 0 .0f ];
7468
7569 [_textView.layoutManager setDelegate: self ];
76-
70+
7771 [_textView setAllowsUndo: NO ];
7872 [_textView setAllowsImageEditing: NO ];
7973 [_textView setAutomaticDashSubstitutionEnabled: NO ];
@@ -151,9 +145,9 @@ - (void)show
151145{
152146 self.hidden = NO ;
153147
154- NSRect frame = self.editorScrollView .frame ;
155- frame .size .width = self.editorScrollView .superview .frame .size .width - self.bounds .size .width ;
156- self.editorScrollView .frame = frame ;
148+ NSRect editorTextViewFrame = self.editorScrollView .frame ;
149+ editorTextViewFrame .size .width = self.editorScrollView .superview .frame .size .width - self.bounds .size .width ;
150+ self.editorScrollView .frame = editorTextViewFrame ;
157151
158152 [self updateTextView ];
159153 [self updateSelectionView ];
@@ -163,21 +157,20 @@ - (void)hide
163157{
164158 self.hidden = YES ;
165159
166- NSRect frame = self.editorScrollView .frame ;
167- frame .size .width = self.editorScrollView .superview .frame .size .width ;
168- self.editorScrollView .frame = frame ;
160+ NSRect editorTextViewFrame = self.editorScrollView .frame ;
161+ editorTextViewFrame .size .width = self.editorScrollView .superview .frame .size .width ;
162+ self.editorScrollView .frame = editorTextViewFrame ;
169163}
170164
171165#pragma mark - Updating
172166
173167- (void )updateTheme
174168{
175169 [self setFont: nil ];
176- [self updateTextView ];
177170
178171 [self setBackgroundColor: nil ];
179172 [self .selectionView setSelectionColor: nil ];
180- [self .textView setBackgroundColor: self .backgroundColor];
173+ [self .textView setBackgroundColor: self .backgroundColor];
181174}
182175
183176- (void )updateTextView
@@ -204,7 +197,6 @@ - (void)updateTextView
204197
205198 [mutableAttributedString setAttributes: @{NSFontAttributeName : self.font , NSParagraphStyleAttributeName : style} range: NSMakeRange (0 , mutableAttributedString.length)];
206199 [self .textView.textStorage setAttributedString: mutableAttributedString];
207- [mutableAttributedString release ];
208200}
209201
210202- (void )resizeWithOldSuperviewSize : (NSSize )oldSize
@@ -238,15 +230,20 @@ - (void)updateSelectionView
238230 ratio = (textHeight - self.selectionView .bounds .size .height ) / editorContentHeight;
239231 selectionViewFrame.origin .y = self.editorScrollView .contentView .bounds .origin .y * ratio;
240232 }
241-
233+
242234 [self .selectionView setFrame: selectionViewFrame];
243235}
244236
245237#pragma mark - NSLayoutManagerDelegate
246238
247239- (void )layoutManager : (NSLayoutManager *)layoutManager didCompleteLayoutForTextContainer : (NSTextContainer *)textContainer atEnd : (BOOL )layoutFinished
248240{
249- if (layoutFinished) {
241+ if ([layoutManager isEqual: self .editorTextView.layoutManager]) {
242+ [(id <NSLayoutManagerDelegate >)self .editorTextView layoutManager: layoutManager
243+ didCompleteLayoutForTextContainer: textContainer
244+ atEnd: layoutFinished];
245+ }
246+ else if (layoutFinished) {
250247 [self updateSelectionView ];
251248 }
252249}
0 commit comments