1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-21 21:52:10 +02:00

Bug 561559 - Fix formatting def capture lambda expressions

We missed a space before the closing brackets if the proper option
was selected.

Change-Id: Ibbb09c3c961dc1b5e22aaa65ffb5d9878c2bb08b
This commit is contained in:
Marco Stornelli 2020-03-29 16:23:48 +02:00
parent f4951d8086
commit f20570a200
2 changed files with 22 additions and 2 deletions

View file

@ -2492,8 +2492,9 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
final int elementsLength = elements.size();
if (encloseInParen) {
boolean spaceBeforeClosingParen = elements.isEmpty() && !addEllipsis ? options.fSpaceBetweenEmptyParen
: options.fSpaceBeforeClosingParen;
boolean spaceBeforeClosingParen = elements.isEmpty() && !addEllipsis
&& options.captureDefault == CaptureDefault.UNSPECIFIED ? options.fSpaceBetweenEmptyParen
: options.fSpaceBeforeClosingParen;
tailFormatter = new ClosingParensesisTailFormatter(spaceBeforeClosingParen, tailFormatter,
options.rightToken);
}

View file

@ -4734,4 +4734,23 @@ public class CodeFormatterTest extends BaseUITestCase {
public void testFormatterOnOff_Bug559669() throws Exception {
assertFormatterResult();
}
//int main() {
// auto f = [&](){
// };
// return 0;
//}
//int main() {
// auto f = [ & ]() {
// };
// return 0;
//}
public void testLambdaExpressionOnlyDefCapture_Bug561559() throws Exception {
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION,
CCorePlugin.INSERT);
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION,
CCorePlugin.INSERT);
assertFormatterResult();
}
}