fantomas icon indicating copy to clipboard operation
fantomas copied to clipboard

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

Open johlrich opened this issue 4 years ago • 6 comments

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 - d9626947f6fee1fd19dcde4db056d2ed88b4fa0b

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

johlrich avatar Jun 24 '20 22:06 johlrich

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

rbrus avatar Jul 20 '20 06:07 rbrus

@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:

  • https://www.youtube.com/watch?v=FCrkUqCCzgI

nojaf avatar Aug 07 '20 09:08 nojaf

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

rbrus avatar Aug 07 '20 09:08 rbrus

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.

nojaf avatar Aug 07 '20 09:08 nojaf

@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.

rbrus avatar Aug 07 '20 10:08 rbrus

Here's a similar one:

Issue created from fantomas-online

Code

a [] [
    // def
]

Result

a [] []

reinux avatar Oct 02 '20 00:10 reinux