You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One editing operation that often comes up is wrapping a subtree in another node.
An example that happened to me recently in Rust if changing Type to Option<Type> in several places.
It'd be really great if we could have such wrapping operation built-in, as that'd help with these. However there's an interesting case - what if I wanted to wrap into Result? Which type parameter should be picked?
I envision something like this:
wo - wrap as Option<T>, no indication is needed as it's obviously one w1r - wrap as Result<T, _> w2r - wrap as Result<_, T> w1o - same as wo wr - error because of ambiguity (but equivalent to w1r would also make sense as this operation is more common in case of Result)
Dot command should work with this too, also multi-cursor operations. (Select all occurrences of Type within a subtree and wrap them.)
The text was updated successfully, but these errors were encountered:
Yep I'd like to see this too 😃. I was thinking that you could have w for 'wrap' and W for 'wrap individually', so you could e.g. turn {<true>, <false>} into {<[true]>, <[false]>} (W) or {<[true, false]>} (w). Slurp and barf are also cool and useful.
I'm not sure sure how I feel about having shortcuts for Option and Result, on the basis that you might want to wrap with any type - much easier I reckon to perform the wrap and then put the user into 'stringly-edit' mode to let them enter the name themselves. If the LSP/intellisense is good enough, then you should be able to type o<tab> to get Option, and r<tab> to get Result. Not ideal in terms of key inputs, but I don't think the gain of having special shortcuts for types in the prelude is worth the extra memory load...
Yeah, I didn't mean specific shortcuts, they were just examples. But having an option to have a binding for such shortcuts would be cool. I'd definitely try these specific to see how it improves experience.
One editing operation that often comes up is wrapping a subtree in another node.
An example that happened to me recently in Rust if changing
Type
toOption<Type>
in several places.It'd be really great if we could have such wrapping operation built-in, as that'd help with these. However there's an interesting case - what if I wanted to wrap into
Result
? Which type parameter should be picked?I envision something like this:
wo
- wrap asOption<T>
, no indication is needed as it's obviously onew1r
- wrap asResult<T, _>
w2r
- wrap asResult<_, T>
w1o
- same aswo
wr
- error because of ambiguity (but equivalent tow1r
would also make sense as this operation is more common in case ofResult
)Dot command should work with this too, also multi-cursor operations. (Select all occurrences of
Type
within a subtree and wrap them.)The text was updated successfully, but these errors were encountered: