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 85f381c969cc..c90c5286debb 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
@@ -4270,6 +4270,10 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
}
if (!myMousePressedInsideSelection) {
+ if (myCaretModel.supportsMultipleCarets()) {
+ oldSelectionStart = logicalPositionToOffset(myLastMousePressedLocation);
+ oldVisLeadSelectionStart = logicalToVisualPosition(myLastMousePressedLocation);
+ }
// There is a possible case that lead selection position should be adjusted in accordance with the mouse move direction.
// E.g. consider situation when user selects the whole line by clicking at 'line numbers' area. 'Line end' is considered
// to be lead selection point then. However, when mouse is dragged down we want to consider 'line start' to be
diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/EditorMultiCaretTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/EditorMultiCaretTest.java
index 6f37735002a0..caec0af4de9c 100644
--- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/EditorMultiCaretTest.java
+++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/EditorMultiCaretTest.java
@@ -160,6 +160,27 @@ public class EditorMultiCaretTest extends AbstractEditorTest {
"line");
}
+ public void testAltOnOffWhileDragging() throws Exception {
+ init("line1\n" +
+ "line2\n" +
+ "line3",
+ TestFileType.TEXT);
+ setEditorVisibleSize(1000, 1000);
+
+ mouse().clickAt(0, 1).dragTo(1, 2);
+ checkResultByText("line1\n" +
+ "line2\n" +
+ "line3");
+ mouse().alt().dragTo(1, 3);
+ checkResultByText("line1\n" +
+ "line2\n" +
+ "line3");
+ mouse().dragTo(2, 4).release();
+ checkResultByText("line1\n" +
+ "line2\n" +
+ "line3");
+ }
+
public void testTyping() throws Exception {
init("some text\n" +
"some other text\n" +