diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CAutoIndentTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CAutoIndentTest.java index bf3e6469583..4344a76bc5e 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CAutoIndentTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CAutoIndentTest.java @@ -514,6 +514,16 @@ public class CAutoIndentTest extends AbstractAutoEditTest { // The brace was closed automatically. assertEquals("}", tester.getLine(1)); //$NON-NLS-1$ } + + public void testSkipToStatementStartWhitesmiths_Bug311018() throws Exception { + DefaultCodeFormatterOptions whitesmiths= DefaultCodeFormatterOptions.getWhitesmithsSettings(); + CCorePlugin.setOptions(new HashMap(whitesmiths.getMap())); + AutoEditTester tester = createAutoEditTester(); + tester.type("if (i > 0)\n"); //$NON-NLS-1$ + tester.type("{\n"); //$NON-NLS-1$ + // start is indented to the brace + assertEquals("if (i > 0)\n {\n \n }", tester.fDoc.get()); + } private void assertNoError() { if (!fStatusLog.isEmpty()) { 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 0255458e466..a3e8e0e7daf 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 @@ -1319,8 +1319,8 @@ public final class CIndenter { case Symbols.TokenWHILE: case Symbols.TokenFOR: case Symbols.TokenTRY: + fIndent += fPrefs.prefIndentBracesForBlocks ? 1 : 0; return fPosition; - case Symbols.TokenCLASS: case Symbols.TokenSTRUCT: case Symbols.TokenUNION: