@@ -1,3 +1,4 @@
1+use crate::graphemes::next_grapheme_boundary;
1use crate::selection::Range;
2use crate::selection::Range;
2use crate::state::{Direction, Granularity, Mode, State};
3use crate::state::{Direction, Granularity, Mode, State};
3use crate::transaction::{ChangeSet, Transaction};
4use crate::transaction::{ChangeSet, Transaction};
@@ -74,9 +75,10 @@ pub fn append_mode(state: &mut State, _count: usize) {
74 state.mode = Mode::Insert;
75 state.mode = Mode::Insert;
76 // TODO: as transaction
77 // TODO: as transaction
78+ let text = &state.doc.slice(..);
77 state.selection = state.selection.clone().transform(|range| {
79 state.selection = state.selection.clone().transform(|range| {
78 // TODO: to() + next char
80 // TODO: to() + next char
79− Range::new(range.from(), range.to())
81+ Range::new(range.from(), next_grapheme_boundary(text, range.to()))
@@ -86,6 +88,7 @@ pub fn append_mode(state: &mut State, _count: usize) {
86// O inserts a new line after each line with a selection
88// O inserts a new line after each line with a selection
88pub fn normal_mode(state: &mut State, _count: usize) {
90pub fn normal_mode(state: &mut State, _count: usize) {
91+ // TODO: if leaving append mode, move cursor back by 1
89 state.mode = Mode::Normal;
92 state.mode = Mode::Normal;