IDEA-120730 Editor drops the existing selection when hitting Alt while selecting

This commit is contained in:
Dmitry Batrak
2014-03-24 11:39:51 +04:00
parent 09bb6a338d
commit 7177fd5936
2 changed files with 25 additions and 0 deletions
@@ -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
@@ -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("l<selection>ine1\n" +
"li<caret></selection>ne2\n" +
"line3");
mouse().alt().dragTo(1, 3);
checkResultByText("l<selection>in<caret></selection>e1\n" +
"l<selection>in<caret></selection>e2\n" +
"line3");
mouse().dragTo(2, 4).release();
checkResultByText("l<selection>ine1\n" +
"line2\n" +
"line<caret></selection>3");
}
public void testTyping() throws Exception {
init("some<caret> text<caret>\n" +
"some <selection><caret>other</selection> <selection>text<caret></selection>\n" +