mirror of
https://github.com/nushell/nushell.git
synced 2024-12-24 16:09:11 +01:00
remove the hard coded escaping from split row and split column (#4731)
This commit is contained in:
parent
02dfb57ed1
commit
5b3cc73ac6
@ -114,12 +114,10 @@ fn split_column_helper(
|
|||||||
head: Span,
|
head: Span,
|
||||||
) -> Vec<Value> {
|
) -> Vec<Value> {
|
||||||
if let Ok(s) = v.as_string() {
|
if let Ok(s) = v.as_string() {
|
||||||
let splitter = separator.item.replace("\\n", "\n");
|
|
||||||
|
|
||||||
let split_result: Vec<_> = if collapse_empty {
|
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 {
|
} else {
|
||||||
s.split(&splitter).collect()
|
s.split(&separator.item).collect()
|
||||||
};
|
};
|
||||||
|
|
||||||
let positional: Vec<_> = rest.iter().map(|f| f.item.clone()).collect();
|
let positional: Vec<_> = rest.iter().map(|f| f.item.clone()).collect();
|
||||||
|
@ -86,8 +86,7 @@ fn split_row_helper(v: &Value, separator: &Spanned<String>, name: Span) -> Vec<V
|
|||||||
match v.span() {
|
match v.span() {
|
||||||
Ok(v_span) => {
|
Ok(v_span) => {
|
||||||
if let Ok(s) = v.as_string() {
|
if let Ok(s) = v.as_string() {
|
||||||
let splitter = separator.item.replace("\\n", "\n");
|
s.split(&separator.item)
|
||||||
s.split(&splitter)
|
|
||||||
.filter_map(|s| {
|
.filter_map(|s| {
|
||||||
if s.trim() != "" {
|
if s.trim() != "" {
|
||||||
Some(Value::string(s, v_span))
|
Some(Value::string(s, v_span))
|
||||||
|
Loading…
Reference in New Issue
Block a user