From 037bcc12e986bc2dd825ff9d692c130444e153a2 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Wed, 26 May 2010 07:28:30 +0000 Subject: [PATCH] Indentation inside a multi-line return statement. Bug 314397. --- .../eclipse/cdt/ui/tests/text/CHeuristicScannerTest.java | 8 ++++---- .../src/org/eclipse/cdt/internal/ui/text/CIndenter.java | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CHeuristicScannerTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CHeuristicScannerTest.java index ac583a2a929..8225ab6bf1d 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CHeuristicScannerTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CHeuristicScannerTest.java @@ -117,7 +117,7 @@ public class CHeuristicScannerTest extends TestCase { ""); int pos= fScanner.findReferencePosition(29); - Assert.assertEquals(28, pos); + Assert.assertEquals(21, pos); } public void testPrevIndentationUnit5() { @@ -331,7 +331,7 @@ public class CHeuristicScannerTest extends TestCase { "\t\treturn a"); String indent= fScanner.computeIndentation(28).toString(); - Assert.assertEquals("\t\t", indent); + Assert.assertEquals("\t\t\t", indent); } public void testIndentation3() { @@ -340,7 +340,7 @@ public class CHeuristicScannerTest extends TestCase { "\t\treturn a;"); String indent= fScanner.computeIndentation(29).toString(); - Assert.assertEquals("\t\t", indent); + Assert.assertEquals("\t\t\t", indent); } public void testIndentation4() { @@ -350,7 +350,7 @@ public class CHeuristicScannerTest extends TestCase { ""); String indent= fScanner.computeIndentation(29).toString(); - Assert.assertEquals("\t\t", indent); + Assert.assertEquals("\t\t\t", indent); } public void testIndentation5() { 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 a3e8e0e7daf..45bd501d775 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 @@ -1091,6 +1091,11 @@ public final class CIndenter { // if not: take the start of the list ( LPAREN, LBRACE, LBRACKET ) and either align or // indent by list-indent return skipToPreviousListItemOrListStart(); + + case Symbols.TokenRETURN: + fIndent = fPrefs.prefContinuationIndent; + return fPosition; + default: // inside whatever we don't know about: similar to the list case: // if we are inside a continued expression, then either align with a previous line that @@ -1674,6 +1679,10 @@ public final class CIndenter { fIndent = fPrefs.prefContinuationIndent; } return 0; + + case Symbols.TokenRETURN: + fIndent = fPrefs.prefContinuationIndent; + return fPosition; } } }