Skip to content

Commit

Permalink
Use a boolean to indicate whether to yank during deletion of a select…
Browse files Browse the repository at this point in the history
  • Loading branch information
voiceroy authored and mtoohey31 committed Jun 2, 2024
1 parent a40c1f2 commit 68c527e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2617,13 +2617,13 @@ fn selection_is_linewise(selection: &Selection, text: &Rope) -> bool {
})
}

fn delete_selection_impl(cx: &mut Context, op: Operation) {
fn delete_selection_impl(cx: &mut Context, op: Operation, yank: bool) {
let (view, doc) = current!(cx.editor);

let selection = doc.selection(view.id);
let only_whole_lines = selection_is_linewise(selection, doc.text());

if cx.register != Some('_') {
if cx.register != Some('_') && yank {
// first yank the selection
let text = doc.text().slice(..);
let values: Vec<String> = selection.fragments(text).map(Cow::into_owned).collect();
Expand Down Expand Up @@ -2700,21 +2700,19 @@ fn delete_by_selection_insert_mode(
}

fn delete_selection(cx: &mut Context) {
delete_selection_impl(cx, Operation::Delete);
delete_selection_impl(cx, Operation::Delete, true);
}

fn delete_selection_noyank(cx: &mut Context) {
cx.register = Some('_');
delete_selection_impl(cx, Operation::Delete);
delete_selection_impl(cx, Operation::Delete, false);
}

fn change_selection(cx: &mut Context) {
delete_selection_impl(cx, Operation::Change);
delete_selection_impl(cx, Operation::Change, true);
}

fn change_selection_noyank(cx: &mut Context) {
cx.register = Some('_');
delete_selection_impl(cx, Operation::Change);
delete_selection_impl(cx, Operation::Change, false);
}

fn collapse_selection(cx: &mut Context) {
Expand Down

0 comments on commit 68c527e

Please sign in to comment.