@@ -10,47 +10,23 @@ pub type Command = fn(state: &mut State, count: usize);
11pub fn move_char_left(state: &mut State, count: usize) {
11pub fn move_char_left(state: &mut State, count: usize) {
12 // TODO: use a transaction
12 // TODO: use a transaction
13− let selection = state.move_selection(
13+ let selection = state.move_selection(Direction::Backward, Granularity::Character, count);
14− // TODO: remove the clone here
15− state.selection.clone(),
17− Granularity::Character,
20 state.selection = selection;
14 state.selection = selection;
23pub fn move_char_right(state: &mut State, count: usize) {
17pub fn move_char_right(state: &mut State, count: usize) {
24 // TODO: use a transaction
18 // TODO: use a transaction
25− state.selection = state.move_selection(
19+ state.selection = state.move_selection(Direction::Forward, Granularity::Character, count);
26− // TODO: remove the clone here
27− state.selection.clone(),
29− Granularity::Character,
34pub fn move_line_up(state: &mut State, count: usize) {
22pub fn move_line_up(state: &mut State, count: usize) {
35 // TODO: use a transaction
23 // TODO: use a transaction
36− state.selection = state.move_selection(
24+ state.selection = state.move_selection(Direction::Backward, Granularity::Line, count);
37− // TODO: remove the clone here
38− state.selection.clone(),
45pub fn move_line_down(state: &mut State, count: usize) {
27pub fn move_line_down(state: &mut State, count: usize) {
46 // TODO: use a transaction
28 // TODO: use a transaction
47− state.selection = state.move_selection(
29+ state.selection = state.move_selection(Direction::Forward, Granularity::Line, count);
48− // TODO: remove the clone here
49− state.selection.clone(),
56// avoid select by default by having a visual mode switch that makes movements into selects
32// 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) {
67 state.selection = state
43 state.selection = state
68 .selection
44 .selection
70 .transform(|range| Range::new(range.to(), range.from()))
45 .transform(|range| Range::new(range.to(), range.from()))
@@ -76,7 +51,7 @@ pub fn append_mode(state: &mut State, _count: usize) {
77 // TODO: as transaction
52 // TODO: as transaction
78 let text = &state.doc.slice(..);
53 let text = &state.doc.slice(..);
79− state.selection = state.selection.clone().transform(|range| {
54+ state.selection = state.selection.transform(|range| {
80 // TODO: to() + next char
55 // TODO: to() + next char
81 Range::new(range.from(), next_grapheme_boundary(text, range.to()))
56 Range::new(range.from(), next_grapheme_boundary(text, range.to()))