Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2010-04-30 05:36:39 -0400
committerAnton Leherbauer2010-04-30 05:36:39 -0400
commit4e1599eb2993810817e3315366991c46f02c938b (patch)
tree776a64e490f87db57fbdc15d8bd94b228c4fafb8
parent1244f1fcf364a0ef242557958e51eb36a3b16024 (diff)
downloadorg.eclipse.cdt-4e1599eb2993810817e3315366991c46f02c938b.tar.gz
org.eclipse.cdt-4e1599eb2993810817e3315366991c46f02c938b.tar.xz
org.eclipse.cdt-4e1599eb2993810817e3315366991c46f02c938b.zip
Bug 311018 - Auto-indent not working for Whitesmiths on if/while/for braces
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CAutoIndentTest.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java2
2 files changed, 11 insertions, 1 deletions
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 f853be4232..9190b1ac1c 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
@@ -438,6 +438,16 @@ public class CAutoIndentTest extends AbstractAutoEditTest {
store.setToDefault(PreferenceConstants.EDITOR_AUTO_INDENT);
}
}
+
+ public void testSkipToStatementStartWhitesmiths_Bug311018() throws Exception {
+ DefaultCodeFormatterOptions whitesmiths= DefaultCodeFormatterOptions.getWhitesmithsSettings();
+ CCorePlugin.setOptions(new HashMap<String, String>(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());
+ }
public void testTabsAsSpaces_SmartIndentDisabled_Bug242707() throws Exception {
HashMap<String, String> options = new HashMap<String, String>();
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 2184172036..5e83d7c00b 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
@@ -1277,8 +1277,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.TokenENUM:
case Symbols.TokenSTRUCT:

Back to the top