Feature request: Move the cursor when expanding/collapsing
Opened this issue · 4 comments
Let's say I have the following method:
def foo(hello, world, ohai):
pass
Now I put my cursor on the first 'h' in 'hello'. After calling ArgWrap the code (as expected) becomes the following:
def foo(
hello,
world,
ohai,
):
pass
However, my cursor is on the opening parenthesis rather than the 'h' of hello. Now if put my cursor on the 'h' again and call ArgWrap, my cursor stays in the same place in the file and is therefore hovering over 'pass'. Therefore, I can't simply toggle ArgWrap back-and-forth because I have to move my cursor in between the calls.
It'd be great if the cursor tracked the argument that you're hovering over (or at the very least remained within the parenthesis) so that it was easier to toggle between the states.
I experienced this while testing this plugin for my use-case but after I used it a few time, i realised that in a real scenario I only format when i have to once & don't generally go back & forth between these.
But to maintain the context would be really helpful in cases like if we want to edit the parameters.
+1
I really would like this "spatial idempotency".
That is, being able to issue the same command many times to toggle back and forth seamlessly between wrapped and unwrapped states. It really helps with not breaking the "flow" when coding.
I am guessing that when wrapping, it is relatively easy as lines are added after the current location and thus simply return to the original line of invocation and then going to the end will work?
When de-wrapping we need to calculate the number of lines removed and figure out the cursor offset etc., so it is more complicated.
This issue can now be closed #24
@elythyr Thank you, works like a charm 🚀