mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Unindent action doesn't place caret inside text, if it was not there already. (IDEA-111438)
This commit is contained in:
@@ -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) {
|
||||
|
||||
+7
@@ -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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user