Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Make newline experience consistent across match branches #3083

Closed
4 of 6 tasks
Lanayx opened this issue May 5, 2024 · 1 comment
Closed
4 of 6 tasks

Comments

@Lanayx
Copy link
Member

Lanayx commented May 5, 2024

I propose we add configuration (or make default) for having consistent indentation of match cases.
So:

  1. If all branches can placed in the same line, do that
  2. If any branch must be moved to new line (due to length or multiline), move all branches to the new line

Pros and Cons

The advantages of making this adjustment to Fantomas are - more consistent code look and feel.

The disadvantages of making this adjustment to Fantomas are - reformatting existing code base (could be fixed by disabling feature by default)

Examples

From Oxpecker
Existing formatting:

match result with
| Ok _ -> return! ctx.Write <| Created()
| Error error ->
    env.Logger.LogError(error)
    return! ctx.Write <| BadRequest {| Error = error |}

Proposed formatting:

match result with
| Ok _ -> 
    return! ctx.Write <| Created()
| Error error ->
    env.Logger.LogError(error)
    return! ctx.Write <| BadRequest {| Error = error |}

Extra information

Estimated cost (XS, S, M, L, XL, XXL): M

Related suggestions: (put links to related suggestions here)

Affidavit (please submit!)

Please tick this by placing a cross in the box:

Please tick all that apply:

  • This is not a breaking change to Fantomas
  • I or my company would be willing to help implement and/or test this
  • This suggestion is part of the Microsoft style guide (please add a link to section if so)
  • This suggestion is part of the G-Research style guide (please add a link to section if so)
@nojaf
Copy link
Contributor

nojaf commented May 5, 2024

This falls under what-are-we-not-looking-for.

You are in luck, however, that this was discussed at some point in the style guide: fsharp/fslang-design#650.

I would accept a PR for this.

@nojaf nojaf closed this as not planned Won't fix, can't repro, duplicate, stale May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants