question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Code reformat breaks the code

See original GitHub issue

When running code Reformat Code (cmd+opt+L), the produced code is broken because of indentation when using [<Annotations>]:

[<CLIMutable>]
type CreateUser =
    { [<JsonRequired>]
      Name: string }

is changed to:

[<CLIMutable>]
type CreateUser =
    {  [<JsonRequired>]
      Name: string }

^ Notice the extra space in front of [<JsonRequired>]. That make the code on the next line “off side”, which causes the whole parsing to fail.


Also, one unrelated question: I read on fantomas’ site that Rider uses it for its formatting. However, fantomas’ formatting is way more opinionated than Rider’s. Imo that’s mostly a good thing, but it would be nice if it was configurable so that I could choose fantomas’ more opinionated formatting if I wanted to.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
auduchinokcommented, Aug 16, 2019

@nojaf : Trying the code above in the online tool you linked gives correct code. When I do the same in Rider, it gives the wrong code.

This could be due to Rider uses different default settings compared to the online tool. We have PreserveEndOfLine enabled by default to try to preserve used formatting style where possible.

Is there an ETA on that? Also, can you add formatting options to the (fantomas) code formatting in Rider? Fantomas has a ton of options

All Fantomas options are already in File | Settings | Editor | Code Style | F#.

1reaction
auduchinokcommented, Dec 24, 2019

Fixed in 2019.3 with Fantomas update.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VS code formatting breaks the code unexpectedly in .js files
I am a newbie in React. I am using vscode. Whenever I save app.js file, it formats the whole code and throws errors....
Read more >
Reformat code | IntelliJ IDEA Documentation
IntelliJ IDEA lets you reformat your code according to the requirements you've specified in your current code style scheme or the .editorconfig file....
Read more >
Code formatting: is it worth to make bad code to look bad?
Not only bad formatting makes it harder to improve the code, but also, bad (or, more likely, unfamiliar) formatting may make code look...
Read more >
Automatically reformat Python code in Visual Studio
Automatically format Python code in Visual Studio, including spacing, statements, wrapping, and comments.
Read more >
Code formatting
This helps the automatic formatter to insert an appropriate amount of line breaks for Flutter-style code. Here is an example of automatically formatted...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found