Skip to content

Commit

Permalink
Extract setting for preference of newline placement for computation e…
Browse files Browse the repository at this point in the history
…xpressions (#2746)

* Add new setting

* Add test

* Implement new setting

* Add setting-specific tests to its own file

* Fix an issue with applying to lambdas

* Fix issue when applying to LetBang and AndBang

* Fix all failing tests, some cleanup

* Remove invalid tests, some more cleanup

* Rename some helpers

* temp

* Cleanup, add test

* Rename setting

* Use local Fantomas.Core reference for Configuration.fsx.

* Rename some things and fix assertion

* Update docs

* Simplify isStroustrupStyleExpr

* Rename test file to match setting name.

* Add additional test to highlight that settings don't affect each other.

---------

Co-authored-by: nojaf <[email protected]>
  • Loading branch information
josh-degraw and nojaf committed Mar 27, 2023
1 parent a85ed3c commit e480717
Show file tree
Hide file tree
Showing 23 changed files with 786 additions and 742 deletions.
20 changes: 20 additions & 0 deletions docs/docs/end-users/Configuration.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,26 @@ formatCode
MultilineBracketStyle = Stroustrup }
(*** include-output ***)

(**
<fantomas-setting name="fsharp_newline_before_multiline_computation_expression" green></fantomas-setting>
Insert a newline before a computation expression that spans multiple lines
Default = true
*)

formatCode
"""
let something =
task {
let! thing = otherThing ()
return 5
}
"""
{ FormatConfig.Default with
NewlineBeforeMultilineComputationExpression = false }
(*** include-output ***)

(**
## G-Research style
Expand Down
1 change: 1 addition & 0 deletions src/Fantomas.Core.Tests/Fantomas.Core.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<Compile Include="ListTests.fs" />
<Compile Include="CompilerDirectivesTests.fs" />
<Compile Include="ComputationExpressionTests.fs" />
<Compile Include="NewlineBeforeMultilineComputationExpressionTests.fs" />
<Compile Include="TypeProviderTests.fs" />
<Compile Include="FormattingSelectionOnlyTests.fs" />
<Compile Include="ValidationTests.fs" />
Expand Down
Loading

0 comments on commit e480717

Please sign in to comment.