Skip to content

Commit 10abce9

Browse files
xJonathanLEIpathwave
authored andcommitted
Exit select mode on replace commands (helix-editor#4554)
1 parent 10202b3 commit 10abce9

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

helix-term/src/commands.rs

+12-8
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,7 @@ fn replace(cx: &mut Context) {
13071307
});
13081308

13091309
apply_transaction(&transaction, doc, view);
1310+
exit_select_mode(cx);
13101311
}
13111312
})
13121313
}
@@ -3588,18 +3589,19 @@ fn replace_with_yanked(cx: &mut Context) {
35883589
});
35893590

35903591
apply_transaction(&transaction, doc, view);
3592+
exit_select_mode(cx);
35913593
}
35923594
}
35933595
}
35943596

35953597
fn replace_selections_with_clipboard_impl(
3596-
editor: &mut Editor,
3598+
cx: &mut Context,
35973599
clipboard_type: ClipboardType,
3598-
count: usize,
35993600
) -> anyhow::Result<()> {
3600-
let (view, doc) = current!(editor);
3601+
let count = cx.count();
3602+
let (view, doc) = current!(cx.editor);
36013603

3602-
match editor.clipboard_provider.get_contents(clipboard_type) {
3604+
match cx.editor.clipboard_provider.get_contents(clipboard_type) {
36033605
Ok(contents) => {
36043606
let selection = doc.selection(view.id);
36053607
let transaction = Transaction::change_by_selection(doc.text(), selection, |range| {
@@ -3612,18 +3614,20 @@ fn replace_selections_with_clipboard_impl(
36123614

36133615
apply_transaction(&transaction, doc, view);
36143616
doc.append_changes_to_history(view.id);
3615-
Ok(())
36163617
}
3617-
Err(e) => Err(e.context("Couldn't get system clipboard contents")),
3618+
Err(e) => return Err(e.context("Couldn't get system clipboard contents")),
36183619
}
3620+
3621+
exit_select_mode(cx);
3622+
Ok(())
36193623
}
36203624

36213625
fn replace_selections_with_clipboard(cx: &mut Context) {
3622-
let _ = replace_selections_with_clipboard_impl(cx.editor, ClipboardType::Clipboard, cx.count());
3626+
let _ = replace_selections_with_clipboard_impl(cx, ClipboardType::Clipboard);
36233627
}
36243628

36253629
fn replace_selections_with_primary_clipboard(cx: &mut Context) {
3626-
let _ = replace_selections_with_clipboard_impl(cx.editor, ClipboardType::Selection, cx.count());
3630+
let _ = replace_selections_with_clipboard_impl(cx, ClipboardType::Selection);
36273631
}
36283632

36293633
fn paste(cx: &mut Context, pos: Paste) {

0 commit comments

Comments
 (0)