fsprojects-archive / zzarchive-VisualFSharpPowerTools

[ARCHIVED] Power commands for F# in Visual Studio
http://fsprojects.github.io/VisualFSharpPowerTools/
Apache License 2.0
310 stars 77 forks source link

Provide a way to change a pipe chain written on one line into a multi-line representation #1488

Closed TeaDrivenDev closed 7 years ago

TeaDrivenDev commented 7 years ago

Conceptually, this is quite similar to #1487, but probably requires a vastly more complex implementation.

Description

There should be a way to easily "transpose" a pipe chain written on one line into the equivalent multi-line representation.

Short pipe chains are often written in one line like

inputs |> Seq.filter (fun x -> x.Number > 20) |> Seq.pairwise

Later changes often make it necessary to change the representation to span multiple lines:

inputs
|> Seq.filter (fun x -> x.Number > 20)
|> Seq.pairwise

Depending on the length of the chain (and possibly local circumstances in the code), this requires quite a bit of fiddly and mechanical work for navigation, indentation and removing trailing spaces.

Expected behavior

When X, detect if the whole pipe chain is on one line.

I am not sure about X here. I see two possibilities:

  • The entire expression that the pipe chain constitutes is selected (this seems easier to implement)
  • The caret is on one (or only the first?) pipe operator in the chain (this would be much nicer to use)

If so, provide a light bulb suggestion to transform the pipe chain into a multi-line representation.

There are some complexities and complications here:

Transforming a multi-line pipe chain into a single-line representation should be of similar complexity, but only under the condition that each of its parts takes up exactly one line. If that can be reliably detected, an equivalent light bulb suggestion could be displayed for the X of respective pipe chains.