Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarco Stornelli2020-03-29 14:23:48 +0000
committerMarco Stornelli2020-03-30 05:17:03 +0000
commit4a4c5fca4dee26c5655b01b526d44eac66863b58 (patch)
tree887f612e854e8f65d2b729944142030b96e35065 /core
parent1cb1cdaa9a48702a1fbd0520020ac8aa14f8b82a (diff)
downloadorg.eclipse.cdt-4a4c5fca4dee26c5655b01b526d44eac66863b58.tar.gz
org.eclipse.cdt-4a4c5fca4dee26c5655b01b526d44eac66863b58.tar.xz
org.eclipse.cdt-4a4c5fca4dee26c5655b01b526d44eac66863b58.zip
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
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java5
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java19
2 files changed, 22 insertions, 2 deletions
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java
index 70fbedd4890..08f8b002805 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java
@@ -2515,8 +2515,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);
}
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java
index 74997c84ac7..c72f0b79fa0 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java
@@ -4771,4 +4771,23 @@ public class CodeFormatterTest extends BaseUITestCase {
public void testDeductionGuideExplicit() 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();
+ }
}

Back to the top