sideways.vim icon indicating copy to clipboard operation
sideways.vim copied to clipboard

SidewaysJump* little issues

Open andreiglingeanu opened this issue 8 years ago • 6 comments

  1. When I have this line of code (cursor is ^):
= f.text_field :email, autofocus: true, class: "form-control", placeholder: "Email", :"ng-model"=>'email', :'ng-change'=>'detect2factorAuth()'
---^

And I execute :SidewaysJumpRight it doesn't take me to the next argument. Is this by purpose? 2) When I have this long line of code (cursor is ^):

= f.text_field :email, autofocus: true,
                     class: "form-control", placeholder: "Email", :"ng-model"=>'email',
----------------------^
                     :'ng-change'=>'detect2factorAuth()'

And I execute :SidewaysJumpRight it also doesn't work. In this case :Sideways* also doesn't work.

I understand that this maybe is an implementation difficulty.

andreiglingeanu avatar Oct 11 '15 10:10 andreiglingeanu

Sorry for taking a while to respond.

  1. The plugin works on arguments, which is why it expects that the cursor is on one of them. In your case, I guess you should first place your cursor on :email before jumping around arguments. This is due both to being easier to implement (it's a useful assumption that you'd be on an argument, lets me safely go backwards to search for the function beginning) and because I'm not sure how the plugin should work if it's not on an argument. For instance, moving an argument right-wise doesn't make sense, but maybe jumping does (so it jumps on the first one). I'll think about how I can fit this within the plugin, but I can't promise anything.

  2. This is definitely due to implementation difficulties. To be honest, I'd like to be able to manipulate arguments over several lines as well, but right now, sideways only works on a single line. In these cases, I use my splitjoin plugin to join lines up, move things around, and then split them back, but it has its limitations.

I would like to get this to work. I can think of a possible way to do this, but I'll have to see if it works well enough

AndrewRadev avatar Nov 04 '15 16:11 AndrewRadev

I've pushed a branch called multiline, in which I've tried to get sideways to work for multiline argument lists. So far, the existing tests are passing and some simple experiments seem to work. But I'm super sure there are going to be issues in a larger file with more complicated edge cases. For instance, I'm worried whether the loop that looks for arguments would even terminate correctly on all occasions.

I'm going to use this branch for the moment and try to fix things as they pop up. I'd appreciate if you were to test it as well and let me know what breaks.

AndrewRadev avatar Nov 21 '15 10:11 AndrewRadev

Very nice! I have lost access to my laptop these days. Will get in touch with some feedback in 3 days.

andreiglingeanu avatar Nov 21 '15 11:11 andreiglingeanu

I have tested multiline branch. I covers fully my use cases. Will try to use it in my day-to-day work. Will come back with more feedback.

andreiglingeanu avatar Nov 24 '15 18:11 andreiglingeanu

Just giving you a heads-up that I've merged the "multiline" branch into master. I had some fixes to both ones and I figured maybe it's time to just get it done anyway. It seems stable to me, although if you run into bugs, let me know.

This covers point 2 on your list, and I don't think I'll be able to do anything about point 1 for now. Still, I don't mind leaving the issue open for a while. I plan to revisit old issues whenever I can and I might figure something out in the future.

AndrewRadev avatar Jan 06 '16 13:01 AndrewRadev

Great, thank you :+1:

andreiglingeanu avatar Jan 06 '16 14:01 andreiglingeanu