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

Outdenting problem when specifying record with accessibility modifier #2597

Closed
1 of 3 tasks
yreynhout opened this issue Oct 24, 2022 · 1 comment · Fixed by #2602
Closed
1 of 3 tasks

Outdenting problem when specifying record with accessibility modifier #2597

yreynhout opened this issue Oct 24, 2022 · 1 comment · Fixed by #2602

Comments

@yreynhout
Copy link

Issue created from fantomas-online

Code

module OutdentingProblem =
    type Configuration = private { Setting1: int; Setting2: bool }

    let withSetting1 value configuration =
        { configuration with Setting1 = value }

    let withSetting2 value configuration =
        { configuration with Setting2 = value }

Result

module OutdentingProblem =
    type Configuration = private {
        Setting1: int
        Setting2: bool
    }

let withSetting1 value configuration = { configuration with Setting1 = value }

let withSetting2 value configuration = { configuration with Setting2 = value }

Problem description

If one uses an accessibility modifier in front of a record (I tried private, public, internal) the functions below it seem to get outdented.

Extra information

  • The formatted result breaks my code.
  • The formatted result gives compiler warnings.
  • I or my company would be willing to help fix this.

Options

Fantomas main branch at 2022-10-24T07:25:37Z - 529aa7d

    { config with
                MultilineBlockBracketsOnSameColumn = true
                ExperimentalStroustrupStyle = true }

Did you know that you can ignore files when formatting from fantomas-tool or the FAKE targets by using a .fantomasignore file?

@yreynhout yreynhout changed the title <Insert meaningful title> Outdenting problem when specifying record with accessibility modifier Oct 24, 2022
@nojaf
Copy link
Contributor

nojaf commented Oct 24, 2022

Hello, thank you for reporting this problem.

It appears we should not unindent in:

+> optSingle (fun _ -> unindent) ao'

That should be something along the lines of:

onlyIfCtx
  (fun ctx -> not (ctx.Config.ExperimentalStroustrupStyle && List.isEmpty ms))
  (optSingle (fun _ -> unindent) ao')

Are you interested in submitting a PR for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants