diff --git a/crates/nu-cli/src/commands/lines.rs b/crates/nu-cli/src/commands/lines.rs index 25e86a3e7d..bcc2addcd5 100644 --- a/crates/nu-cli/src/commands/lines.rs +++ b/crates/nu-cli/src/commands/lines.rs @@ -68,32 +68,8 @@ async fn lines(args: CommandArgs, registry: &CommandRegistry) -> Result { - let mut leftover_string = leftover_string.lock(); - - let st = (&*leftover_string).clone() + &st; - - let mut lines: Vec = st.lines().map(|x| x.to_string()).collect(); - - if !ends_with_line_ending(&st) { - if let Some(last) = lines.pop() { - leftover_string.clear(); - leftover_string.push_str(&last); - } else { - leftover_string.clear(); - } - } else { - leftover_string.clear(); - } - - let success_lines: Vec<_> = lines - .iter() - .map(|x| ReturnSuccess::value(UntaggedValue::line(x).into_untagged_value())) - .collect(); - - futures::stream::iter(success_lines) } - Value { + | Value { value: UntaggedValue::Primitive(Primitive::Line(st)), .. } => { @@ -103,15 +79,12 @@ async fn lines(args: CommandArgs, registry: &CommandRegistry) -> Result = st.lines().map(|x| x.to_string()).collect(); + leftover_string.clear(); + if !ends_with_line_ending(&st) { if let Some(last) = lines.pop() { - leftover_string.clear(); leftover_string.push_str(&last); - } else { - leftover_string.clear(); } - } else { - leftover_string.clear(); } let success_lines: Vec<_> = lines