From 7f1562ec237ad34a102ee08bb4536fa03f0e897d Mon Sep 17 00:00:00 2001 From: Pavel Fatin Date: Thu, 10 Sep 2015 15:31:29 +0200 Subject: [PATCH] Zero-latency typing: handle carets in "virtual space" --- .../com/intellij/openapi/editor/impl/EditorImpl.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index c010e46703db..0d6ef01b83be 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -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 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");