tweekmonster / braceless.vim

:snake: Text objects, folding, and more for Python and other indented languages.
395 stars 13 forks source link

Continuation slash added inside parenthesis block #27

Closed kyokley closed 8 years ago

kyokley commented 8 years ago

When editing python, it seems like backslashes are being added sometimes for code that already exists within parentheses. I've tried tracking down the exact scenario that triggers the issue but was mostly unsuccessful. I know that I've seen it occur when trying to break up long lines of code or attempting to return a tuple from a function.

For example, if I start with the following:

from foo import x, y, z

Then try to move each import unto a separate line, I end up with:

from foo import (x, \
                 y, \
                 z)

Is this the expected behavior?

tweekmonster commented 8 years ago

@kyokley No this is not expected behavior. I haven't fixed it yet because I've been working on formatting behavior. I haven't tested it fully yet, but you can use the WIP branch I just pushed to deal with this problem and also be my guinea pig :grin:

https://github.com/tweekmonster/braceless.vim/tree/simple-format

Not only will line continuations not appear in your case, you can also break up strings and rejoin lines without all the unnecessary extra spaces and line continuations.

kyokley commented 8 years ago

Thanks for taking a look. I loaded up the branch but I'm still seeing the same behavior. I wish I could be of more help but I'm still learning how vimscript works. I'm happy to be a guinea pig though if there's anything else you'd like me to try.

tweekmonster commented 8 years ago

@kyokley You should only be seeing line continuations when the imports aren't wrapped in parenthesis.

Line continuations are added if there aren't inside of parenthesis.

kyokley commented 8 years ago

Ah, I see. I wasn't starting with both parentheses in place. I can work with that. Thanks again.

tweekmonster commented 8 years ago

Yeah, it's a stopgap for now. I'm working on full auto-formatting that will wrap the imports in parenthesis and break them into lines if you go over your textwidth in Vim. It's taking more time than I expected because there's a lot of different situations (not just imports I mean). The branch I pushed is the half way point so you can at least press enter in some key parts to get format assistance.

tweekmonster commented 8 years ago

@kyokley I'm planning to merge the previously mentioned branch tonight just to keep moving forward with my other autoformat work. Have you noticed anything that would be a blocker for the merge?

kyokley commented 8 years ago

I haven't had a chance to use it very extensively but during that time, I haven't noticed any problems.

tweekmonster commented 8 years ago

@kyokley This is merged into master now. My schedule didn't work out as planned when I mentioned merging before.