From 063aa9452d7c41e486a143b9f7e14fb5d14ad808 Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Wed, 21 Jul 2021 09:32:48 -0700 Subject: [PATCH] Fix yank not working with internally zero-width ranges. --- helix-term/src/commands.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 0ea78f6b..475eccf2 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -3000,9 +3000,13 @@ fn redo(cx: &mut Context) { fn yank(cx: &mut Context) { let (view, doc) = current!(cx.editor); + let text = doc.text().slice(..); + let values: Vec = doc .selection(view.id) - .fragments(doc.text().slice(..)) + .clone() + .min_width_1(text) + .fragments(text) .map(Cow::into_owned) .collect(); @@ -3021,10 +3025,13 @@ fn yank(cx: &mut Context) { fn yank_joined_to_clipboard_impl(editor: &mut Editor, separator: &str) -> anyhow::Result<()> { let (view, doc) = current!(editor); + let text = doc.text().slice(..); let values: Vec = doc .selection(view.id) - .fragments(doc.text().slice(..)) + .clone() + .min_width_1(text) + .fragments(text) .map(Cow::into_owned) .collect(); @@ -3052,11 +3059,13 @@ fn yank_joined_to_clipboard(cx: &mut Context) { fn yank_main_selection_to_clipboard_impl(editor: &mut Editor) -> anyhow::Result<()> { let (view, doc) = current!(editor); + let text = doc.text().slice(..); let value = doc .selection(view.id) .primary() - .fragment(doc.text().slice(..)); + .min_width_1(text) + .fragment(text); if let Err(e) = editor.clipboard_provider.set_contents(value.into_owned()) { bail!("Couldn't set system clipboard content: {:?}", e);