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

Currying a pair gets spread over multiple lines #1700

Closed
3 tasks
pbiggar opened this issue May 5, 2021 · 3 comments · Fixed by #1701
Closed
3 tasks

Currying a pair gets spread over multiple lines #1700

pbiggar opened this issue May 5, 2021 · 3 comments · Fixed by #1701

Comments

@pbiggar
Copy link
Contributor

pbiggar commented May 5, 2021

Issue created from fantomas-online

Code

// Actual code
if List.any ((=) (ownerName, username)) specialCases then 6

// Reduced version
((=) (ownerName, username))

Result

// Actual code
if List.any
    ((=)
        (
            ownerName,
            username
        ))
    specialCases then
    6

// Reduced version
((=)
    (
        ownerName,
        username
    ))

Problem description

I would expect this code to be kept in one line:

if List.any ((=) (ownerName, username)) specialCases then 6

Extra information

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

Options

Fantomas Master at 05/01/2021 14:37:19 - d8e76d4

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 May 6, 2021

This problem was introduced while fixing #1341.
I believe we miss a check whether the code is short in

| AppParenArg (Choice2Of2 (Paren _, _, _, _, _) as app) -> genAlternativeAppWithParenthesis app astContext

we want something like

        | AppParenArg (Choice2Of2 (Paren _, _, _, _, _) as app) ->
            let short =
                match app with
                | Choice1Of2 (a, lpr, ts, tr, rpr, pr) -> sepNone // TODO
                | Choice2Of2 (a, lpr, p, rpr, pr) -> sepNone // TODO

            let long = genAlternativeAppWithParenthesis app astContext
            expressionFitsOnRestOfLine short long

I don't time right now to provide a complete solution but you might get the idea.
Would you be interested in submitting a PR?

@pbiggar
Copy link
Contributor Author

pbiggar commented May 6, 2021

Would you be interested in submitting a PR?

Gonna try for an hour or two :)

@nojaf
Copy link
Contributor

nojaf commented May 6, 2021

Great! You can start out with going through the Contribution Guidelines.
The first set of YouTube videos might also be useful to get started.
Let me know if you have any questions.

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