Skip to content

Commit 3c797c7

Browse files
committed
Attempt at fixing #52
- forcing the layoutManager to layout the whole text container - reusing the same height in both the minimap and the editor textView
1 parent b45a655 commit 3c797c7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

SCXcodeMinimap/SCXcodeMinimapView.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,11 +393,11 @@ - (void)updateOffset
393393
return;
394394
}
395395

396-
CGFloat editorTextHeight = CGRectGetHeight([self.editorTextView.layoutManager usedRectForTextContainer:self.editorTextView.textContainer]);
397-
CGFloat minimapTextHeight = CGRectGetHeight([self.textView.layoutManager usedRectForTextContainer:self.textView.textContainer]);
396+
[self.editorTextView.layoutManager ensureLayoutForTextContainer:self.editorTextView.textContainer];
398397

398+
CGFloat editorTextHeight = CGRectGetHeight([self.editorTextView.layoutManager usedRectForTextContainer:self.editorTextView.textContainer]);
399399
CGFloat adjustedEditorContentHeight = editorTextHeight - CGRectGetHeight(self.editor.scrollView.bounds);
400-
CGFloat adjustedMinimapContentHeight = minimapTextHeight - (CGRectGetHeight(self.scrollView.bounds) * (1 / self.scrollView.magnification));
400+
CGFloat adjustedMinimapContentHeight = editorTextHeight - (CGRectGetHeight(self.scrollView.bounds) * (1 / self.scrollView.magnification));
401401

402402
NSRect selectionViewFrame = NSMakeRect(0, 0, self.textView.bounds.size.width * (1 / self.scrollView.magnification), self.editor.scrollView.visibleRect.size.height);
403403

@@ -413,7 +413,7 @@ - (void)updateOffset
413413
[self.scrollView.documentView scrollPoint:offset];
414414

415415

416-
ratio = (minimapTextHeight - self.selectionView.bounds.size.height) / adjustedEditorContentHeight;
416+
ratio = (editorTextHeight - self.selectionView.bounds.size.height) / adjustedEditorContentHeight;
417417
selectionViewFrame.origin.y = self.editor.scrollView.contentView.bounds.origin.y * ratio;
418418

419419
[self.selectionView setFrame:selectionViewFrame];

0 commit comments

Comments
 (0)