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 f0913658234..9313d9c5ac7 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 @@ -307,16 +307,16 @@ public class CIndenterTest extends BaseUITestCase { //class A { //A(int a, //int b) - //:f(0) - //{ + //: f(0), + //g(0) { //} //}; //class A { // A(int a, // int b) - // :f(0) - // { + // : f(0), + // g(0) { // } //}; public void testConstructorBodyWithInitializer_Bug194586() throws Exception { 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 30b986502bc..595aa0be0b6 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 @@ -671,7 +671,6 @@ public final class CIndenter { // remainder while (spaces-- > 0) ret.append(' '); - } catch (BadLocationException e) { } @@ -1511,7 +1510,7 @@ public final class CIndenter { while (true) { nextToken(); - // if any line item comes with its own indentation, adapt to it + // If any line item comes with its own indentation, adapt to it if (fLine < startLine) { try { int lineOffset= fDocument.getLineOffset(startLine); @@ -1522,9 +1521,13 @@ public final class CIndenter { fIndent = fPrefs.prefContinuationIndent; } else { fAlign= fScanner.findNonWhitespaceForwardInAnyPartition(lineOffset, bound); + // If the reference line starts with a colon, skip the colon. + if (peekToken(fAlign) == Symbols.TokenCOLON) { + fAlign= fScanner.findNonWhitespaceForwardInAnyPartition(fAlign + 1, bound); + } } } catch (BadLocationException e) { - // ignore and return just the position + // Ignore and return just the position } return startPosition; } @@ -1955,7 +1958,7 @@ public final class CIndenter { * Returns true if the current tokens look like a method * declaration header (i.e. only the return type and method name). The * heuristic calls nextToken and expects an identifier - * (method name) and an optional retrun type declaration. + * (method name) and an optional return type declaration. * * @return true if the current position looks like a method * declaration header.