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

Comment gets duplicated #1912

Closed
2 tasks
knocte opened this issue Oct 8, 2021 · 1 comment · Fixed by #1914
Closed
2 tasks

Comment gets duplicated #1912

knocte opened this issue Oct 8, 2021 · 1 comment · Fixed by #1914

Comments

@knocte
Copy link
Contributor

knocte commented Oct 8, 2021

Issue created from fantomas-online

Code

type TorDirectory =
    private
        {
            NetworkStatus: NetworkStatusDocument
        }

    static member Bootstrap (nodeEndPoint: IPEndPoint) =
        async {
            return
                {
                    TorDirectory.NetworkStatus =
                        NetworkStatusDocument.Parse consensusStr
                    ServerDescriptors = Map.empty
                    // comment
                }
        }

Result

type TorDirectory =
    private
        { NetworkStatus: NetworkStatusDocument }

    static member Bootstrap(nodeEndPoint: IPEndPoint) =
        async {
            return
                { TorDirectory.NetworkStatus = NetworkStatusDocument.Parse consensusStr
                  ServerDescriptors = Map.empty
                // comment
                }
        // comment
        }

Extra information

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

Options

Fantomas 4.6 branch at 10/08/2021 09:24:03 - c12fa2d

Default Fantomas configuration

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

@nojaf
Copy link
Contributor

nojaf commented Oct 11, 2021

Hey, thanks for reporting this issue.
The problem here is that we currently consider the entire range of the computation expression to look for a closing RBRACE token that might have trivia.

+> enterNodeTokenByName synExpr.Range RBRACE

It will find the token from the record and think it is a match.
This can be resolved by limiting the range in which the token could possibly reside.
Something along the lines of

(fun ctx ->
                         let closingBraceRange =
                             ctx.MkRangeWith
                                 (synExpr.Range.EndLine, synExpr.Range.EndColumn - 1)
                                 (synExpr.Range.EndLine, synExpr.Range.EndColumn)

                         enterNodeTokenByName closingBraceRange RBRACE ctx)

Because of SynExpr.CompExpr has a range from the opening { to the closing one }.
Are you interested in submitting a PR?

su8898 added a commit to su8898/fantomless that referenced this issue Oct 12, 2021
su8898 added a commit to su8898/fantomless that referenced this issue Oct 12, 2021
su8898 added a commit to su8898/fantomless that referenced this issue Oct 12, 2021
su8898 added a commit to su8898/fantomless that referenced this issue Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants