@@ -380,6 +380,29 @@ pub fn extend_prev_char(cx: &mut Context) {
383+pub fn replace(cx: &mut Context) {
384+ // need to wait for next key
385+ cx.on_next_key(move |cx, event| {
387+ code: KeyCode::Char(ch),
391+ let text = Tendril::from_char(ch);
393+ let mut doc = cx.doc();
396+ Transaction::change_by_selection(doc.text(), doc.selection(), |range| {
397+ (range.from(), range.to() + 1, Some(text.clone()))
400+ doc.apply(&transaction);
401+ doc.append_changes_to_history();
383fn scroll(view: &mut View, offset: usize, direction: Direction) {
406fn scroll(view: &mut View, offset: usize, direction: Direction) {
384 use Direction::*;
407 use Direction::*;
385 // we use short lived borrows since view's methods read from doc too
408 // we use short lived borrows since view's methods read from doc too