Zero-latency typing: handle carets in "virtual space"

This commit is contained in:
Pavel Fatin
2015-09-10 16:43:33 +02:00
parent 1adcddbf0a
commit 7f1562ec23
@@ -2186,6 +2186,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
return myDocument instanceof DocumentImpl &&
myHighlighter instanceof LexerEditorHighlighter &&
!mySelectionModel.hasSelection() &&
arePositionsWithinDocument(myCaretModel.getAllCarets()) &&
areVisualLinesUnique(myCaretModel.getAllCarets()) &&
!isInplaceRenamerActive() &&
!KEY_CHARS_TO_SKIP.contains(c);
@@ -2203,6 +2204,16 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
return true;
}
// Checks whether all the carets are within document or some of them are in a so called "virtual space".
private boolean arePositionsWithinDocument(List<Caret> carets) {
for (Caret caret : carets) {
if (caret.getLogicalPosition().compareTo(offsetToLogicalPosition(caret.getOffset())) != 0) {
return false;
}
}
return true;
}
// TODO Improve the approach - handle such cases in a more general way.
private boolean isInplaceRenamerActive() {
Key<?> key = Key.findKeyByName("EditorInplaceRenamer");