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

Wrong indentation when accessing member of constructed record #383

Closed
alfonsogarciacaro opened this issue Dec 10, 2018 · 0 comments
Closed

Comments

@alfonsogarciacaro
Copy link
Contributor

Issue created from fantomas-ui

When I duplicate a record ({ myRecord with FieldA = 5 }) and immediately access a member, the indentation after formatting is wrong. The interesting part is that this only happens if the . to access the member is in a new line, but it's fantomas which puts the . in the new line. So the compilation error only appears after formatting twice the same code (it took me a while to realize this when I tried to reproduce the problem):

Step 1:

        match msg with
        | AMessage ->
            { model with AFieldWithAVeryVeryVeryLooooooongName = 10 }.RecalculateTotal()

Step 2 (after Fantomas formatting):

        match msg with
        | AMessage ->
            { model with AFieldWithAVeryVeryVeryLooooooongName = 10 }
                .RecalculateTotal()

Step 3 (after formatting again with Fantomas): compilation error

        match msg with
        | AMessage -> { model with AFieldWithAVeryVeryVeryLooooooongName = 10 }
                .RecalculateTotal()

Code

type MyRecord =
    { AFieldWithAVeryVeryVeryLooooooongName: int
      FieldB: int
      Total: int
    }
    member this.RecalculateTotal() =
        { this with Total = AFieldWithAVeryVeryVeryLooooooongName + FieldB }

type Msg =
    | AMessage
    | AnotherMessage

let update msg model =
    let res =
        match msg with
        | AMessage ->
            { model with AFieldWithAVeryVeryVeryLooooooongName = 10 }
                .RecalculateTotal()
        | AnotherMessage -> model
    res

Error

type MyRecord =
    { AFieldWithAVeryVeryVeryLooooooongName : int
      FieldB : int
      Total : int }
    member this.RecalculateTotal() =
        { this with Total = AFieldWithAVeryVeryVeryLooooooongName + FieldB }

type Msg =
    | AMessage
    | AnotherMessage

let update msg model =
    let res =
        match msg with
        | AMessage -> { model with AFieldWithAVeryVeryVeryLooooooongName = 10 }
                .RecalculateTotal()
        | AnotherMessage -> model
    res

Options

Fantomas 2.9.1

Name Value
IndentSpaceNum 4
PageWidth 80
PreserveEndOfLine false
SemicolonAtEndOfLine false
SpaceBeforeArgument true
SpaceBeforeColon true
SpaceAfterComma true
SpaceAfterSemicolon true
IndentOnTryWith false
ReorderOpenDeclaration false
SpaceAroundDelimiter true
StrictMode false
nojaf added a commit to nojaf/fantomas that referenced this issue Jan 17, 2019
@nojaf nojaf closed this as completed in e7ac8f8 Jan 17, 2019
nojaf added a commit to nojaf/fantomas that referenced this issue Jan 22, 2019
jindraivanek added a commit that referenced this issue Jan 22, 2019
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

1 participant