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:
This should not only work for the |> operator, but also ||> and |||>. I don't think there's a way to make it work for custom pipe operators of higher arity (unless we simply detect operators called |(4+)> and consider them pipe operators in the same meaning by convention).
Can we make sure a <| operator somewhere in the chain doesn't mess things up in some way?
Can we make sure that doesn't wreck nested chains?
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.
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
Later changes often make it necessary to change the representation to span multiple lines:
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.If so, provide a light bulb suggestion to transform the pipe chain into a multi-line representation.
There are some complexities and complications here:
|>
operator, but also||>
and|||>
. I don't think there's a way to make it work for custom pipe operators of higher arity (unless we simply detect operators called|(4+)>
and consider them pipe operators in the same meaning by convention).<|
operator somewhere in the chain doesn't mess things up in some way?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.