mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 380490 - Invalid auto indentation after a multiline function call
This commit is contained in:
parent
e266e58f98
commit
506c347cd8
2 changed files with 27 additions and 3 deletions
|
@ -25,7 +25,6 @@ import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
|
|||
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterOptions;
|
||||
import org.eclipse.cdt.ui.tests.BaseUITestCase;
|
||||
|
||||
|
||||
import org.eclipse.cdt.internal.ui.editor.CDocumentSetupParticipant;
|
||||
import org.eclipse.cdt.internal.ui.editor.IndentUtil;
|
||||
|
||||
|
@ -979,4 +978,27 @@ public class CIndenterTest extends BaseUITestCase {
|
|||
public void testIndentationAfterFunctionHeaderWithPointerReturnType_Bug334805() throws Exception {
|
||||
assertIndenterResult();
|
||||
}
|
||||
|
||||
//void test(int arg1, int arg2) {
|
||||
//if (BooleanFunction1(arg1,
|
||||
//arg2) ||
|
||||
//BooleanFunction2(arg1, arg2)) {
|
||||
//x++;
|
||||
//}
|
||||
//}
|
||||
|
||||
//void test(int arg1, int arg2) {
|
||||
// if (BooleanFunction1(arg1,
|
||||
// arg2) ||
|
||||
// BooleanFunction2(arg1, arg2)) {
|
||||
// x++;
|
||||
// }
|
||||
//}
|
||||
public void testMultilineFunctionCall_Bug380490() throws Exception {
|
||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE);
|
||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION,
|
||||
DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT,
|
||||
DefaultCodeFormatterConstants.INDENT_ON_COLUMN));
|
||||
assertIndenterResult();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
|
|||
* </p>
|
||||
*/
|
||||
public final class CIndenter {
|
||||
|
||||
/**
|
||||
* The CDT Core preferences.
|
||||
*/
|
||||
|
@ -1588,6 +1587,7 @@ public final class CIndenter {
|
|||
private int skipToPreviousListItemOrListStart() {
|
||||
int startLine= fLine;
|
||||
int startPosition= fPosition;
|
||||
int linesSkippedInsideScopes = 0;
|
||||
boolean continuationLineCandidate =
|
||||
fToken == Symbols.TokenEQUAL || fToken == Symbols.TokenSHIFTLEFT ||
|
||||
fToken == Symbols.TokenRPAREN;
|
||||
|
@ -1596,7 +1596,7 @@ public final class CIndenter {
|
|||
nextToken();
|
||||
|
||||
// If any line item comes with its own indentation, adapt to it
|
||||
if (fLine < startLine) {
|
||||
if (fLine < startLine - linesSkippedInsideScopes) {
|
||||
try {
|
||||
int lineOffset= fDocument.getLineOffset(startLine);
|
||||
int bound= Math.min(fDocument.getLength(), startPosition + 1);
|
||||
|
@ -1617,6 +1617,7 @@ public final class CIndenter {
|
|||
return startPosition;
|
||||
}
|
||||
|
||||
int line = fLine;
|
||||
switch (fToken) {
|
||||
// scopes: skip them
|
||||
case Symbols.TokenRPAREN:
|
||||
|
@ -1625,6 +1626,7 @@ public final class CIndenter {
|
|||
case Symbols.TokenRBRACKET:
|
||||
case Symbols.TokenRBRACE:
|
||||
skipScope();
|
||||
linesSkippedInsideScopes = line - fLine;
|
||||
break;
|
||||
|
||||
// scope introduction: special treat who special is
|
||||
|
|
Loading…
Add table
Reference in a new issue