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 13:04:07 -04:00
committed by GitHub
parent 20be133713
commit 9a2b7ef372
3 changed files with 162 additions and 144 deletions
+13
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;