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-z>i within original selection should produce result #3560

Open
vbauerster opened this issue Jun 21, 2020 · 3 comments
Open

<a-z>i within original selection should produce result #3560

vbauerster opened this issue Jun 21, 2020 · 3 comments

Comments

@vbauerster
Copy link
Contributor

vbauerster commented Jun 21, 2020

I wish <a-z>i would allow me to intersect two selection lists with not equal number of elements (selections), if other selections are within original one. It's hard to explain with words so here is illustration:

alt-z.png

So selection is saved first with Z, then we have two more selections with help of <a-S> (both are within original), next we want to intersect in order to get result as depictured above on third line.

At the moment <a-z>i complains like the two selection lists don't have the same number of elements (1 vs 2).

Also imo following (same number of selections, but the second one is within the first one) should also work like this:

one-within.png

@mreppen
Copy link
Contributor

mreppen commented Jun 23, 2020

This is the same feature I requested here: #3504
I am currently running with my own patch and love this feature. My patch is only a proof of concept. Note that the order, i.e., which selection is removed from which, is reversed.

PS.
I don't think this should be called intersection. Seeing selections as sets, it is a difference/subtraction.

@vbauerster
Copy link
Contributor Author

vbauerster commented Jun 23, 2020

You're right this is not intersection.

If we assume that selected (by anchor or cursor) cell is 1 and not selected is 0, then current intersection behaviour is AND table, survives 1 and 1:
intersection.png

Difference/subtraction is like negated AND table, we negate the result of AND operation:
diff.png

The tricky part is that current implementation doesn't allow to combine single selection with multiple or vise versa. But I reckon for difference/subtraction operation it should.

PS: all above illustrations represent single line combined with Z and <a-z>, not three liens.

@mreppen
Copy link
Contributor

mreppen commented Jun 23, 2020

@vbauerster I might be misunderstanding you, but no, it is not "negated AND". What you describe in your second example is the symmetric difference https://en.wikipedia.org/wiki/Symmetric_difference
That's actually why I called it subtraction: to avoid confusion with symmetric difference.

From your example, I'm quite convinced it's subtraction. Please have a look at the linked issue and I think you will agree.

In that issue, we also discuss paired vs non-paired operations, which likely relates to what you call single/multiple. Please check it out and join the discussion.

Also, if you want to try it out, this is my non-paired ("multiple") patched version https://github.com/mreppen/kakoune/tree/subtract
But as I said, keep in mind that I coded the order opposite of what you described (A\B vs B\A).

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

No branches or pull requests

2 participants