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

Comments can be lost or shifted when at the end of expressions. #932

Open
johlrich opened this issue Jun 24, 2020 · 6 comments
Open

Comments can be lost or shifted when at the end of expressions. #932

johlrich opened this issue Jun 24, 2020 · 6 comments

Comments

@johlrich
Copy link
Contributor

Issue created from fantomas-online

Please describe here fantomas problem you encountered

Comments can be lost or shifted when at the end of expressions.

Code

let value = 
    // comment on the front
    let x = 2
    x * x
    // comment on the back

let something () = 
    async {
        // return "foo"
        return "bar"
        // return "baz"
    }

Result

let value =
    // comment on the front
    let x = 2
    x * x
// comment on the back

let something () =
    async {
        // return "foo"
        return "bar"
    }

Options

Fantomas Master at 06/24/2020 06:54:29 - d962694

Name Value
IndentSpaceNum 4
PageWidth 120
SemicolonAtEndOfLine false
SpaceBeforeParameter true
SpaceBeforeLowercaseInvocation true
SpaceBeforeUppercaseInvocation false
SpaceBeforeClassConstructor false
SpaceBeforeMember false
SpaceBeforeColon false
SpaceAfterComma true
SpaceBeforeSemicolon false
SpaceAfterSemicolon true
IndentOnTryWith false
SpaceAroundDelimiter true
MaxIfThenElseShortWidth 40
MaxInfixOperatorExpression 50
MaxRecordWidth 40
MaxArrayOrListWidth 40
MaxValueBindingWidth 40
MaxFunctionBindingWidth 40
MultilineBlockBracketsOnSameColumn false
NewlineBetweenTypeDefinitionAndMembers false
KeepIfThenInSameLine false
MaxElmishWidth 40
StrictMode false
@rbrus
Copy link

rbrus commented Jul 20, 2020

I think this should be reopened and put into the highest priority. Formatting in VSC regularly removes comments. I don't know what I have lost till today but probably a lot of useful or critical comments.

image

@nojaf
Copy link
Contributor

nojaf commented Aug 7, 2020

@rbrus this is a very complex and layered problem, the screenshot you posted illustrates the same type of bug but there is no one fix that will magically tackle both cases here.
Please report every problem you have the missing comments as an individual issue.
Block comments versus line comments alone are already a significant difference.

To get some more context of what is going wrong here you can watch:

@rbrus
Copy link

rbrus commented Aug 7, 2020

@nojaf I understand there is no magic, sorry for reporting it.

@nojaf
Copy link
Contributor

nojaf commented Aug 7, 2020

No, don't get me wrong @rbrus reporting is a good thing!
All I wanted to say is that in this case, it is better to report each individual case.

@rbrus
Copy link

rbrus commented Aug 7, 2020

@nojaf no, you just wanted to prove me that I should not write with this tone, or I am exaggerating that there are more issues like this. And I really don't have time to go alone through hundreds of commits to find the one which has this issue.

And I can tell you why!

Formatting often changes 80% of the code (in terms of selection when compared with different tools). As you should understand as you are the maintainer. I would need to go line by line in all 'big changes' commits, and go through every commit to find these commits and then try to find the issues.

I did what I can at the time, reported, gave you the latest example checked quickly if this is reproducible (and yes it is), and hoped that code related to comments is in one place so you will be able to find it.

Especially in this case, comments are removed, so it obviously sounds that some value in some functions which formats this type of code is skipped. If your code is complex on the level you cannot debug / find it, then I cannot help you more at this time.

@reinux
Copy link

reinux commented Oct 2, 2020

Here's a similar one:

Issue created from fantomas-online

Code

a [] [
    // def
]

Result

a [] []

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

No branches or pull requests

5 participants