fsprojects / fantomas

FSharp source code formatter
https://fsprojects.github.io/fantomas
Other
764 stars 190 forks source link

[Feature request] `then` on new line #2940

Closed IgorErin closed 11 months ago

IgorErin commented 1 year ago

I believe my project needs support for an option that allows you to transfer if, as follows

if expr1 then
    expr2
else 
    expr3

Should, in my opinion, support conversion to the following two formats (on a par with if expr1 then expr2 else expr3)

if expr1 
then expr2 
else expr3

or

if expr1 
then 
    expr2 
else 
    expr3

or

if expr1 
then expr2 else expr3

Unfortunately, I do not know if this functionality is supported, since I have not found a single place where I could get acquainted with a complete list of all the formatting features of your tool. (Could you tell me if there is one?)

UPD: Regarding all this, I found this request. Is it possible to make this a separate option?

Is it possible to separate this from max_line_length? Is it possible to make it more optional and how optional can it be done? We are ready to help in the implementation of this functionality.

Pros and Cons

In our opinion, this will improve the readability and maintainability of the code, as it will clearly distinguish two branches of execution.

Examples

if type'' = typeof<bool> then typeof<BoolHostAlias> else type'' ->

if type'' = typeof<bool> 
then typeof<BoolHostAlias> else type''
if vType :? RefType<_> && globalVars |> List.contains variable.Name then
    declSpecs.AddressSpaceQualifier <- Global
elif vType :? RefType<_> && localVars |> List.contains variable.Name then
     declSpecs.AddressSpaceQualifier <- Local

->

if
    vType :? RefType<_> &&
    globalVars |> List.contains variable.Name
then
     declSpecs.AddressSpaceQualifier <- Global
elif
     vType :? RefType<_> &&
     localVars |> List.contains variable.Name
then
     declSpecs.AddressSpaceQualifier <- Local

Affidavit (please submit!)

Please tick this by placing a cross in the box:

Please tick all that apply:

nojaf commented 11 months ago

Hello! We noticed that you might have missed the chance to go through our contribution guidelines. We've laid out some helpful insights there on why we're not pursuing this specific feature. You can find more details here. Your understanding is greatly appreciated!