@@ -368,7 +368,6 @@ pub fn open_below(view: &mut View, _count: usize) {
368 let transaction = Transaction::change(&view.state, changes).with_selection(selection);
368 let transaction = Transaction::change(&view.state, changes).with_selection(selection);
370 transaction.apply(&mut view.state);
370 transaction.apply(&mut view.state);
371− // TODO: need to store into history if successful
374// O inserts a new line before each line with a selection
373// O inserts a new line before each line with a selection
@@ -420,48 +419,49 @@ pub fn goto_mode(view: &mut View, _count: usize) {
420 view.state.mode = Mode::Goto;
419 view.state.mode = Mode::Goto;
422+// NOTE: Transactions in this module get appended to history when we switch back to normal mode.
423−// TODO: insert means add text just before cursor, on exit we should be on the last letter.
425+ // 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) {
426+ pub fn insert_char(view: &mut View, c: char) {
425− let c = Tendril::from_char(c);
427+ let c = Tendril::from_char(c);
426− let transaction = Transaction::insert(&view.state, c);
428+ let transaction = Transaction::insert(&view.state, c);
428− transaction.apply(&mut view.state);
430+ transaction.apply(&mut view.state);
429− // TODO: need to store into history if successful
432−pub fn insert_tab(view: &mut View, _count: usize) {
433+ pub fn insert_tab(view: &mut View, _count: usize) {
433− insert_char(view, '\t');
434+ insert_char(view, '\t');
436−pub fn insert_newline(view: &mut View, _count: usize) {
437+ pub fn insert_newline(view: &mut View, _count: usize) {
437− insert_char(view, '\n');
438+ insert_char(view, '\n');
440−// TODO: handle indent-aware delete
441+ // TODO: handle indent-aware delete
441−pub fn delete_char_backward(view: &mut View, count: usize) {
442+ pub fn delete_char_backward(view: &mut View, count: usize) {
442− let text = &view.state.doc.slice(..);
443+ let text = &view.state.doc.slice(..);
443− let transaction = Transaction::change_by_selection(&view.state, |range| {
444+ let transaction = Transaction::change_by_selection(&view.state, |range| {
445− graphemes::nth_prev_grapheme_boundary(text, range.head, count),
446+ graphemes::nth_prev_grapheme_boundary(text, range.head, count),
446− range.head,
447+ range.head,
450− transaction.apply(&mut view.state);
451+ transaction.apply(&mut view.state);
451− // TODO: need to store into history if successful
454−pub fn delete_char_forward(view: &mut View, count: usize) {
454+ pub fn delete_char_forward(view: &mut View, count: usize) {
455− let text = &view.state.doc.slice(..);
455+ let text = &view.state.doc.slice(..);
456− let transaction = Transaction::change_by_selection(&view.state, |range| {
456+ let transaction = Transaction::change_by_selection(&view.state, |range| {
458− range.head,
458+ range.head,
459− graphemes::nth_next_grapheme_boundary(text, range.head, count),
459+ graphemes::nth_next_grapheme_boundary(text, range.head, count),
463− transaction.apply(&mut view.state);
463+ transaction.apply(&mut view.state);
464− // TODO: need to store into history if successful
464+ }
467// Undo / Redo
467// Undo / Redo