IDEA-118419 Keep caret on the screen while changing font size

taking into account intra-line mouse position to avoid lines 'jumping'
This commit is contained in:
Dmitry Batrak
2013-12-24 10:41:24 +04:00
parent e23693cb2e
commit 00dda2f265
@@ -914,6 +914,8 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
Point zoomCenterRelative = zoomCenter == null ? new Point() : zoomCenter;
Point zoomCenterAbsolute = new Point(visibleArea.x + zoomCenterRelative.x, visibleArea.y + zoomCenterRelative.y);
LogicalPosition zoomCenterLogical = xyToLogicalPosition(zoomCenterAbsolute).withoutVisualPositionInfo();
int oldLineHeight = getLineHeight();
int intraLineOffset = zoomCenterAbsolute.y % oldLineHeight;
myScheme.setEditorFontSize(fontSize);
myPropertyChangeSupport.firePropertyChange(PROP_FONT_SIZE, oldFontSize, fontSize);
@@ -925,7 +927,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
myScrollingModel.disableAnimation();
try {
myScrollingModel.scrollToOffsets(visibleArea.x == 0 ? 0 : shiftedZoomCenterAbsolute.x - zoomCenterRelative.x, // stick to left border if it's visible
shiftedZoomCenterAbsolute.y - zoomCenterRelative.y);
shiftedZoomCenterAbsolute.y - zoomCenterRelative.y + (intraLineOffset * getLineHeight() + oldLineHeight / 2) / oldLineHeight);
} finally {
myScrollingModel.enableAnimation();
}