Skip to content
This repository has been archived by the owner on Dec 26, 2023. It is now read-only.

Feature request: Move the cursor when expanding/collapsing #7

Open
ealter opened this issue Jul 8, 2016 · 4 comments
Open

Feature request: Move the cursor when expanding/collapsing #7

ealter opened this issue Jul 8, 2016 · 4 comments

Comments

@ealter
Copy link

ealter commented Jul 8, 2016

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.

@PezCoder
Copy link

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.

@jeetsukumaran
Copy link
Contributor

+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.

@camilledejoye
Copy link
Contributor

This issue can now be closed #24

@PezCoder
Copy link

@elythyr Thank you, works like a charm 🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants