@@ -100,43 +100,41 @@ mod test {
100100
101101 #[test]
102102 fn test_find_line_comment() {
103− use crate::State;
104−
105103 // four lines, two space indented, except for line 1 which is blank.
106− let doc = Rope::from(" 1\n\n 2\n 3");
107−
108− let mut state = State::new(doc);
104+ let mut doc = Rope::from(" 1\n\n 2\n 3");
109105 // select whole document
110− state.selection = Selection::single(0, state.doc.len_chars() - 1);
106+ let mut selection = Selection::single(0, doc.len_chars() - 1);
111107
112− let text = state.doc.slice(..);
108+ let text = doc.slice(..);
113109
114110 let res = find_line_comment("//", text, 0..3);
115111 // (commented = true, to_change = [line 0, line 2], min = col 2, margin = 1)
116112 assert_eq!(res, (false, vec![0, 2], 2, 1));
117113
118114 // comment
119− let transaction = toggle_line_comments(&state.doc, &state.selection, None);
120− transaction.apply(&mut state.doc);
121− state.selection = state.selection.map(transaction.changes());
115+ let transaction = toggle_line_comments(&doc, &selection, None);
116+ transaction.apply(&mut doc);
117+ selection = selection.map(transaction.changes());
122118
123− assert_eq!(state.doc, " // 1\n\n // 2\n // 3");
119+ assert_eq!(doc, " // 1\n\n // 2\n // 3");
124120
125121 // uncomment
126− let transaction = toggle_line_comments(&state.doc, &state.selection, None);
127− transaction.apply(&mut state.doc);
128− state.selection = state.selection.map(transaction.changes());
129− assert_eq!(state.doc, " 1\n\n 2\n 3");
122+ let transaction = toggle_line_comments(&doc, &selection, None);
123+ transaction.apply(&mut doc);
124+ selection = selection.map(transaction.changes());
125+ assert_eq!(doc, " 1\n\n 2\n 3");
126+ assert!(selection.len() == 1); // to ignore the selection unused warning
130127
131128 // 0 margin comments
132− state.doc = Rope::from(" //1\n\n //2\n //3");
129+ doc = Rope::from(" //1\n\n //2\n //3");
133130 // reset the selection.
134− state.selection = Selection::single(0, state.doc.len_chars() - 1);
131+ selection = Selection::single(0, doc.len_chars() - 1);
135132
136− let transaction = toggle_line_comments(&state.doc, &state.selection, None);
137− transaction.apply(&mut state.doc);
138− state.selection = state.selection.map(transaction.changes());
139− assert_eq!(state.doc, " 1\n\n 2\n 3");
133+ let transaction = toggle_line_comments(&doc, &selection, None);
134+ transaction.apply(&mut doc);
135+ selection = selection.map(transaction.changes());
136+ assert_eq!(doc, " 1\n\n 2\n 3");
137+ assert!(selection.len() == 1); // to ignore the selection unused warning
140138
141139 // TODO: account for uncommenting with uneven comment indentation
142140 }