mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
diff: do not scroll to change, if visible position was changed during loading
This commit is contained in:
+1
@@ -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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user