on master help sign in
enhanced `surround_replace` to provide visual feedback (#7588)
commit843ae971209d41b88b66d282979ed76303ec5e34 authorAlex Vinyals <alevinval@gmail.com> dateThu 13 Jul 2023, 15:01 (3 years ago) parent9551e4e
1 file changed+9−1
helix-term/src/commands.rs+9−1
helix-term/src/commands.rs+9−1
@@ -5174,11 +5174,18 @@ fn surround_replace(cx: &mut Context) {
51745174 }
51755175 };
51765176
5177+ let selection = selection.clone();
5178+ let ranges: SmallVec<[Range; 1]> = change_pos.iter().map(|&p| Range::point(p)).collect();
5179+ doc.set_selection(
5180+ view.id,
5181+ Selection::new(ranges, selection.primary_index() * 2),
5182+ );
5183+
51775184 cx.on_next_key(move |cx, event| {
51785185 let (view, doc) = current!(cx.editor);
51795186 let to = match event.char() {
51805187 Some(to) => to,
5181− None => return,
5188+ None => return doc.set_selection(view.id, selection),
51825189 };
51835190 let (open, close) = surround::get_pair(to);
51845191 let transaction = Transaction::change(
@@ -5189,6 +5196,7 @@ fn surround_replace(cx: &mut Context) {
51895196 (pos, pos + 1, Some(t))
51905197 }),
51915198 );
5199+ doc.set_selection(view.id, selection);
51925200 doc.apply(&transaction, view.id);
51935201 exit_select_mode(cx);
51945202 });