aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-04-07 06:40:15 +0000
committerBlaž Hrastnik2021-04-07 06:40:15 +0000
commit82ff99666291c38f6fb42ff7aa41a02b57c6cf38 (patch)
tree2e6fc99bb335d1711ce4db876bfd5878482ac3e7 /helix-term/src
parent89f81be31bf1a3bf0d4e80bc190b2193e89ff533 (diff)
Yank selection when deleting.
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index b79f3b79..0d5ffb9c 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -707,6 +707,18 @@ pub fn extend_line(cx: &mut Context) {
// heuristic: append changes to history after each command, unless we're in insert mode
fn _delete_selection(doc: &mut Document, view_id: ViewId) {
+ // first yank the selection
+ let values: Vec<String> = doc
+ .selection(view_id)
+ .fragments(doc.text().slice(..))
+ .map(Cow::into_owned)
+ .collect();
+
+ // TODO: allow specifying reg
+ let reg = '"';
+ register::set(reg, values);
+
+ // then delete
let transaction =
Transaction::change_by_selection(doc.text(), doc.selection(view_id), |range| {
(range.from(), range.to() + 1, None)