@@ -122,7 +122,7 @@ impl State {
122122 // TODO: move all selections according to normal cursor move semantics by collapsing it
123123 // into cursors and moving them vertically
124124
125− let ranges = self.selection.ranges.iter().map(|range| {
125+ self.selection.transform(|range| {
126126 // let pos = if !range.is_empty() {
127127 // // if selection already exists, bump it to the start or end of current select first
128128 // if dir == Direction::Backward {
@@ -134,10 +134,7 @@ impl State {
134134 let pos = self.move_pos(range.head, dir, granularity, count);
135135 // };
136136 SelectionRange::new(pos, pos)
137− });
138−
139− Selection::new(ranges.collect(), self.selection.primary_index)
140− // TODO: update selection in state via transaction
137+ })
141138 }
142139
143140 pub fn extend_selection(
@@ -146,13 +143,10 @@ impl State {
146143 granularity: Granularity,
147144 count: usize,
148145 ) -> Selection {
149− let ranges = self.selection.ranges.iter().map(|range| {
146+ self.selection.transform(|range| {
150147 let pos = self.move_pos(range.head, dir, granularity, count);
151148 SelectionRange::new(range.anchor, pos)
152− });
153−
154− Selection::new(ranges.collect(), self.selection.primary_index)
155− // TODO: update selection in state via transaction
149+ })
156150 }
157151}
158152
@@ -203,7 +197,6 @@ mod test {
203197 fn test_coords_at_pos() {
204198 let text = Rope::from("ḧëḷḷö\nẅöṛḷḋ");
205199 assert_eq!(coords_at_pos(&text.slice(..), 0), (0, 0));
206− // TODO: what is the coordinate of newline?
207200 assert_eq!(coords_at_pos(&text.slice(..), 5), (0, 5)); // position on \n
208201 assert_eq!(coords_at_pos(&text.slice(..), 6), (1, 0)); // position on w
209202 assert_eq!(coords_at_pos(&text.slice(..), 7), (1, 1)); // position on o