Skip to content

Commit 2521609

Browse files
Better line length calculation, better selection view updating.
1 parent 1a2221f commit 2521609

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

SCXcodeMinimap/SCMiniMapView.m

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ - (void)updateTextView
218218
//Send the text storage update off to the main thread
219219
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
220220
[weakSelf.textView.textStorage setAttributedString:mutableAttributedString];
221-
221+
[weakSelf updateSelectionView];
222222
}];
223223

224224
//Now that we've sent that off, let's see how many lines we have while
@@ -229,10 +229,14 @@ - (void)updateTextView
229229

230230
- (void)calculateLinesFromString:(NSString *)string
231231
{
232-
NSArray *lines = [string componentsSeparatedByString:@"\n"];
232+
NSUInteger stringLength = [string length];
233+
NSInteger numberOfLines = 0;
234+
for (NSInteger index = 0; index < stringLength; numberOfLines++) {
235+
index = NSMaxRange([string lineRangeForRange:NSMakeRange(index, 0)]);
236+
}
233237

234238
//Cache the last calculated lines so we can figure out how long we should take to render this minimap.
235-
self.lastCalculatedLines = lines.count;
239+
self.lastCalculatedLines = numberOfLines;
236240
}
237241

238242
- (void)resizeWithOldSuperviewSize:(NSSize)oldSize

0 commit comments

Comments
 (0)