enhanced surround_replace
to provide visual feedback (#7588)
This commit is contained in:
parent
9551e4e111
commit
843ae97120
1 changed files with 9 additions and 1 deletions
|
@ -5174,11 +5174,18 @@ fn surround_replace(cx: &mut Context) {
|
|||
}
|
||||
};
|
||||
|
||||
let selection = selection.clone();
|
||||
let ranges: SmallVec<[Range; 1]> = change_pos.iter().map(|&p| Range::point(p)).collect();
|
||||
doc.set_selection(
|
||||
view.id,
|
||||
Selection::new(ranges, selection.primary_index() * 2),
|
||||
);
|
||||
|
||||
cx.on_next_key(move |cx, event| {
|
||||
let (view, doc) = current!(cx.editor);
|
||||
let to = match event.char() {
|
||||
Some(to) => to,
|
||||
None => return,
|
||||
None => return doc.set_selection(view.id, selection),
|
||||
};
|
||||
let (open, close) = surround::get_pair(to);
|
||||
let transaction = Transaction::change(
|
||||
|
@ -5189,6 +5196,7 @@ fn surround_replace(cx: &mut Context) {
|
|||
(pos, pos + 1, Some(t))
|
||||
}),
|
||||
);
|
||||
doc.set_selection(view.id, selection);
|
||||
doc.apply(&transaction, view.id);
|
||||
exit_select_mode(cx);
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue