Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2008-03-03 13:53:57 +0000
committerAnton Leherbauer2008-03-03 13:53:57 +0000
commitcf7493d440b7113c315c4025a4064ad3feaf0e49 (patch)
treeadd4670ab27549dde36267964925353ad0a9a8fd /core/org.eclipse.cdt.ui.tests
parent7484954d7f9f41129241cb4910b0e929455f58e6 (diff)
downloadorg.eclipse.cdt-cf7493d440b7113c315c4025a4064ad3feaf0e49.tar.gz
org.eclipse.cdt-cf7493d440b7113c315c4025a4064ad3feaf0e49.tar.xz
org.eclipse.cdt-cf7493d440b7113c315c4025a4064ad3feaf0e49.zip
219923: [Indenter] Provide preferences option to disable auto-indent.
Diffstat (limited to 'core/org.eclipse.cdt.ui.tests')
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CAutoIndentTest.java34
1 files changed, 34 insertions, 0 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 cf9a40b6af6..e4622569755 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
@@ -24,12 +24,14 @@ import junit.framework.TestSuite;
import org.eclipse.core.runtime.ILogListener;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.ui.text.ICPartitions;
import org.eclipse.cdt.ui.text.doctools.DefaultMultilineCommentAutoEditStrategy;
@@ -401,6 +403,38 @@ public class CAutoIndentTest extends AbstractAutoEditTest {
assertNoError();
}
+ public void testAutoIndentDisabled_Bug219923() throws Exception {
+ AutoEditTester tester = createAutoEditTester(); //$NON-NLS-1$
+ IPreferenceStore store= PreferenceConstants.getPreferenceStore();
+ try {
+ store.setValue(PreferenceConstants.EDITOR_AUTO_INDENT, false);
+ tester.type("void main() {\n"); //$NON-NLS-1$
+ assertEquals(1, tester.getCaretLine());
+ // Nested statement is not indented
+ assertEquals(0, tester.getCaretColumn());
+ // The brace was closed automatically.
+ assertEquals("}", tester.getLine(1)); //$NON-NLS-1$
+ tester.type('\t');
+ tester.type('\n');
+ // indent from previous line
+ assertEquals(1, tester.getCaretColumn());
+ tester.type('{');
+ tester.type('\n');
+ // indent from previous line
+ assertEquals(1, tester.getCaretColumn());
+ tester.type('}');
+ tester.type('\n');
+ // indent from previous line
+ assertEquals(1, tester.getCaretColumn());
+ tester.backspace();
+ tester.type('\n');
+ // indent from previous line
+ assertEquals(0, tester.getCaretColumn());
+ } finally {
+ store.setToDefault(PreferenceConstants.EDITOR_AUTO_INDENT);
+ }
+ }
+
private void assertNoError() {
if (!fStatusLog.isEmpty()) {
fail(fStatusLog.get(0).toString());

Back to the top