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.

Rider doesn't respect setting: fsharp_multi_line_lambda_closing_newline

See original GitHub issue

Rider version 2021.2 EAP 8 (and previous versions) doesn’t respect the fsharp_multi_line_lambda_closing_newline formatting option from Fantomas which results in a mismatch between the formatting from Rider and the CLI tool.

My understanding is that the current EAP uses the newest version of this plugin from branch net212 and this branch is on the latest Fantomas version (4.5.0) which I use locally.

Repro Steps

  1. Add .editorconfig to project
root = true

# Based on: https://github.com/G-Research/fsharp-formatting-conventions/blob/master/.editorconfig
# Difference is: disable_elmish_syntax=false and single_argument_web_mode=true
[*.fs]
fsharp_single_argument_web_mode=true
fsharp_space_before_uppercase_invocation=true
fsharp_space_before_member=true
fsharp_space_before_colon=true
fsharp_multiline_block_brackets_on_same_column=true
fsharp_newline_between_type_definition_and_members=true
fsharp_keep_if_then_in_same_line=true
fsharp_align_function_signature_to_indentation=true
fsharp_alternative_long_member_definitions=true
fsharp_disable_elmish_syntax=false
fsharp_multi_line_lambda_closing_newline=true
  1. Add code that contains a lambda. For example:
let x =
    [ "Item"; "Item"; "Item" ]
    |> List.mapi (fun i x ->
        let index = i + 1
        sprintf "%s: %i" x index
    )
  1. Format it with Ctrl+Alt+L

Expected Result

let x =
    [ "Item"; "Item"; "Item" ]
    |> List.mapi (fun i x ->
        let index = i + 1
        sprintf "%s: %i" x index
    )

Actual Result

let x =
    [ "Item"; "Item"; "Item" ]
    |> List.mapi
        (fun i x ->
            let index = i + 1
            sprintf "%s: %i" x index)

Repository

I have made a small repo that contains minimal code for reproducing this error: https://github.com/panmau/rider-fantomas-repro

Environment

Rider version: Rider 2021.2 EAP 8 Fantomas CLI: 4.5.0 OS: Manjaro Linux 21.1.0 Pahvo

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
panmonacommented, Jul 23, 2021

@auduchinok @DedSec256 Thank you for taking a look at this and the continued improvements regarding the integration of Fantomas in Rider. I’m looking forward to the release of the bug fix!

3reactions
auduchinokcommented, Jul 23, 2021

@panmau Thanks for such a comprehensive report!

Some settings weren’t added during recent Fantomas updates, and we currently have to do it manually during updates. It’s too late to merge a fix to 2021.2 release, but https://github.com/JetBrains/resharper-fsharp/pull/298 is going to be included in a bug fix update. The logic implemented in https://github.com/JetBrains/resharper-fsharp/pull/261 allows us not to maintain the settings list altogether, so it’ll be harder to lose a setting like this in 2021.3 and going forward.

Read more comments on GitHub >

github_iconTop Results From Across the Web

F# code formatting guidelines
In case the arguments of a lambda do not fit on a single line, or are multiline themselves, put them on the next...
Read more >
EditorConfig properties for C#: Line Breaks
This page lists custom JetBrains Rider EditorConfig properties that you can use to configure formatting preferences in C#, specifically, ...
Read more >
Configuration
editorconfig file and will be picked up automatically by the commandline. Your IDE should respect your settings, however the implementation of that is...
Read more >
C# multi-line lambda expression [duplicate]
Closed 8 years ago. I want to print a percentage value in one (or more) integer intervals. The code below describes object.ProgressChanged ...
Read more >
Why Use F#? | Hacker News
In my opinion it's honestly the best statically typed general purpose programming language. f# and also Ocaml strike for me the right ...
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