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 inside LongIdentWithDots not preserved #2027

Closed
3 tasks
dbrattli opened this issue Jan 17, 2022 · 5 comments · Fixed by #2063
Closed
3 tasks

Comment inside LongIdentWithDots not preserved #2027

dbrattli opened this issue Jan 17, 2022 · 5 comments · Fixed by #2063

Comments

@dbrattli
Copy link

Issue created from fantomas-online

Code

let path =
    match normalizedPath with
    | path ->
        path  // translate path to Python relative syntax
            .Replace("../../../", "....")
            

Result

let path =
    match normalizedPath with
    | path -> path.Replace("../../../", "....")

Problem description

Fantomas removes comment in method dot chain. It looks tricky since the white-space where the
comment was has been removed. Perhaps the comment should be moved after the .Replace instead? Related to fable-compiler/Fable#2738

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 branch at 1/1/1990

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 Jan 17, 2022

Hello Dag, thank you for reporting this issue.
Fantomas is not considering trivia right now inside a LongIdentWithDots right now.

LongIdentWithDots([path; Replace], [tmp.fsx (5,12--5,13)])

Comments between dots are not printed, an easy workaround might be to move the comment above or below it.

Are you interested in submitting a PR for this one?

@nojaf nojaf changed the title Fantomas removes comment Comment inside LongIdentWithDots not preserved Jan 17, 2022
@dbrattli
Copy link
Author

Hi Florian, thanks for the info. Yes I can try. It would be interesting to learn more about the untyped AST. I'll have a look at it (next weekend)

@nojaf
Copy link
Contributor

nojaf commented Jan 17, 2022

Cool to hear! To get started, you can check out our Contribution Guidelines and take a peek at the YouTube channel.
If you have any questions, feel free to reach out.

@dbrattli
Copy link
Author

dbrattli commented Feb 6, 2022

@nojaf Sorry that I didn't have the bandwidth for looking into this

@nojaf
Copy link
Contributor

nojaf commented Feb 6, 2022

No worries, this would have been quite the challenge anyway for someone new to the codebase to pick up.
That being said, I'm working on other aspects of this project. So to see your own issues moving, I highly recommend scratching your own itch 😊.
I'm going to release this shortly as part of 4.6.2.

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