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 handling multi lines comment at the end of file after function application #810

Closed
matteobaglini opened this issue May 6, 2020 · 3 comments
Labels
good first issue Long hanging fruit: easy issue to get your feet wet!

Comments

@matteobaglini
Copy link
Contributor

Issue created from fantomas-online

Typically comments at the end of file stay there after formatting (see test), but if the comment is a multi line one ((* . . . *) block) and the the previous line is a function application, the comment is moved between function call and parameters.

Code

printfn "Hello World"
(* This is a comment. *)

Result

printfn
(* This is a comment. *) "Hello World"

Expected Result

printfn "Hello World"
(* This is a comment. *)

Note that with a single line comment (//) it works properly.

Options

Fantomas Next - 4.0.0-alpha-001-1/1/1990

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
MaxLetBindingWidth 40
MultilineBlockBracketsOnSameColumn false
NewlineBetweenTypeDefinitionAndMembers false
StrictMode false
@nojaf
Copy link
Contributor

nojaf commented May 8, 2020

Hello, this is a trivia bug. The block comment is now being assigned to the printfn Ident instead of the SynConst.String.

image
image

The problem occurs when the trivia is being assigned to a trivia node.
I think the addTriviaToTriviaNode case should be extended to support scenarios where the comment is the last line of the file.
Maybe it automatically should be assigned to the SynModule.

You can watch the first three videos on YouTube to understand how Fantomas works and what Trivia does.

I know this is a big ask, but could I persuade you to try and tackle this issue yourself?
This is a good first issue for newcomers.

@nojaf nojaf added the good first issue Long hanging fruit: easy issue to get your feet wet! label May 8, 2020
@matteobaglini
Copy link
Contributor Author

Forgive the delay response but you have definitely persuaded me 😄.

@nojaf
Copy link
Contributor

nojaf commented May 15, 2020

Hey @matteobaglini, very cool to hear 🤗!
Many thanks for this fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Long hanging fruit: easy issue to get your feet wet!
Projects
None yet
Development

No branches or pull requests

2 participants