diff: do not scroll to change, if visible position was changed during loading

This commit is contained in:
Aleksey Pivovarov
2015-03-03 19:26:42 +03:00
parent 964cf5c02d
commit 56ba3ff8f9
3 changed files with 12 additions and 0 deletions
@@ -463,6 +463,7 @@ public abstract class ThreesideTextDiffViewer extends TextDiffViewerBase {
}
public void onRediff() {
if (DiffUtil.wasScrolled(getEditors())) myShouldScroll = false;
if (myShouldScroll && myScrollToChange != null) {
myShouldScroll = !doScrollToChange(myScrollToChange);
}
@@ -495,6 +495,7 @@ public abstract class TwosideTextDiffViewer extends TextDiffViewerBase {
}
public void onRediff() {
if (DiffUtil.wasScrolled(getEditors())) myShouldScroll = false;
if (myShouldScroll && myScrollToChange != null) {
myShouldScroll = !doScrollToChange(myScrollToChange);
}
@@ -249,6 +249,16 @@ public class DiffUtil {
return carets;
}
public static boolean wasScrolled(@NotNull List<? extends Editor> editors) {
for (Editor editor : editors) {
if (editor == null) continue;
if (editor.getCaretModel().getOffset() != 0) return true;
if (editor.getScrollingModel().getVerticalScrollOffset() != 0) return true;
if (editor.getScrollingModel().getHorizontalScrollOffset() != 0) return true;
}
return false;
}
public static class EditorsVisiblePositions {
public static final Key<EditorsVisiblePositions> KEY = Key.create("Diff.EditorsVisiblePositions");