@@ -368,7 +368,6 @@ pub fn open_below(view: &mut View, _count: usize) {
368368 let transaction = Transaction::change(&view.state, changes).with_selection(selection);
369369
370370 transaction.apply(&mut view.state);
371− // TODO: need to store into history if successful
372371}
373372
374373// O inserts a new line before each line with a selection
@@ -420,48 +419,49 @@ pub fn goto_mode(view: &mut View, _count: usize) {
420419 view.state.mode = Mode::Goto;
421420}
422421
423−// TODO: insert means add text just before cursor, on exit we should be on the last letter.
424−pub fn insert_char(view: &mut View, c: char) {
425− let c = Tendril::from_char(c);
426− let transaction = Transaction::insert(&view.state, c);
422+// NOTE: Transactions in this module get appended to history when we switch back to normal mode.
423+pub mod insert {
424+ use super::*;
425+ // TODO: insert means add text just before cursor, on exit we should be on the last letter.
426+ pub fn insert_char(view: &mut View, c: char) {
427+ let c = Tendril::from_char(c);
428+ let transaction = Transaction::insert(&view.state, c);
427429
428− transaction.apply(&mut view.state);
429− // TODO: need to store into history if successful
430−}
430+ transaction.apply(&mut view.state);
431+ }
431432
432−pub fn insert_tab(view: &mut View, _count: usize) {
433− insert_char(view, '\t');
434−}
433+ pub fn insert_tab(view: &mut View, _count: usize) {
434+ insert_char(view, '\t');
435+ }
435436
436−pub fn insert_newline(view: &mut View, _count: usize) {
437− insert_char(view, '\n');
438−}
437+ pub fn insert_newline(view: &mut View, _count: usize) {
438+ insert_char(view, '\n');
439+ }
439440
440−// TODO: handle indent-aware delete
441−pub fn delete_char_backward(view: &mut View, count: usize) {
442− let text = &view.state.doc.slice(..);
443− let transaction = Transaction::change_by_selection(&view.state, |range| {
444− (
445− graphemes::nth_prev_grapheme_boundary(text, range.head, count),
446− range.head,
447− None,
448− )
449− });
450− transaction.apply(&mut view.state);
451− // TODO: need to store into history if successful
452−}
441+ // TODO: handle indent-aware delete
442+ pub fn delete_char_backward(view: &mut View, count: usize) {
443+ let text = &view.state.doc.slice(..);
444+ let transaction = Transaction::change_by_selection(&view.state, |range| {
445+ (
446+ graphemes::nth_prev_grapheme_boundary(text, range.head, count),
447+ range.head,
448+ None,
449+ )
450+ });
451+ transaction.apply(&mut view.state);
452+ }
453453
454−pub fn delete_char_forward(view: &mut View, count: usize) {
455− let text = &view.state.doc.slice(..);
456− let transaction = Transaction::change_by_selection(&view.state, |range| {
457− (
458− range.head,
459− graphemes::nth_next_grapheme_boundary(text, range.head, count),
460− None,
461− )
462− });
463− transaction.apply(&mut view.state);
464− // TODO: need to store into history if successful
454+ pub fn delete_char_forward(view: &mut View, count: usize) {
455+ let text = &view.state.doc.slice(..);
456+ let transaction = Transaction::change_by_selection(&view.state, |range| {
457+ (
458+ range.head,
459+ graphemes::nth_next_grapheme_boundary(text, range.head, count),
460+ None,
461+ )
462+ });
463+ transaction.apply(&mut view.state);
464+ }
465465}
466466
467467// Undo / Redo