mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
avoid caret visual position changes on parameter hints adding (IDEA-115424)
fix side effect of horizontal scrolling not working correctly for Home/End on a long line
This commit is contained in:
@@ -43,6 +43,7 @@ public interface ScrollingModel {
|
||||
|
||||
void scrollVertically(int scrollOffset);
|
||||
void scrollHorizontally(int scrollOffset);
|
||||
void scroll(int horizontalOffset, int verticalOffset);
|
||||
|
||||
void addVisibleAreaListener(@NotNull VisibleAreaListener listener);
|
||||
void removeVisibleAreaListener(@NotNull VisibleAreaListener listener);
|
||||
|
||||
+3
-2
@@ -56,10 +56,11 @@ public class CaretVisualPositionKeeper {
|
||||
Point caretLocation = editor.visualPositionToXY(editor.getCaretModel().getVisualPosition());
|
||||
int scrollOffset = caretLocation.y - relativePosition;
|
||||
ScrollingModel scrollingModel = editor.getScrollingModel();
|
||||
Rectangle targetArea = scrollingModel.getVisibleAreaOnScrollingFinished();
|
||||
// when animated scrolling is in progress, we'll not stop it immediately
|
||||
boolean useAnimation = !scrollingModel.getVisibleAreaOnScrollingFinished().equals(scrollingModel.getVisibleArea());
|
||||
boolean useAnimation = !targetArea.equals(scrollingModel.getVisibleArea());
|
||||
if (!useAnimation) scrollingModel.disableAnimation();
|
||||
scrollingModel.scrollVertically(scrollOffset);
|
||||
scrollingModel.scroll(targetArea.x, scrollOffset);
|
||||
if (!useAnimation) scrollingModel.enableAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1155,7 +1155,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
Point shiftedZoomCenterAbsolute = logicalPositionToXY(zoomCenterLogical);
|
||||
myScrollingModel.disableAnimation();
|
||||
try {
|
||||
myScrollingModel.scrollToOffsets(visibleArea.x == 0 ? 0 : shiftedZoomCenterAbsolute.x - zoomCenterRelative.x, // stick to left border if it's visible
|
||||
myScrollingModel.scroll(visibleArea.x == 0 ? 0 : shiftedZoomCenterAbsolute.x - zoomCenterRelative.x, // stick to left border if it's visible
|
||||
shiftedZoomCenterAbsolute.y - zoomCenterRelative.y + (intraLineOffset * getLineHeight() + oldLineHeight / 2) / oldLineHeight);
|
||||
} finally {
|
||||
myScrollingModel.enableAnimation();
|
||||
|
||||
@@ -114,7 +114,7 @@ public class ScrollingModelImpl implements ScrollingModelEx {
|
||||
final int currentOffset = getVerticalScrollOffset();
|
||||
int offsetToUse = Math.min(minPreferredY, currentOffset);
|
||||
if (offsetToUse != currentOffset) {
|
||||
scrollToOffsets(getHorizontalScrollOffset(), offsetToUse);
|
||||
scroll(getHorizontalScrollOffset(), offsetToUse);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -159,7 +159,7 @@ public class ScrollingModelImpl implements ScrollingModelEx {
|
||||
AnimatedScrollingRunnable canceledThread = cancelAnimatedScrolling(false);
|
||||
Rectangle viewRect = canceledThread != null ? canceledThread.getTargetVisibleArea() : getVisibleArea();
|
||||
Point p = calcOffsetsToScroll(targetLocation, scrollType, viewRect);
|
||||
scrollToOffsets(p.x, p.y);
|
||||
scroll(p.x, p.y);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -305,7 +305,7 @@ public class ScrollingModelImpl implements ScrollingModelEx {
|
||||
|
||||
@Override
|
||||
public void scrollVertically(int scrollOffset) {
|
||||
scrollToOffsets(getHorizontalScrollOffset(), scrollOffset);
|
||||
scroll(getHorizontalScrollOffset(), scrollOffset);
|
||||
}
|
||||
|
||||
private void _scrollVertically(int scrollOffset) {
|
||||
@@ -319,7 +319,7 @@ public class ScrollingModelImpl implements ScrollingModelEx {
|
||||
|
||||
@Override
|
||||
public void scrollHorizontally(int scrollOffset) {
|
||||
scrollToOffsets(scrollOffset, getVerticalScrollOffset());
|
||||
scroll(scrollOffset, getVerticalScrollOffset());
|
||||
}
|
||||
|
||||
private void _scrollHorizontally(int scrollOffset) {
|
||||
@@ -330,7 +330,8 @@ public class ScrollingModelImpl implements ScrollingModelEx {
|
||||
scrollbar.setValue(scrollOffset);
|
||||
}
|
||||
|
||||
void scrollToOffsets(int hOffset, int vOffset) {
|
||||
@Override
|
||||
public void scroll(int hOffset, int vOffset) {
|
||||
if (myAccumulateViewportChanges) {
|
||||
myAccumulatedXOffset = hOffset;
|
||||
myAccumulatedYOffset = vOffset;
|
||||
@@ -431,7 +432,7 @@ public class ScrollingModelImpl implements ScrollingModelEx {
|
||||
public void flushViewportChanges() {
|
||||
myAccumulateViewportChanges = false;
|
||||
if (myAccumulatedXOffset >= 0 && myAccumulatedYOffset >= 0) {
|
||||
scrollToOffsets(myAccumulatedXOffset, myAccumulatedYOffset);
|
||||
scroll(myAccumulatedXOffset, myAccumulatedYOffset);
|
||||
myAccumulatedXOffset = myAccumulatedYOffset = -1;
|
||||
cancelAnimatedScrolling(true);
|
||||
}
|
||||
|
||||
+5
@@ -97,6 +97,11 @@ public class TextComponentScrollingModel implements ScrollingModel {
|
||||
throw new UnsupportedOperationException("Not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scroll(int horizontalOffset, int verticalOffset) {
|
||||
throw new UnsupportedOperationException("Not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addVisibleAreaListener(@NotNull final VisibleAreaListener listener) {
|
||||
throw new UnsupportedOperationException("Not implemented");
|
||||
|
||||
Reference in New Issue
Block a user