Skip to content

Commit 2f3dbfb

Browse files
committed
Considering text container insets in offset calculations, moved size menu item title to its own constant.
1 parent 1699c5a commit 2f3dbfb

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

SCXcodeMinimap/SCXcodeMinimap.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
NSString *const kShowMinimapMenuItemTitle = @"Show Minimap";
5454
NSString *const kHideMinimapMenuItemTitle = @"Hide Minimap";
5555

56+
NSString *const kSizeMenuItemTitle = @"Size";
57+
5658
NSString *const kHighlightBreakpointsMenuItemTitle = @"Highlight breakpoints";
5759
NSString *const kHighlightIssuesMenuItemTitle = @"Highlight issues";
5860
NSString *const kHighlightSelectedSymbolMenuItemTitle = @"Highlight selected symbol";
@@ -131,7 +133,7 @@ - (void)createMenuItem
131133
[sizeView setAutoresizingMask:NSViewMinXMargin | NSViewMaxXMargin | NSViewMinYMargin | NSViewMaxYMargin];
132134

133135
NSTextField *sizeViewTitleLabel = [[NSTextField alloc] initWithFrame:NSMakeRect(18.0f, 0.0f, 50.0f, 20.0f)];
134-
[sizeViewTitleLabel setStringValue:@"Size"];
136+
[sizeViewTitleLabel setStringValue:kSizeMenuItemTitle];
135137
[sizeViewTitleLabel setFont:[NSFont systemFontOfSize:14]];
136138
[sizeViewTitleLabel setBezeled:NO];
137139
[sizeViewTitleLabel setDrawsBackground:NO];

SCXcodeMinimap/SCXcodeMinimapView.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -529,15 +529,14 @@ - (void)updateOffset
529529
return;
530530
}
531531

532-
CGFloat ratio = (adjustedMinimapContentHeight / adjustedEditorContentHeight) * (1 / self.scrollView.magnification);
533-
CGPoint offset = NSMakePoint(self.editor.scrollView.contentView.bounds.origin.x,
534-
MAX(0, floorf(self.editor.scrollView.contentView.bounds.origin.y * ratio * self.scrollView.magnification)));
535-
536-
[self.scrollView.documentView scrollPoint:offset];
532+
CGFloat editorYOffset = CGRectGetMinY(self.editor.scrollView.contentView.bounds) + ABS(CGRectGetMinY(self.editorTextView.frame));
537533

534+
CGFloat ratio = (adjustedMinimapContentHeight / adjustedEditorContentHeight) * (1 / self.scrollView.magnification);
535+
[self.scrollView.documentView scrollPoint:NSMakePoint(self.editor.scrollView.contentView.bounds.origin.x,
536+
MAX(0, floorf(editorYOffset * ratio * self.scrollView.magnification)))];
538537

539538
ratio = (editorTextHeight - self.selectionView.bounds.size.height) / adjustedEditorContentHeight;
540-
selectionViewFrame.origin.y = self.editor.scrollView.contentView.bounds.origin.y * ratio;
539+
selectionViewFrame.origin.y = editorYOffset * ratio;
541540

542541
[self.selectionView setFrame:selectionViewFrame];
543542
}
@@ -569,6 +568,7 @@ - (void)handleMouseEvent:(NSEvent *)theEvent
569568

570569
NSRect neededRect = [self.editorTextView.layoutManager boundingRectForGlyphRange:activeRange inTextContainer:self.editorTextView.textContainer];
571570
neededRect.origin.y = MAX(0, neededRect.origin.y - CGRectGetHeight(self.editor.containerView.bounds) / 2);
571+
neededRect.origin.y += CGRectGetMinY(self.editorTextView.frame);
572572

573573
BOOL shouldAnimateContentOffset = (theEvent.type != NSLeftMouseDragged);
574574

0 commit comments

Comments
 (0)