From fd2d7c6fc9b5fc44a068c1f4a27de2e546465b69 Mon Sep 17 00:00:00 2001 From: dawedawe Date: Sun, 13 Feb 2022 17:12:57 +0100 Subject: [PATCH 1/2] Explain what's needed to close issues, that aren't reproducable anymore. --- CONTRIBUTING.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fd00147ede..3814b8430b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -135,6 +135,9 @@ Filename: `MyNewConceptTests.fs`. When developing a new feature, add new tests to cover all code paths. +If you come across an issue, which can't be reproduced with the latest version of Fantomas but is still open, please submit a regression test. +That way, we can ensure the issue stays fixed after closing it. + ## Guidelines - Please always rebase your code on the targeted branch. @@ -182,8 +185,8 @@ It's often better to check *before* contributing that you're setting off on the ## Fixing style guide inconsistencies Fantomas tries to keep up with the style guides, but as these are living documents, it can occur that something is listed in the style that Fantomas is not respecting. -In this case, please create an issue using our [online tool](https://fsprojects.github.io/fantomas-tools/#/). -Copy the code snippet from the guide and add a link to the section of the guide that is not being respected. +In this case, please create an issue using our [online tool](https://fsprojects.github.io/fantomas-tools/#/). +Copy the code snippet from the guide and add a link to the section of the guide that is not being respected. The maintainers will then add the `bug (stylistic)` to confirm the bug is fixable in Fantomas. In most cases, it may seem obvious that the case can be fixed. However, in the past there have been changes to the style guide that Fantomas could not implement for technical reasons: Fantomas can only implement rules based on information entirely contained within the untyped syntax tree. @@ -193,7 +196,7 @@ When fixing a stylistic issue, please ask the maintainers what branch should be Strive to ensure that end users can always update to the latest patch revision of their current minor or major without fear. A user should only need to deal with style changes when they have explicitly [chosen to upgrade](https://github.com/fsprojects/fantomas/blob/master/docs/Documentation.md#updating-to-a-new-fantomas-version) to a new minor or major version. -In case no major or minor branch was created yet, please reach out to the maintainers. +In case no major or minor branch was created yet, please reach out to the maintainers. The maintainers will frequently rebase this branch on top of the master branch and release alpha/beta packages accordingly. # Your First Contribution From bdb6481c4c9f7b2f23707d9da4ef22daf40f595a Mon Sep 17 00:00:00 2001 From: dawe Date: Mon, 14 Feb 2022 18:44:27 +0100 Subject: [PATCH 2/2] Fix 1749: Creating anonymous record based on a function call with a list arg - Wrap genExpr() in atCurrentColumnIndent() --- ...ineBlockBracketsOnSameColumnRecordTests.fs | 40 +++++++++++++++++++ src/Fantomas/CodePrinter.fs | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/Fantomas.Tests/MultilineBlockBracketsOnSameColumnRecordTests.fs b/src/Fantomas.Tests/MultilineBlockBracketsOnSameColumnRecordTests.fs index c7ce20f7f2..a588fcecf2 100644 --- a/src/Fantomas.Tests/MultilineBlockBracketsOnSameColumnRecordTests.fs +++ b/src/Fantomas.Tests/MultilineBlockBracketsOnSameColumnRecordTests.fs @@ -3,6 +3,7 @@ module Fantomas.Tests.MultilineBlockBracketsOnSameColumnRecordTests open NUnit.Framework open FsUnit open Fantomas.Tests.TestHelper +open Fantomas.FormatConfig let config = { config with @@ -1189,3 +1190,42 @@ let ``anonymous records with comments on record fields`` () = BarValue = barValue |} """ + +[] +let ``creating anonymous record based on a function call, 1749`` () = + formatSourceString + false + """ +type Foo = static member Create a = {| Name = "Isaac" |} +type Bar() = member _.Create (a,b) = () +let bar = Bar() +type Thing = static member Stuff = 123 +let x = {| Foo.Create ([ bar.Create(Thing.Stuff, Thing.Stuff) ]) with Age = 41 |} +""" + { config with + ArrayOrListMultilineFormatter = MultilineFormatterType.CharacterWidth + SpaceBeforeUppercaseInvocation = true } + |> prepend newline + |> should + equal + """ +type Foo = + static member Create a = {| Name = "Isaac" |} + +type Bar() = + member _.Create(a, b) = () + +let bar = Bar () + +type Thing = + static member Stuff = 123 + +let x = + {| Foo.Create ( + [ + bar.Create (Thing.Stuff, Thing.Stuff) + ] + ) with + Age = 41 + |} +""" diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index 4126720f48..bf858e3dc2 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -3099,7 +3099,7 @@ and genMultilineAnonRecordAlignBrackets (isStruct: bool) fields copyInfo astCont let fieldsExpr = col sepSemiNln fields (genAnonRecordFieldName astContext) let copyExpr fieldsExpr e = - genExpr astContext e + atCurrentColumnIndent (genExpr astContext e) +> (!- " with" +> indent +> whenShortIndent indent