Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A case that sideways.vim ignores #45

Open
you-n-g opened this issue Oct 25, 2020 · 2 comments
Open

A case that sideways.vim ignores #45

you-n-g opened this issue Oct 25, 2020 · 2 comments

Comments

@you-n-g
Copy link

you-n-g commented Oct 25, 2020

Hi,
Sideways is realy a great plugin that saves me a lot of time.
It works as what I expected most of the time.

But it ignores a case that happens in my daily work.

a, b, c = 1, 2, 3

Sideways can't move a, b or c left or right.
There is the same issue with 1, 2 or 3.

Thanks in advance if you can consider such case!

@you-n-g you-n-g changed the title A case that sideways.vim ingores A case that sideways.vim ignores Oct 25, 2020
@AndrewRadev
Copy link
Owner

Sideways is realy a great plugin that saves me a lot of time.

Thanks, I'm happy to hear that.

The problem with supporting this use case is that, currently, sideways needs to know how a list starts in order to decide how to work with it. For instance, if you have foo(1, 2, 3), the plugin looks for an opening ( and if it finds it, considers it the start of a list with comma-separated items. Here's the relevant definition even:

\ 'start': '(\_s*',
\ 'end': ')',
\ 'delimiter': ',\_s*',
\ 'brackets': ['([{''"', ')]}''"'],

Could the "start" be defined simply as the start of the line? Sort of. I've created a branch, variable-assignments, which implements this, with some tweaks. The problem is, it breaks a lot of other cases, for instance:

foo = [
  one, two,
  three, four
]

With the cursor on the last item, the plugin finds a valid start at the beginning of three, four and only works on that area. You'd think that it would give up because it doesn't find an ending =, but it finds a closing bracket, and the behaviour of the plugin is to consider that an "end", so that, for instance, if you have something like [1, 2, function_call 3, 4], the function_call would be detected correctly.

I don't have a good solution to this. The branch is there, and you could experiment with it, but I think it'll break too many other cases. I'll keep thinking about a possible solution, but the general rule of the plugin is "detect the type of list based on the start".

@you-n-g
Copy link
Author

you-n-g commented Nov 9, 2020

Is it OK to make it only works when the beginning and ending are in the same sideways_definition dict?

In your case, it find a closing bracket as the ending, but it is not paired with the previous found beginning(the start of the line).

Thanks.

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

No branches or pull requests

2 participants