Better cursor movement

This commit is contained in:
Joshua Barretto 2025-06-11 20:32:54 +01:00
parent 7aafdaa90f
commit 58a8c5c9e5

View file

@ -143,11 +143,19 @@ impl Buffer {
};
match dir {
Dir::Left => {
cursor.pos = cursor.pos.saturating_sub(dist[0]);
cursor.pos = if !retain_base && cursor.base < cursor.pos {
cursor.base
} else {
cursor.pos.saturating_sub(dist[0])
};
cursor.reset_desired_col(&self.text);
}
Dir::Right => {
cursor.pos = (cursor.pos + dist[0]).min(self.text.chars.len());
cursor.pos = if !retain_base && cursor.base > cursor.pos {
cursor.base
} else {
(cursor.pos + dist[0]).min(self.text.chars.len())
};
cursor.reset_desired_col(&self.text);
}
Dir::Up => {