Skip to content

Commit e0f5e40

Browse files
committed
Prevent the selection view from jumping around (incomplete)
1 parent 493597c commit e0f5e40

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

SCXcodeMinimap/SCMiniMapView.m

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ - (SCSelectionView *)selectionView
9292
{
9393
if (_selectionView == nil) {
9494
_selectionView = [[SCSelectionView alloc] init];
95-
[_selectionView setAutoresizingMask: NSViewMinXMargin | NSViewMaxXMargin | NSViewWidthSizable | NSViewHeightSizable | NSViewMinYMargin | NSViewMaxYMargin];
9695
//[_selectionView setShouldInverseColors:YES];
9796
[self.textView addSubview:_selectionView];
9897
}
@@ -169,7 +168,18 @@ - (void)updateTextView
169168
[mutableAttributedString release];
170169
}
171170

171+
- (void)resizeWithOldSuperviewSize:(NSSize)oldSize
172+
{
173+
[super resizeWithOldSuperviewSize:oldSize];
174+
[self updateSelectionViewAnimated:YES];
175+
}
176+
172177
- (void)updateSelectionView
178+
{
179+
[self updateSelectionViewAnimated:NO];
180+
}
181+
182+
- (void)updateSelectionViewAnimated:(BOOL)animated
173183
{
174184
if ([self isHidden]) {
175185
return;
@@ -195,7 +205,11 @@ - (void)updateSelectionView
195205
selectionViewFrame.origin.y = self.editorScrollView.contentView.bounds.origin.y * ratio;
196206
}
197207

198-
self.selectionView.frame = selectionViewFrame;
208+
if(animated) {
209+
[self.selectionView.animator setFrame:selectionViewFrame];
210+
} else {
211+
[self.selectionView setFrame:selectionViewFrame];
212+
}
199213
}
200214

201215
#pragma mark - NSLayoutManagerDelegate

0 commit comments

Comments
 (0)