@@ -2,42 +2,47 @@ use crate::state::{Direction, Granularity, State};
22
33/// A command is a function that takes the current state and a count, and does a side-effect on the
44/// state (usually by creating and applying a transaction).
5−type Command = fn(state: &mut State, count: usize);
5+pub type Command = fn(state: &mut State, count: usize);
66
7−fn move_char_left(state: &mut State, count: usize) {
7+pub fn move_char_left(state: &mut State, count: usize) {
88 // TODO: use a transaction
9− state.selection = state.move_selection(
10− state.selection,
9+ let selection = state.move_selection(
10+ // TODO: remove the clone here
11+ state.selection.clone(),
1112 Direction::Backward,
1213 Granularity::Character,
1314 count,
1415 );
16+ state.selection = selection;
1517}
1618
17−fn move_char_right(state: &mut State, count: usize) {
19+pub fn move_char_right(state: &mut State, count: usize) {
1820 // TODO: use a transaction
1921 state.selection = state.move_selection(
20− state.selection,
22+ // TODO: remove the clone here
23+ state.selection.clone(),
2124 Direction::Forward,
2225 Granularity::Character,
2326 count,
2427 );
2528}
2629
27−fn move_line_up(state: &mut State, count: usize) {
30+pub fn move_line_up(state: &mut State, count: usize) {
2831 // TODO: use a transaction
2932 state.selection = state.move_selection(
30− state.selection,
33+ // TODO: remove the clone here
34+ state.selection.clone(),
3135 Direction::Backward,
3236 Granularity::Line,
3337 count,
3438 );
3539}
3640
37−fn move_line_down(state: &mut State, count: usize) {
41+pub fn move_line_down(state: &mut State, count: usize) {
3842 // TODO: use a transaction
3943 state.selection = state.move_selection(
40− state.selection,
44+ // TODO: remove the clone here
45+ state.selection.clone(),
4146 Direction::Forward,
4247 Granularity::Line,
4348 count,