helix: Change f and t motions (#35216)

In vim and zed (vim and helix modes) typing "tx" will jump before the
next `x`, but typing it again won't do anything. But in helix the cursor
just jumps before the `x` after that. I added that in helix mode.
This also solves another small issue where the selection doesn't include
the first `x` after typing "fx" twice. And similarly after typing "Fx"
or "Tx" the selection should include the character that the motion
startet on.

Release Notes:

- helix: Fixed inconsistencies in the "f" and "t" motions
This commit is contained in:
fantacell 2025-08-14 19:04:07 +02:00 committed by GitHub
parent 20be133713
commit 9a2b7ef372
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 162 additions and 144 deletions

View file

@ -104,6 +104,19 @@ impl<T: Copy + Ord> Selection<T> {
self.goal = new_goal;
}
pub fn set_head_tail(&mut self, head: T, tail: T, new_goal: SelectionGoal) {
if head < tail {
self.reversed = true;
self.start = head;
self.end = tail;
} else {
self.reversed = false;
self.start = tail;
self.end = head;
}
self.goal = new_goal;
}
pub fn swap_head_tail(&mut self) {
if self.reversed {
self.reversed = false;