mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-170583 "Reformat Code" leads to weird scrolling in the editor window
ensuring all possible cases are covered
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -129,7 +129,7 @@ public class ReformatCodeProcessor extends AbstractLayoutCodeProcessor {
|
||||
CodeStyleManager.getInstance(myProject).reformatText(file, ranges);
|
||||
}
|
||||
|
||||
caretPositionKeeper.restoreOriginalLocation();
|
||||
caretPositionKeeper.restoreOriginalLocation(true);
|
||||
|
||||
if (before != null) {
|
||||
prepareUserNotificationMessage(document, before);
|
||||
|
||||
+1
-1
@@ -139,7 +139,7 @@ public class ParameterHintsPassFactory extends AbstractProjectComponent implemen
|
||||
List<Inlay> hints = getParameterHints(manager);
|
||||
ParameterHintsUpdater updater = new ParameterHintsUpdater(myEditor, hints, myHints, myShowOnlyIfExistedBeforeHints);
|
||||
updater.update();
|
||||
keeper.restoreOriginalLocation();
|
||||
keeper.restoreOriginalLocation(false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -49,7 +49,7 @@ public class CaretVisualPositionKeeper {
|
||||
}
|
||||
}
|
||||
|
||||
public void restoreOriginalLocation() {
|
||||
public void restoreOriginalLocation(boolean stopAnimation) {
|
||||
for (Map.Entry<Editor, Integer> e : myCaretRelativeVerticalPositions.entrySet()) {
|
||||
Editor editor = e.getKey();
|
||||
int relativePosition = e.getValue();
|
||||
@@ -58,10 +58,10 @@ public class CaretVisualPositionKeeper {
|
||||
ScrollingModel scrollingModel = editor.getScrollingModel();
|
||||
Rectangle targetArea = scrollingModel.getVisibleAreaOnScrollingFinished();
|
||||
// when animated scrolling is in progress, we'll not stop it immediately
|
||||
boolean useAnimation = !targetArea.equals(scrollingModel.getVisibleArea());
|
||||
if (!useAnimation) scrollingModel.disableAnimation();
|
||||
boolean disableAnimation = targetArea.equals(scrollingModel.getVisibleArea()) || stopAnimation;
|
||||
if (disableAnimation) scrollingModel.disableAnimation();
|
||||
scrollingModel.scroll(targetArea.x, scrollOffset);
|
||||
if (!useAnimation) scrollingModel.enableAnimation();
|
||||
if (disableAnimation) scrollingModel.enableAnimation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user