From c5a950f73f7b04f8da99681c01672b91904a18de Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Mon, 6 May 2019 19:50:41 -0700 Subject: [PATCH] Fix JSX removing semicolons --- formatTest/unit_tests/expected_output/jsx.re | 32 ++++++++++++-------- formatTest/unit_tests/input/jsx.re | 13 ++++++++ src/reason-parser/reason_pprint_ast.ml | 8 ++--- 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/formatTest/unit_tests/expected_output/jsx.re b/formatTest/unit_tests/expected_output/jsx.re index abcc7935b..108b06348 100644 --- a/formatTest/unit_tests/expected_output/jsx.re +++ b/formatTest/unit_tests/expected_output/jsx.re @@ -623,21 +623,17 @@ ReasonReact.(<> {string("Test")} ); ;
- { - let left = limit->Int.toString; - {j|$left characters left|j}->React.string; - } + {let left = limit->Int.toString; + {j|$left characters left|j}->React.string}
; - { - let uri = "/images/header-background.png"; - ; - } + {let uri = "/images/header-background.png"; + } ;
@@ -650,3 +646,15 @@ ReasonReact.(<> {string("Test")} ); {ReasonReact.string("bar")} }
; + +let v = + + + ...{_ => { + let renderX = x => + {let y = x ++ x; +
}; + renderX("foo"); + }} + + ; diff --git a/formatTest/unit_tests/input/jsx.re b/formatTest/unit_tests/input/jsx.re index 64a92a927..23c6a74c4 100644 --- a/formatTest/unit_tests/input/jsx.re +++ b/formatTest/unit_tests/input/jsx.re @@ -519,3 +519,16 @@ ReasonReact.(<> {string("Test")} ); {ReasonReact.string(foo)} } : {ReasonReact.string("bar")} }
; + +let v = + + + ...{_ => { + let renderX = x => { + let y = x ++ x; +
; + }; + renderX("foo"); + }} + + ; diff --git a/src/reason-parser/reason_pprint_ast.ml b/src/reason-parser/reason_pprint_ast.ml index a02699219..98b9e6f0f 100644 --- a/src/reason-parser/reason_pprint_ast.ml +++ b/src/reason-parser/reason_pprint_ast.ml @@ -6096,7 +6096,7 @@ let printer = object(self:'self) ~inline:(true, inline_braces) ~wrap:("{", "}") ~postSpace:true - ~sep:(if inline_braces then NoSep else (SepFinal (";", ";"))) + ~sep:(if inline_braces then (Sep ";") else (SepFinal (";", ";"))) (self#letList x) in Some layout @@ -6272,11 +6272,7 @@ let printer = object(self:'self) | head :: remaining -> self#formatChildren remaining - (self - #dont_preserve_braces (* the brace logic is handled here *) - #simplifyUnparseExpr ~inline:true ~wrap:("{", "}") - head - :: processedRev) + (self#inline_braces#simplifyUnparseExpr ~inline:true ~wrap:("{", "}") head :: processedRev) | [] -> match processedRev with | [] -> None | _::_ -> Some (List.rev processedRev)