summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoopur Gupta2013-04-05 06:19:30 (EDT)
committer Dani Megert2013-04-05 06:19:30 (EDT)
commit98de7b54e9692cb1c0e42917238ed0376e594ac1 (patch)
tree3ea67becb091fb248df1b83d44ec34d8de9f392a
parent16adef4548198d353256203ee59d8c8fb8b4726e (diff)
downloadeclipse.jdt.ui-98de7b54e9692cb1c0e42917238ed0376e594ac1.zip
eclipse.jdt.ui-98de7b54e9692cb1c0e42917238ed0376e594ac1.tar.gz
eclipse.jdt.ui-98de7b54e9692cb1c0e42917238ed0376e594ac1.tar.bz2
Fixed bug 404879: [typing] Regression on auto-insert of {}
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaAutoIndentStrategyTest.java15
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaAutoIndentStrategy.java4
2 files changed, 18 insertions, 1 deletions
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaAutoIndentStrategyTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaAutoIndentStrategyTest.java
index b3c5a8c..f812810 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaAutoIndentStrategyTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaAutoIndentStrategyTest.java
@@ -402,6 +402,21 @@ public class JavaAutoIndentStrategyTest extends TestCase implements ILogListener
Assert.assertEquals(buf.toString(), fDocument.get());
}
+ public void testSmartIndentAfterNewLine10() {
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=404879
+ fDocument.setInitialLineDelimiter("\r\n");
+ fDocument.set("{ foo();");
+ fDocumentCommand.doit= true;
+ fDocumentCommand.offset= 1;
+ fDocumentCommand.text= "\r\n";
+ performSmartIndentAfterNewLine();
+ StringBuffer buf= new StringBuffer();
+ buf.append("{\r\n");
+ buf.append("\tfoo();\r\n");
+ buf.append("}");
+ Assert.assertEquals(buf.toString(), fDocument.get());
+ }
+
/*
* @see junit.framework.TestCase#setUp()
*/
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaAutoIndentStrategy.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaAutoIndentStrategy.java
index 5e2288f..2ddf433 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaAutoIndentStrategy.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaAutoIndentStrategy.java
@@ -417,8 +417,10 @@ public class JavaAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
break;
// only select insert positions for parenthesis currently embracing the caret
- if (openingParen > pos)
+ if (openingParen > pos) {
+ openingParen= -1;
continue;
+ }
if (looksLikeAnonymousClassDef(document, partitioning, scanner, openingParen - 1))
return false;