From de22c3b31128a342756c10d2627ab35d9baa40c8 Mon Sep 17 00:00:00 2001 From: David Dubrow Date: Thu, 29 Apr 2010 16:25:12 +0000 Subject: [PATCH] For whitesmiths, make start of line to be indented with block --- .../org/eclipse/cdt/ui/tests/text/CAutoIndentTest.java | 10 ++++++++++ .../org/eclipse/cdt/internal/ui/text/CIndenter.java | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) 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: