diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java index 9abe5b5291f..99588a8b8dc 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java @@ -25,7 +25,6 @@ import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants; import org.eclipse.cdt.core.formatter.DefaultCodeFormatterOptions; import org.eclipse.cdt.ui.tests.BaseUITestCase; - import org.eclipse.cdt.internal.ui.editor.CDocumentSetupParticipant; import org.eclipse.cdt.internal.ui.editor.IndentUtil; @@ -979,4 +978,27 @@ public class CIndenterTest extends BaseUITestCase { public void testIndentationAfterFunctionHeaderWithPointerReturnType_Bug334805() throws Exception { assertIndenterResult(); } + + //void test(int arg1, int arg2) { + //if (BooleanFunction1(arg1, + //arg2) || + //BooleanFunction2(arg1, arg2)) { + //x++; + //} + //} + + //void test(int arg1, int arg2) { + // if (BooleanFunction1(arg1, + // arg2) || + // BooleanFunction2(arg1, arg2)) { + // x++; + // } + //} + public void testMultilineFunctionCall_Bug380490() throws Exception { + fOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE); + fOptions.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, + DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT, + DefaultCodeFormatterConstants.INDENT_ON_COLUMN)); + assertIndenterResult(); + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java index a03e5b76fa9..910dc5468cf 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java @@ -39,7 +39,6 @@ import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil; *

*/ public final class CIndenter { - /** * The CDT Core preferences. */ @@ -1588,6 +1587,7 @@ public final class CIndenter { private int skipToPreviousListItemOrListStart() { int startLine= fLine; int startPosition= fPosition; + int linesSkippedInsideScopes = 0; boolean continuationLineCandidate = fToken == Symbols.TokenEQUAL || fToken == Symbols.TokenSHIFTLEFT || fToken == Symbols.TokenRPAREN; @@ -1596,7 +1596,7 @@ public final class CIndenter { nextToken(); // If any line item comes with its own indentation, adapt to it - if (fLine < startLine) { + if (fLine < startLine - linesSkippedInsideScopes) { try { int lineOffset= fDocument.getLineOffset(startLine); int bound= Math.min(fDocument.getLength(), startPosition + 1); @@ -1617,6 +1617,7 @@ public final class CIndenter { return startPosition; } + int line = fLine; switch (fToken) { // scopes: skip them case Symbols.TokenRPAREN: @@ -1625,6 +1626,7 @@ public final class CIndenter { case Symbols.TokenRBRACKET: case Symbols.TokenRBRACE: skipScope(); + linesSkippedInsideScopes = line - fLine; break; // scope introduction: special treat who special is