Support LeftInLine and RightInLine motions

This commit is contained in:
Jeremy Soller 2023-11-13 11:10:05 -07:00
parent b3c5f14e47
commit e942e649ed
No known key found for this signature in database
GPG key ID: DCFCA852D3906975

View file

@ -360,6 +360,14 @@ impl<'a> Edit for ViEditor<'a> {
return;
}
Motion::Left => Action::Left,
Motion::LeftInLine => {
let cursor = editor.cursor();
if cursor.index > 0 {
Action::Left
} else {
return;
}
}
Motion::Line => {
//TODO: what to do for this psuedo-motion?
return;
@ -570,6 +578,15 @@ impl<'a> Edit for ViEditor<'a> {
return;
}
Motion::Right => Action::Right,
Motion::RightInLine => {
let cursor = editor.cursor();
let buffer = editor.buffer();
if cursor.index < buffer.lines[cursor.line].text().len() {
Action::Right
} else {
return;
}
}
Motion::ScreenHigh => {
//TODO: is this efficient?
if let Some(first) = editor.buffer().layout_runs().next() {