Skip to content

Commit 0fffea1

Browse files
committed
sh: implement <control>-V input in vi mode
1 parent f2e1ba4 commit 0fffea1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

sh/src/cli/vi/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ enum EditorMode {
239239
Insert,
240240
Replace,
241241
Command,
242+
InsertNext,
242243
}
243244

244245
pub struct CommandError;
@@ -759,6 +760,7 @@ impl ViEditor {
759760
b'\x04' => return Ok(Action::Eof),
760761
b'\x16' => {
761762
// ^V
763+
self.mode = EditorMode::InsertNext;
762764
}
763765
b'\x17' => {}
764766
other if !other.is_ascii_control() => {
@@ -792,6 +794,15 @@ impl ViEditor {
792794
}
793795
}
794796
}
797+
EditorMode::InsertNext => {
798+
if self.cursor.position < self.edit_line.len() {
799+
self.edit_line.insert(self.cursor.position, c);
800+
} else {
801+
self.edit_line.push(c);
802+
}
803+
self.cursor.position += 1;
804+
self.mode = EditorMode::Insert;
805+
}
795806
}
796807
Ok(Action::None)
797808
}

0 commit comments

Comments
 (0)