Unindent action doesn't place caret inside text, if it was not there already. (IDEA-111438)

This commit is contained in:
Yaroslav Lepenkin
2015-02-11 14:34:14 +03:00
parent cb33f58dbe
commit 013314cfbc
2 changed files with 11 additions and 0 deletions
@@ -198,9 +198,13 @@ public class EditorActionUtil {
}
}
int newSpacesEnd = lineStart + buf.length();
if (newCaretOffset >= spacesEnd) {
newCaretOffset += buf.length() - (spacesEnd - lineStart);
}
else if (newCaretOffset >= lineStart && newCaretOffset < spacesEnd && newCaretOffset > newSpacesEnd) {
newCaretOffset = newSpacesEnd;
}
if (buf.length() > 0) {
if (spacesEnd > lineStart) {
@@ -22,6 +22,7 @@ import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.editor.impl.AbstractEditorTest;
import com.intellij.openapi.ide.CopyPasteManager;
import com.intellij.testFramework.EditorTestUtil;
import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
import com.intellij.testFramework.TestFileType;
import java.awt.datatransfer.StringSelection;
@@ -187,4 +188,10 @@ public class EditorActionTest extends AbstractEditorTest {
"blah <selection>blah\n" +
"blah bl<caret></selection>ah");
}
public void testCaretComesBeforeTextOnUnindent() throws IOException {
initText(" <caret> text");
unindent();
checkResultByText(" <caret>text");
}
}