on master help sign in
Fix yank not working with internally zero-width ranges.
063aa94Nathan Vegdahl
helix-term/src/commands.rs+12−3
@@ -3000,9 +3000,13 @@ fn redo(cx: &mut Context) {
3000
3000
3001fn yank(cx: &mut Context) {
3001fn yank(cx: &mut Context) {
3002 let (view, doc) = current!(cx.editor);
3002 let (view, doc) = current!(cx.editor);
3003+ let text = doc.text().slice(..);
3004+
3003 let values: Vec<String> = doc
3005 let values: Vec<String> = doc
3004 .selection(view.id)
3006 .selection(view.id)
3007+ .clone()
3008+ .min_width_1(text)
3005− .fragments(doc.text().slice(..))
3009+ .fragments(text)
3006 .map(Cow::into_owned)
3010 .map(Cow::into_owned)
3007 .collect();
3011 .collect();
3008
3012
@@ -3021,10 +3025,13 @@ fn yank(cx: &mut Context) {
3021
3025
3022fn yank_joined_to_clipboard_impl(editor: &mut Editor, separator: &str) -> anyhow::Result<()> {
3026fn yank_joined_to_clipboard_impl(editor: &mut Editor, separator: &str) -> anyhow::Result<()> {
3023 let (view, doc) = current!(editor);
3027 let (view, doc) = current!(editor);
3028+ let text = doc.text().slice(..);
3024
3029
3025 let values: Vec<String> = doc
3030 let values: Vec<String> = doc
3026 .selection(view.id)
3031 .selection(view.id)
3032+ .clone()
3033+ .min_width_1(text)
3027− .fragments(doc.text().slice(..))
3034+ .fragments(text)
3028 .map(Cow::into_owned)
3035 .map(Cow::into_owned)
3029 .collect();
3036 .collect();
3030
3037
@@ -3052,11 +3059,13 @@ fn yank_joined_to_clipboard(cx: &mut Context) {
3052
3059
3053fn yank_main_selection_to_clipboard_impl(editor: &mut Editor) -> anyhow::Result<()> {
3060fn yank_main_selection_to_clipboard_impl(editor: &mut Editor) -> anyhow::Result<()> {
3054 let (view, doc) = current!(editor);
3061 let (view, doc) = current!(editor);
3062+ let text = doc.text().slice(..);
3055
3063
3056 let value = doc
3064 let value = doc
3057 .selection(view.id)
3065 .selection(view.id)
3058 .primary()
3066 .primary()
3067+ .min_width_1(text)
3059− .fragment(doc.text().slice(..));
3068+ .fragment(text);
3060
3069
3061 if let Err(e) = editor.clipboard_provider.set_contents(value.into_owned()) {
3070 if let Err(e) = editor.clipboard_provider.set_contents(value.into_owned()) {
3062 bail!("Couldn't set system clipboard content: {:?}", e);
3071 bail!("Couldn't set system clipboard content: {:?}", e);