diff --git a/src/Fantomas.Tests/ElmishTests.fs b/src/Fantomas.Tests/ElmishTests.fs index 6ad46a6313..188029cd68 100644 --- a/src/Fantomas.Tests/ElmishTests.fs +++ b/src/Fantomas.Tests/ElmishTests.fs @@ -711,4 +711,57 @@ Html.ul [ Html.li [ Html.strong "Two" ] Html.li [ Html.em "Three" ] ] -""" \ No newline at end of file +""" + +[] +let ``feliz construct with a single element as child, 999`` () = + formatSourceString false """ +let drawer = + Mui.drawer [ + // drawer.open' props.IsOpen + + drawer.children + [ + Html.div [ prop.className classes.toolbar ] + props.Items + |> List.map (fun s -> + Mui.listItem + [ + listItem.button true + match state with + | Some t when t = s -> listItem.selected true + | _ -> listItem.selected false + prop.text s + prop.onClick (fun _ -> + s + |> MenuItemClick + |> dispatch) + ]) + |> Mui.list + ] + ] +""" { config with SingleArgumentWebMode = true } + |> prepend newline + |> should equal """ +let drawer = + Mui.drawer [ + // drawer.open' props.IsOpen + + drawer.children [ + Html.div [ + prop.className classes.toolbar + ] + props.Items + |> List.map (fun s -> + Mui.listItem [ + listItem.button true + match state with + | Some t when t = s -> listItem.selected true + | _ -> listItem.selected false + prop.text s + prop.onClick (fun _ -> s |> MenuItemClick |> dispatch) + ]) + |> Mui.list + ] + ] +""" diff --git a/src/Fantomas.Tests/ListTests.fs b/src/Fantomas.Tests/ListTests.fs index 190806b00d..436575506b 100644 --- a/src/Fantomas.Tests/ListTests.fs +++ b/src/Fantomas.Tests/ListTests.fs @@ -208,10 +208,9 @@ let prismCli commando = """ config |> should equal """let prismCli commando = let props = - createObj - [ "component" ==> "pre" - //"className" ==> "language-fsharp" - ] + createObj [ "component" ==> "pre" + //"className" ==> "language-fsharp" + ] () """ @@ -230,10 +229,9 @@ let prismCli commando = """ ({ config with SpaceAroundDelimiter = false }) |> should equal """let prismCli commando = let props = - createObj - [|"component" ==> "pre" - //"className" ==> "language-fsharp" - |] + createObj [|"component" ==> "pre" + //"className" ==> "language-fsharp" + |] () """ diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index ef6ae4f2c1..3e4fda0609 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -959,6 +959,7 @@ and genExpr astContext synExpr = let genChildren = ifElse isArray sepOpenA sepOpenL +> col sepSemi children (genExpr astContext) + +> enterNodeTokenByName synExpr.Range (if isArray then "BAR_RBRACK" else "RBRACK") +> ifElse isArray sepCloseA sepCloseL !- identifier @@ -969,7 +970,7 @@ and genExpr astContext synExpr = !- identifier +> sepSpace +> ifElse isArray sepOpenA sepOpenL - +> atCurrentColumn (col sepNln children (genExpr astContext)) + +> atCurrentColumn (col sepNln children (genExpr astContext) +> enterNodeTokenByName synExpr.Range (if isArray then "BAR_RBRACK" else "RBRACK")) +> ifElse isArray sepCloseA sepCloseL let felizExpression = @@ -981,6 +982,7 @@ and genExpr astContext synExpr = +> col sepNln children (genExpr astContext) +> unindent +> sepNln + +> enterNodeTokenByName synExpr.Range (if isArray then "BAR_RBRACK" else "RBRACK") +> ifElse isArray sepCloseAFixed sepCloseLFixed) let multilineExpression = ifElse ctx.Config.SingleArgumentWebMode felizExpression elmishExpression diff --git a/src/Fantomas/SourceParser.fs b/src/Fantomas/SourceParser.fs index 7f58cec64e..b786e73a26 100644 --- a/src/Fantomas/SourceParser.fs +++ b/src/Fantomas/SourceParser.fs @@ -1430,6 +1430,8 @@ let (|ElmishReactWithoutChildren|_|) e = | App(OptVar(ident,_,_), [ArrayOrList(isArray, children, _)]) | App(OptVar(ident,_,_), [ArrayOrListOfSeqExpr(isArray, CompExpr(_, Sequentials children))]) -> Some(ident, isArray, children) + | App(OptVar(ident,_,_), [ArrayOrListOfSeqExpr(isArray, CompExpr(_, singleChild))]) -> + Some(ident, isArray, [singleChild]) | _ -> None