Better cursor movement
This commit is contained in:
parent
7aafdaa90f
commit
58a8c5c9e5
1 changed files with 10 additions and 2 deletions
12
src/state.rs
12
src/state.rs
|
|
@ -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 => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue