Skip to content

Commit 797d7c1

Browse files
xJonathanLEIShekhinah Memmel
authored andcommitted
Exit select mode on replace commands (helix-editor#4554)
1 parent 389b9f7 commit 797d7c1

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

helix-term/src/commands.rs

Lines changed: 12 additions & 8 deletions
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
}
@@ -3621,18 +3622,19 @@ fn replace_with_yanked(cx: &mut Context) {
36213622
});
36223623

36233624
apply_transaction(&transaction, doc, view);
3625+
exit_select_mode(cx);
36243626
}
36253627
}
36263628
}
36273629

36283630
fn replace_selections_with_clipboard_impl(
3629-
editor: &mut Editor,
3631+
cx: &mut Context,
36303632
clipboard_type: ClipboardType,
3631-
count: usize,
36323633
) -> anyhow::Result<()> {
3633-
let (view, doc) = current!(editor);
3634+
let count = cx.count();
3635+
let (view, doc) = current!(cx.editor);
36343636

3635-
match editor.clipboard_provider.get_contents(clipboard_type) {
3637+
match cx.editor.clipboard_provider.get_contents(clipboard_type) {
36363638
Ok(contents) => {
36373639
let selection = doc.selection(view.id);
36383640
let transaction = Transaction::change_by_selection(doc.text(), selection, |range| {
@@ -3645,18 +3647,20 @@ fn replace_selections_with_clipboard_impl(
36453647

36463648
apply_transaction(&transaction, doc, view);
36473649
doc.append_changes_to_history(view.id);
3648-
Ok(())
36493650
}
3650-
Err(e) => Err(e.context("Couldn't get system clipboard contents")),
3651+
Err(e) => return Err(e.context("Couldn't get system clipboard contents")),
36513652
}
3653+
3654+
exit_select_mode(cx);
3655+
Ok(())
36523656
}
36533657

36543658
fn replace_selections_with_clipboard(cx: &mut Context) {
3655-
let _ = replace_selections_with_clipboard_impl(cx.editor, ClipboardType::Clipboard, cx.count());
3659+
let _ = replace_selections_with_clipboard_impl(cx, ClipboardType::Clipboard);
36563660
}
36573661

36583662
fn replace_selections_with_primary_clipboard(cx: &mut Context) {
3659-
let _ = replace_selections_with_clipboard_impl(cx.editor, ClipboardType::Selection, cx.count());
3663+
let _ = replace_selections_with_clipboard_impl(cx, ClipboardType::Selection);
36603664
}
36613665

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

0 commit comments

Comments
 (0)