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

Rotating adjacent selections' content breaks selection ranges #7272

Open
CptPotato opened this issue Jun 7, 2023 · 5 comments
Open

Rotating adjacent selections' content breaks selection ranges #7272

CptPotato opened this issue Jun 7, 2023 · 5 comments
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug

Comments

@CptPotato
Copy link
Contributor

Summary

I noticed that adjacent selections break when rotating their content.

Reproduction Steps

A simple way to reproduce this is to select every character in a word ( miw s.<ret> ) and then rotating the content ( A-( / A-) ). The resulting text is correct, but the selection ranges aren't.

Helix log

The log contains nothing related to the issue.

Platform

Windows

Terminal Emulator

wezterm

Helix Version

d1a4bd8 (master from 2023-05-02)

@CptPotato CptPotato added the C-bug Category: This is a bug label Jun 7, 2023
@CptPotato CptPotato changed the title Rotating adjacend selections' content breaks selection ranges Rotating adjacent selections' content breaks selection ranges Jun 7, 2023
@kirawi kirawi added the A-helix-term Area: Helix term improvements label Jun 10, 2023
@pascalkuthe
Copy link
Member

Hmm I am not entirely sure this is really considered a bug. We actually automatically merge adjacent ranges, anytime we do... anything. Adjacent ranges are sort of in a weird spot. Some commands can create them but they disappear almost immediately.

However considering we got a command to unify ranges I wonder if we should remove the automatic merging of adjacent ranges and only merge actuaually overlapping ranges.

Thaughts @the-mikedavis?

@CptPotato
Copy link
Contributor Author

Would there be a way to catch this and remove the secondary selections entirely in that case? Since the result is usually very unexpected:

image

image

@pascalkuthe
Copy link
Member

pascalkuthe commented Jul 14, 2023

That might be fixed by #5930

@the-mikedavis
Copy link
Member

I think we can allow some degree of overlapping/adjacent ranges like in #2298. We could experiment with allowing overlapping/adjacent ranges in some cases and see what breaks. I suspect there are some places that will need fixes / changes where we assume the invariants from Selection::ensure_invariants are all true.

@pascalkuthe
Copy link
Member

pascalkuthe commented Jul 15, 2023

i think truly overlapping ranges should still be unified (that won't feel great a lot of day-to-day tasks in helix kind of rely on cursors automatically unifying) and getting that invariant out of the codebase would be pretty hard too (for example it would undo the recent optimization to change mapping) but I think the edge-case of perfectly aligned selections should work without issue (once #5930 is merged) since those are already possible to create right now with `s' (and I can't think of a place where we would rely on that)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug
Projects
None yet
Development

No branches or pull requests

4 participants