diff --git a/src/Fantomas.Tests/ElmishTests.fs b/src/Fantomas.Tests/ElmishTests.fs index 998875a356..416d07ebb9 100644 --- a/src/Fantomas.Tests/ElmishTests.fs +++ b/src/Fantomas.Tests/ElmishTests.fs @@ -21,4 +21,77 @@ let view (model: Model) dispatch = (appearing = (fun () -> dispatch PageAppearing), title = model.Planet.Info.Name, backgroundColor = Color.Black, content = [ "....long line....................................................................................................." ]) +""" + +[] +let ``fabulous view`` () = + formatSourceString false """ + let loginPage = + View.ContentPage( + title = "Fabulous Demo", + content = View.ScrollView( + content = View.StackLayout( + padding = 30.0, + children = [ + View.Frame( + verticalOptions = LayoutOptions.CenterAndExpand, + content = View.StackLayout(children = [ + View.Entry( + placeholder = "User name", + isEnabled = (not model.IsSigningIn), + textChanged = (fun args -> (dispatch (UserNameChanged args.NewTextValue)))) + View.Entry( + placeholder = "Password", + isPassword = true, + isEnabled = (not model.IsSigningIn), + textChanged = (fun args -> (dispatch (PasswordChanged args.NewTextValue)))) + View.Button( + text = "Sign in", + heightRequest = 30.0, + isVisible = (not model.IsSigningIn), + command = (fun () -> dispatch SignIn), + canExecute = model.IsCredentialsProvided) + View.ActivityIndicator( + isRunning = true, + heightRequest = 30.0, + isVisible = model.IsSigningIn)]) + ) + ] + ) + ) + ) +""" config + |> prepend newline + |> should equal """ +let loginPage = + View.ContentPage + (title = "Fabulous Demo", + content = + View.ScrollView + (content = + View.StackLayout + (padding = 30.0, + children = + [ View.Frame + (verticalOptions = LayoutOptions.CenterAndExpand, + content = + View.StackLayout + (children = + [ View.Entry + (placeholder = "User name", isEnabled = (not model.IsSigningIn), + textChanged = + (fun args -> (dispatch (UserNameChanged args.NewTextValue)))) + View.Entry + (placeholder = "Password", isPassword = true, + isEnabled = (not model.IsSigningIn), + textChanged = + (fun args -> (dispatch (PasswordChanged args.NewTextValue)))) + View.Button + (text = "Sign in", heightRequest = 30.0, + isVisible = (not model.IsSigningIn), + command = (fun () -> dispatch SignIn), + canExecute = model.IsCredentialsProvided) + View.ActivityIndicator + (isRunning = true, heightRequest = 30.0, + isVisible = model.IsSigningIn) ])) ]))) """ \ No newline at end of file diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index 2bf45acebd..bf041f9860 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -1141,12 +1141,14 @@ and genInfixApps astContext hasNewLine synExprs = | (s, opE, e)::es when (NoBreakInfixOps.Contains s) -> (sepSpace +> tok opE.Range s +> (fun ctx -> - let futureNln = futureNlnCheck (genExpr astContext e) ctx - let genExpr = + let isEqualOperator = match opE with - | SynExpr.Ident(Ident("op_Equality")) when(futureNln) -> + | SynExpr.Ident(Ident("op_Equality")) -> true + | _ -> false + let genExpr = + if isEqualOperator && (futureNlnCheck (genExpr astContext e) ctx) then indent +> sepNln +> genExpr astContext e +> unindent - | _ -> + else sepSpace +> genExpr astContext e genExpr ctx)) +> genInfixApps astContext (hasNewLine || checkNewLine e es) es