Skip to content

Commit 122e69c

Browse files
xJonathanLEIFrederik Vestre
authored and
Frederik Vestre
committed
Exit select mode on replace commands (helix-editor#4554)
1 parent 9102146 commit 122e69c

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
@@ -1304,6 +1304,7 @@ fn replace(cx: &mut Context) {
13041304
});
13051305

13061306
apply_transaction(&transaction, doc, view);
1307+
exit_select_mode(cx);
13071308
}
13081309
})
13091310
}
@@ -3581,18 +3582,19 @@ fn replace_with_yanked(cx: &mut Context) {
35813582
});
35823583

35833584
apply_transaction(&transaction, doc, view);
3585+
exit_select_mode(cx);
35843586
}
35853587
}
35863588
}
35873589

35883590
fn replace_selections_with_clipboard_impl(
3589-
editor: &mut Editor,
3591+
cx: &mut Context,
35903592
clipboard_type: ClipboardType,
3591-
count: usize,
35923593
) -> anyhow::Result<()> {
3593-
let (view, doc) = current!(editor);
3594+
let count = cx.count();
3595+
let (view, doc) = current!(cx.editor);
35943596

3595-
match editor.clipboard_provider.get_contents(clipboard_type) {
3597+
match cx.editor.clipboard_provider.get_contents(clipboard_type) {
35963598
Ok(contents) => {
35973599
let selection = doc.selection(view.id);
35983600
let transaction = Transaction::change_by_selection(doc.text(), selection, |range| {
@@ -3605,18 +3607,20 @@ fn replace_selections_with_clipboard_impl(
36053607

36063608
apply_transaction(&transaction, doc, view);
36073609
doc.append_changes_to_history(view.id);
3608-
Ok(())
36093610
}
3610-
Err(e) => Err(e.context("Couldn't get system clipboard contents")),
3611+
Err(e) => return Err(e.context("Couldn't get system clipboard contents")),
36113612
}
3613+
3614+
exit_select_mode(cx);
3615+
Ok(())
36123616
}
36133617

36143618
fn replace_selections_with_clipboard(cx: &mut Context) {
3615-
let _ = replace_selections_with_clipboard_impl(cx.editor, ClipboardType::Clipboard, cx.count());
3619+
let _ = replace_selections_with_clipboard_impl(cx, ClipboardType::Clipboard);
36163620
}
36173621

36183622
fn replace_selections_with_primary_clipboard(cx: &mut Context) {
3619-
let _ = replace_selections_with_clipboard_impl(cx.editor, ClipboardType::Selection, cx.count());
3623+
let _ = replace_selections_with_clipboard_impl(cx, ClipboardType::Selection);
36203624
}
36213625

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

0 commit comments

Comments
 (0)