IDEA-154894 [api] ability for disabling scrolling on document changes into Editor

This commit is contained in:
Dmitry Batrak
2016-04-19 12:10:59 +03:00
parent 87e2c1f365
commit 0e85fa0ea4
@@ -132,6 +132,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
private static final Key<JComponent> PERMANENT_HEADER = Key.create("PERMANENT_HEADER");
public static final Key<Boolean> DO_DOCUMENT_UPDATE_TEST = Key.create("DoDocumentUpdateTest");
public static final Key<Boolean> FORCED_SOFT_WRAPS = Key.create("forced.soft.wraps");
public static final Key<Boolean> DISABLE_CARET_POSITION_KEEPING = Key.create("editor.disable.caret.position.keeping");
private static final boolean HONOR_CAMEL_HUMPS_ON_TRIPLE_CLICK = Boolean.parseBoolean(System.getProperty("idea.honor.camel.humps.on.triple.click"));
private static final Key<BufferedImage> BUFFER = Key.create("buffer");
private static final Color CURSOR_FOREGROUND_LIGHT = Gray._255;
@@ -1894,7 +1895,9 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
repaintToScreenBottom(0);
updateCaretCursor();
restoreCaretRelativePosition();
if (!Boolean.TRUE.equals(getUserData(DISABLE_CARET_POSITION_KEEPING))) {
restoreCaretRelativePosition();
}
}
private void beforeChangedUpdate(@NotNull DocumentEvent e) {
@@ -1962,7 +1965,8 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
repaintLines(startLine, endLine);
}
if (getCaretModel().getOffset() < e.getOffset() || getCaretModel().getOffset() > e.getOffset() + e.getNewLength()){
if (!Boolean.TRUE.equals(getUserData(DISABLE_CARET_POSITION_KEEPING)) &&
(getCaretModel().getOffset() < e.getOffset() || getCaretModel().getOffset() > e.getOffset() + e.getNewLength())) {
restoreCaretRelativePosition();
}
}