@@ -10,47 +10,23 @@ pub type Command = fn(state: &mut State, count: usize);
1010
1111pub fn move_char_left(state: &mut State, count: usize) {
1212 // TODO: use a transaction
13− let selection = state.move_selection(
14− // TODO: remove the clone here
15− state.selection.clone(),
16− Direction::Backward,
17− Granularity::Character,
18− count,
19− );
13+ let selection = state.move_selection(Direction::Backward, Granularity::Character, count);
2014 state.selection = selection;
2115}
2216
2317pub fn move_char_right(state: &mut State, count: usize) {
2418 // TODO: use a transaction
25− state.selection = state.move_selection(
26− // TODO: remove the clone here
27− state.selection.clone(),
28− Direction::Forward,
29− Granularity::Character,
30− count,
31− );
19+ state.selection = state.move_selection(Direction::Forward, Granularity::Character, count);
3220}
3321
3422pub fn move_line_up(state: &mut State, count: usize) {
3523 // TODO: use a transaction
36− state.selection = state.move_selection(
37− // TODO: remove the clone here
38− state.selection.clone(),
39− Direction::Backward,
40− Granularity::Line,
41− count,
42− );
24+ state.selection = state.move_selection(Direction::Backward, Granularity::Line, count);
4325}
4426
4527pub fn move_line_down(state: &mut State, count: usize) {
4628 // TODO: use a transaction
47− state.selection = state.move_selection(
48− // TODO: remove the clone here
49− state.selection.clone(),
50− Direction::Forward,
51− Granularity::Line,
52− count,
53− );
29+ state.selection = state.move_selection(Direction::Forward, Granularity::Line, count);
5430}
5531
5632// avoid select by default by having a visual mode switch that makes movements into selects
@@ -66,7 +42,6 @@ pub fn insert_mode(state: &mut State, _count: usize) {
6642
6743 state.selection = state
6844 .selection
69− .clone()
7045 .transform(|range| Range::new(range.to(), range.from()))
7146}
7247
@@ -76,7 +51,7 @@ pub fn append_mode(state: &mut State, _count: usize) {
7651
7752 // TODO: as transaction
7853 let text = &state.doc.slice(..);
79− state.selection = state.selection.clone().transform(|range| {
54+ state.selection = state.selection.transform(|range| {
8055 // TODO: to() + next char
8156 Range::new(range.from(), next_grapheme_boundary(text, range.to()))
8257 })