@@ -18,7 +18,7 @@ @interface SCMiniMapView () <NSLayoutManagerDelegate>
1818
1919@property (nonatomic , strong ) NSColor *backgroundColor;
2020@property (nonatomic , strong ) NSFont *font;
21- @property (nonatomic , readwrite ) NSInteger lastCalculatedLines ;
21+ @property (nonatomic , assign ) NSInteger numberOfLines ;
2222
2323@end
2424
@@ -187,15 +187,12 @@ - (void)updateTextView
187187 }
188188
189189 typeof (self) __weak weakSelf = self;
190- NSOperationQueue *background = [[NSOperationQueue alloc ] init ];
191-
192- // Run the attributed strings operation on a background thread
193- [background addOperationWithBlock: ^{
190+ dispatch_async (dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0 ), ^{
194191 NSMutableAttributedString *mutableAttributedString = [self .editorTextView.textStorage mutableCopy ];
195192
196193 if (mutableAttributedString.length == 0 ) {
197194 // Nothing to do here.
198- weakSelf.lastCalculatedLines = 0 ;
195+ weakSelf.numberOfLines = 0 ;
199196 return ;
200197 }
201198
@@ -216,27 +213,25 @@ - (void)updateTextView
216213 [mutableAttributedString setAttributes: @{NSFontAttributeName : weakSelf.font , NSParagraphStyleAttributeName : style} range: NSMakeRange (0 , mutableAttributedString.length)];
217214
218215 // Send the text storage update off to the main thread
219- [[ NSOperationQueue mainQueue ] addOperationWithBlock: ^{
216+ dispatch_async ( dispatch_get_main_queue (), ^{
220217 [weakSelf.textView.textStorage setAttributedString: mutableAttributedString];
221218 [weakSelf updateSelectionView ];
222- }] ;
219+ }) ;
223220
224- // Now that we've sent that off, let's see how many lines we have while
225- // we're in here:
221+ // Calculate the total number of lines
226222 [weakSelf calculateLinesFromString: [mutableAttributedString string ]];
227- }] ;
223+ }) ;
228224}
229225
230226- (void )calculateLinesFromString : (NSString *)string
231227{
232- NSUInteger stringLength = [string length ];
233- NSInteger numberOfLines = 0 ;
234- for (NSInteger index = 0 ; index < stringLength; numberOfLines++) {
228+ NSInteger count = 0 ;
229+ for (NSInteger index = 0 ; index < [string length ]; count++) {
235230 index = NSMaxRange ([string lineRangeForRange: NSMakeRange (index, 0 )]);
236231 }
237232
238233 // Cache the last calculated lines so we can figure out how long we should take to render this minimap.
239- self.lastCalculatedLines = numberOfLines ;
234+ self.numberOfLines = count ;
240235}
241236
242237- (void )resizeWithOldSuperviewSize : (NSSize )oldSize
0 commit comments