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

Undo repeat_last_motion #12877

Open
ShiromMakkad opened this issue Feb 15, 2025 · 10 comments · May be fixed by #12884
Open

Undo repeat_last_motion #12877

ShiromMakkad opened this issue Feb 15, 2025 · 10 comments · May be fixed by #12884
Labels
C-enhancement Category: Improvements

Comments

@ShiromMakkad
Copy link

ShiromMakkad commented Feb 15, 2025

This is coming from: https://www.reddit.com/r/HelixEditor/comments/1ipjmxx/best_way_to_extend_selection_to_character/

Take a look at this snippet: #[default(entity_id("Action", "test-action"))] action: EntityUid.

Imagine I want to jump from the # at the beginning to the a in action. I'll use Alt-. which is bound to repeat_last_motion. If I go too far, I'll overshoot, now my selection is ruined. I'd like something like Vim's , key where you can search in the opposite direction. So if a user executed find_next_char and repeated it, this new action would execute find_prev_char.

This could also be implemented by #1596, but they're not the same interface

@ShiromMakkad ShiromMakkad added the C-enhancement Category: Improvements label Feb 15, 2025
@willbush
Copy link

willbush commented Feb 15, 2025

related: #8495

A maintainer seems interested in PR to implement this #12092 (comment)

Anyone implementing this should also checkout #8761 (comment)

I might give this ago myself since this drives me nuts as well.

@ShiromMakkad
Copy link
Author

If Mike is open to a PR I might do it myself as well. Seems like he's already given an approach, so I think it'll be doable as a first PR.

@willbush
Copy link

If Mike is open to a PR I might do it myself as well. Seems like he's already given an approach, so I think it'll be doable as a first PR.

I spent a bunch of time on this yesterday. Think I'll have a PR ready tonight.

@ShiromMakkad
Copy link
Author

Awesome, thanks!

@nik-rev
Copy link
Contributor

nik-rev commented Feb 16, 2025

Awesome, thanks!

Note, while the PR is really nice it doesn't actually solve your problem

There's a risk of overshooting, and I don't see a way to undo this, so I opened #12877.

If you have your cursor at the # here:

principal: EntityUid, #[default(entity_id("Action", "test-action"))] action: EntitayUid

And you press vta, then repeat with Alt-. 3 times instead of 2, your cursor ends up after the Enti. If you want to undo this with A-S-., your cursor will end up just after the first a in action, whilst you likely wanted to undo that movement such that it was as if the 3rd Alt-. never happened (so your cursor would be just before the first a in action)

(the way the PR implements this is correct actually, it works the same way in Vim. Just letting you know, and thinking about potential solutions to the above problem.)

@willbush
Copy link

(the way the PR implements this is correct actually, it works the same way in Vim. Just letting you know, and thinking about potential solutions to the above problem.)

some type of soft undo might solve it:

@willbush
Copy link

However, one could just A-S-. twice then redo the repeat with A-.:

screenrecord.mp4

@ShiromMakkad
Copy link
Author

hmmmm, that is kind of a problem. Yes you can go two back and one forward, but that isn't ideal. I don't really understand your last sentence. I opened up vi, searched for a character with f, and using , and ; did bring me back to the original character.

@willbush
Copy link

I was using t in the video above and that's what @nik-rev mentioned too. if I use f then it reverse twice is not needed. Works the same as vim.

@ShiromMakkad
Copy link
Author

ShiromMakkad commented Feb 18, 2025

I see. Honestly, I think this implementation and making it an exact undo command is valid, but the current behavior still leaves room for #1596 to be implemented.

Also, this could be used intentionally, although I don't think I would.

Unless an exact undo is easy, I wouldnt mind leaving it as is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Improvements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants