diff --git a/src/services/refactors/addOrRemoveBracesToArrowFunction.ts b/src/services/refactors/addOrRemoveBracesToArrowFunction.ts
index 3cd8e7dfb34..fd75154c562 100644
--- a/src/services/refactors/addOrRemoveBracesToArrowFunction.ts
+++ b/src/services/refactors/addOrRemoveBracesToArrowFunction.ts
@@ -66,13 +66,11 @@ namespace ts.refactor.addOrRemoveBracesToArrowFunction {
if (actionName === addBracesAction.name) {
const returnStatement = factory.createReturnStatement(expression);
body = factory.createBlock([returnStatement], /* multiLine */ true);
- suppressLeadingAndTrailingTrivia(body);
copyLeadingComments(expression!, returnStatement, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ true);
}
else if (actionName === removeBracesAction.name && returnStatement) {
const actualExpression = expression || factory.createVoidZero();
body = needsParentheses(actualExpression) ? factory.createParenthesizedExpression(actualExpression) : actualExpression;
- suppressLeadingAndTrailingTrivia(body);
copyTrailingAsLeadingComments(returnStatement, body, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ false);
copyLeadingComments(returnStatement, body, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ false);
copyTrailingComments(returnStatement, body, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ false);
diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction31.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction31.ts
new file mode 100644
index 00000000000..d8982ad8371
--- /dev/null
+++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction31.ts
@@ -0,0 +1,19 @@
+///
+
+////const a = /*a*/()/*b*/ => {
+//// return (
+//// // comment
+//// 1
+//// );
+////};
+
+goTo.select("a", "b");
+edit.applyRefactor({
+ refactorName: "Add or remove braces in an arrow function",
+ actionName: "Remove braces from arrow function",
+ actionDescription: "Remove braces from arrow function",
+ newContent: `const a = () => (
+ // comment
+ 1
+);`,
+});
diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction32.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction32.ts
new file mode 100644
index 00000000000..555d50b6fcc
--- /dev/null
+++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction32.ts
@@ -0,0 +1,23 @@
+///
+
+////const a = /*a*/()/*b*/ => {
+//// return (
+//// /*
+//// multi-line comment
+//// */
+//// 1
+//// );
+////};
+
+goTo.select("a", "b");
+edit.applyRefactor({
+ refactorName: "Add or remove braces in an arrow function",
+ actionName: "Remove braces from arrow function",
+ actionDescription: "Remove braces from arrow function",
+ newContent: `const a = () => (
+ /*
+ multi-line comment
+ */
+ 1
+);`,
+});
diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction33.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction33.ts
new file mode 100644
index 00000000000..d25b18f1376
--- /dev/null
+++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction33.ts
@@ -0,0 +1,19 @@
+///
+
+////const a = /*a*/()/*b*/ => (
+//// // comment
+//// 1
+////);
+
+goTo.select("a", "b");
+edit.applyRefactor({
+ refactorName: "Add or remove braces in an arrow function",
+ actionName: "Add braces to arrow function",
+ actionDescription: "Add braces to arrow function",
+ newContent: `const a = () => {
+ return (
+ // comment
+ 1
+ );
+};`,
+});
diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction34.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction34.ts
new file mode 100644
index 00000000000..f1bb5858aa1
--- /dev/null
+++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction34.ts
@@ -0,0 +1,23 @@
+///
+
+////const a = /*a*/()/*b*/ => (
+//// /*
+//// multi-line comment
+//// */
+//// 1
+////);
+
+goTo.select("a", "b");
+edit.applyRefactor({
+ refactorName: "Add or remove braces in an arrow function",
+ actionName: "Add braces to arrow function",
+ actionDescription: "Add braces to arrow function",
+ newContent: `const a = () => {
+ return (
+ /*
+ multi-line comment
+ */
+ 1
+ );
+};`,
+});