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

Vi copy mode: Reset cursor position after yank. At possibly ClearSelection or at action to be created? #7967

Open
tipa40 opened this issue May 11, 2024 · 7 comments

Comments

@tipa40
Copy link

tipa40 commented May 11, 2024

Hi,
In vim when you yank a selected text, the cursor position is reset to the first character of the selection as the visual/select mode is exited. In alacritty vi copy mode, the cursor position stays at the last character of the selection when ClearSelection command is executed. In my mind it would be nice if either ClearSelection resets the cursor or if there is a new action created/defined that could be used in place of ClearSelection that does, or any other way of implementing it.

Motivation:
In my use case it happens that I want to copy a line from the terminal and then move a couple of lines up copying another line(, having a clipboard manager being able to store multiple entries,). Starting at the previous selection horizontal start position I see is of greater use since needing to reposition the cursor horizontally is more rare as compared to now where not needing horizontal repositioning is rare.

System

OS: Ubuntu 24.04
Version: 0.13.2
Linux/BSD: SwayWM

@chrisduerr
Copy link
Member

Do you have any suggestions on how this would map to keybindings? Currently the vi mode binding is based on vi's base behavior, but flexible enough to be rebound to any sort of system that uses similar underlying mechanisms.

Implementing your suggestion would require stateful position tracking for the selection mode, would you want this to just always happen on ClearSelection, that wouldn't really feel intuitive to me.

@tipa40
Copy link
Author

tipa40 commented May 11, 2024

Hmm maybe it's not right to alter the behaviour of ClearSelection. Would it be reasonable to add a new action having restoring the position as its sole purpose? Am I missing your point by that question?

@chrisduerr
Copy link
Member

Would it be reasonable to add a new action having restoring the position as its sole purpose?

What would it restore to though? The last position the cursor was in when the selection was started? That seems oddly specific and difficult to grasp.

@tipa40
Copy link
Author

tipa40 commented May 12, 2024

Regarding the pure user experience, which is my actual request: I would like to be able to return to the starting position of where the cursor was when the selection was started when I perform a yank operation. Just as the user experience is in vim when selecting an area from visual mode followed by pressing "y".

What the best way of implementing the same in alacritty I do not have any strong opinion about since I'm not familiar with the code or your best practices/ideas around it. From there I can only come up with random ideas to try to make your case easier to achieve the described behaviour, not to try to lock you into any solution.

It will not at all have to be applied to ClearSelection or an action to be created. That was just what popped up in my mind as the first obvious thing I could think about, but that part could be skipped altogether as I see it. But then I wouldn't know what to suggest instead. The important thing to me is the behaviour itself.

I would probably need a bit more background to come up with good ideas. Maybe you have some idea on how it would best be achieved?

@tipa40 tipa40 changed the title Vi copy mode: Reset cursor position at ClearSelection or at action to be created Vi copy mode: Reset cursor position after yank. At possibly ClearSelection or at action to be created? May 12, 2024
@chrisduerr
Copy link
Member

Maybe you have some idea on how it would best be achieved?

My whole point is that there is no good way. That's why it is the way it is right now. And I don't personally care enough about this to change it.

@tipa40
Copy link
Author

tipa40 commented May 13, 2024

That of course is your decision. The important thing to me is that I have done what I can in this matter. Thanks anyway for keeping it and labeling it up for possible implementation.

@chrisduerr
Copy link
Member

The important thing to me is that I have done what I can in this matter.

I'm happy to look at patches, even if I have no interest in it myself.

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

No branches or pull requests

2 participants