From b58fe565d45f7b7123f124e0a2b2a9d83e1ca623 Mon Sep 17 00:00:00 2001 From: Rolo Date: Sat, 22 Jun 2024 01:35:44 -0700 Subject: [PATCH] feat(commands): unescape `yank-join` separator This commit enhances the `yank-join` command by incorporating the `unescape` function to process the separator provided by the user. This improvement ensures that any escape sequences in the separator are correctly interpreted, aligning with user expectations. Previously, the `yank-join` command joined the current selection with the separator as-is. With this update, escape sequences in the separator such as: - `\\n` for newlines - `\\t` for tabs - `\\u{...}` for Unicode characters are unescaped to their corresponding literal characters before joining the selection. --- helix-term/src/commands.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 67955aec0..b22ffe2f8 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -4144,18 +4144,19 @@ fn yank_joined_impl(editor: &mut Editor, separator: &str, register: char) { let selection = doc.selection(view.id); let selections = selection.len(); + let separator = helix_stdx::str::unescape(separator); let joined = selection .fragments(text) .fold(String::new(), |mut acc, fragment| { if !acc.is_empty() { - acc.push_str(separator); + acc.push_str(&separator); } acc.push_str(&fragment); acc }); match editor.registers.write(register, vec![joined]) { - Ok(_) => editor.set_status(format!( + Ok(()) => editor.set_status(format!( "joined and yanked {selections} selection{} to register {register}", if selections == 1 { "" } else { "s" } )),