From 5b3cc73ac6ca91d1c2d61d08c71cdc933c9ee5f8 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Fri, 4 Mar 2022 15:09:35 -0600 Subject: [PATCH] remove the hard coded escaping from split row and split column (#4731) --- crates/nu-command/src/strings/split/column.rs | 6 ++---- crates/nu-command/src/strings/split/row.rs | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/crates/nu-command/src/strings/split/column.rs b/crates/nu-command/src/strings/split/column.rs index 04721c95ce..7a4dd8be8f 100644 --- a/crates/nu-command/src/strings/split/column.rs +++ b/crates/nu-command/src/strings/split/column.rs @@ -114,12 +114,10 @@ fn split_column_helper( head: Span, ) -> Vec { if let Ok(s) = v.as_string() { - let splitter = separator.item.replace("\\n", "\n"); - let split_result: Vec<_> = if collapse_empty { - s.split(&splitter).filter(|s| !s.is_empty()).collect() + s.split(&separator.item).filter(|s| !s.is_empty()).collect() } else { - s.split(&splitter).collect() + s.split(&separator.item).collect() }; let positional: Vec<_> = rest.iter().map(|f| f.item.clone()).collect(); diff --git a/crates/nu-command/src/strings/split/row.rs b/crates/nu-command/src/strings/split/row.rs index 93515ff7b1..2ea9ff3b5b 100644 --- a/crates/nu-command/src/strings/split/row.rs +++ b/crates/nu-command/src/strings/split/row.rs @@ -86,8 +86,7 @@ fn split_row_helper(v: &Value, separator: &Spanned, name: Span) -> Vec { if let Ok(s) = v.as_string() { - let splitter = separator.item.replace("\\n", "\n"); - s.split(&splitter) + s.split(&separator.item) .filter_map(|s| { if s.trim() != "" { Some(Value::string(s, v_span))