mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-192807 Enter calculates wrong indent
GitOrigin-RevId: ee6543a8e89f9a49e6303f78e86cd343ee78220f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f204c6e6a8
commit
328c05d165
@@ -613,4 +613,21 @@ public class JavaEnterActionTest extends AbstractEnterActionTestCase {
|
||||
"}"
|
||||
);
|
||||
}
|
||||
|
||||
public void testIdea192807() {
|
||||
doTextTest(
|
||||
"java",
|
||||
|
||||
"class MyTest\n" +
|
||||
"{\n" +
|
||||
" private void foo() { String a = \"a\";<caret> String b = \"b\";}\n" +
|
||||
"}",
|
||||
|
||||
"class MyTest\n" +
|
||||
"{\n" +
|
||||
" private void foo() { String a = \"a\";\n" +
|
||||
" <caret>String b = \"b\";}\n" +
|
||||
"}"
|
||||
);
|
||||
}
|
||||
}
|
||||
+12
-1
@@ -136,7 +136,7 @@ public abstract class JavaLikeLangLineIndentProvider implements LineIndentProvid
|
||||
}
|
||||
int statementStart = getStatementStartOffset(beforeSemicolon, dropIndentAfterReturnLike(beforeSemicolon));
|
||||
SemanticEditorPosition atStatementStart = getPosition(editor, statementStart);
|
||||
if (atStatementStart.isAt(BlockOpeningBrace)) {
|
||||
if (isAtBlockOpeningOnSameLine(atStatementStart)) {
|
||||
return myFactory.createIndentCalculator(getIndentInBlock(project, language, atStatementStart), this::getDeepBlockStatementStartOffset);
|
||||
}
|
||||
if (!isInsideForLikeConstruction(atStatementStart)) {
|
||||
@@ -203,6 +203,17 @@ public abstract class JavaLikeLangLineIndentProvider implements LineIndentProvid
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean isAtBlockOpeningOnSameLine(@NotNull SemanticEditorPosition position) {
|
||||
SemanticEditorPosition pos = position.copy();
|
||||
while (!pos.isAt(BlockOpeningBrace)) {
|
||||
pos.moveBefore();
|
||||
if (pos.isAtEnd() || pos.isAtMultiline()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private SemanticEditorPosition afterOptionalWhitespaceOnSameLine(@NotNull Editor editor, int offset) {
|
||||
SemanticEditorPosition position = getPosition(editor, offset);
|
||||
if (position.isAt(Whitespace)) {
|
||||
|
||||
Reference in New Issue
Block a user