@@ -2,42 +2,47 @@ use crate::state::{Direction, Granularity, State};
3/// A command is a function that takes the current state and a count, and does a side-effect on the
3/// A command is a function that takes the current state and a count, and does a side-effect on the
4/// state (usually by creating and applying a transaction).
4/// 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);
7−fn move_char_left(state: &mut State, count: usize) {
7+pub fn move_char_left(state: &mut State, count: usize) {
8 // TODO: use a transaction
8 // TODO: use a transaction
9− state.selection = state.move_selection(
9+ let selection = state.move_selection(
10+ // TODO: remove the clone here
10− state.selection,
11+ state.selection.clone(),
11 Direction::Backward,
12 Direction::Backward,
12 Granularity::Character,
13 Granularity::Character,
16+ state.selection = selection;
17−fn move_char_right(state: &mut State, count: usize) {
19+pub fn move_char_right(state: &mut State, count: usize) {
18 // TODO: use a transaction
20 // TODO: use a transaction
19 state.selection = state.move_selection(
21 state.selection = state.move_selection(
22+ // TODO: remove the clone here
20− state.selection,
23+ state.selection.clone(),
21 Direction::Forward,
24 Direction::Forward,
22 Granularity::Character,
25 Granularity::Character,
27−fn move_line_up(state: &mut State, count: usize) {
30+pub fn move_line_up(state: &mut State, count: usize) {
28 // TODO: use a transaction
31 // TODO: use a transaction
29 state.selection = state.move_selection(
32 state.selection = state.move_selection(
33+ // TODO: remove the clone here
30− state.selection,
34+ state.selection.clone(),
31 Direction::Backward,
35 Direction::Backward,
32 Granularity::Line,
36 Granularity::Line,
37−fn move_line_down(state: &mut State, count: usize) {
41+pub fn move_line_down(state: &mut State, count: usize) {
38 // TODO: use a transaction
42 // TODO: use a transaction
39 state.selection = state.move_selection(
43 state.selection = state.move_selection(
44+ // TODO: remove the clone here
40− state.selection,
45+ state.selection.clone(),
41 Direction::Forward,
46 Direction::Forward,
42 Granularity::Line,
47 Granularity::Line,