diff options
author | Nathan Vegdahl | 2021-07-21 16:32:48 +0000 |
---|---|---|
committer | Nathan Vegdahl | 2021-07-21 16:32:48 +0000 |
commit | 063aa9452d7c41e486a143b9f7e14fb5d14ad808 (patch) | |
tree | f547083b42e22cfb07a799f1829872c66316f1c4 /helix-term | |
parent | bc85c85501306f4d3e5e6c802590816cdaf29c13 (diff) |
Fix yank not working with internally zero-width ranges.
Diffstat (limited to 'helix-term')
-rw-r--r-- | helix-term/src/commands.rs | 15 |
1 files 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<String> = 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<String> = 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); |