diff --git a/crates/nu-command/src/filters/first.rs b/crates/nu-command/src/filters/first.rs index 7fc2b6ecd..7ee7b97a5 100644 --- a/crates/nu-command/src/filters/first.rs +++ b/crates/nu-command/src/filters/first.rs @@ -2,8 +2,8 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, - Type, Value, + Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, ShellError, + Signature, Span, SyntaxShape, Type, Value, }; #[derive(Clone)] @@ -70,6 +70,9 @@ fn first_helper( None => 1, }; + let ctrlc = engine_state.ctrlc.clone(); + let metadata = input.metadata(); + let mut input_peek = input.into_iter().peekable(); if input_peek.peek().is_some() { match input_peek @@ -125,11 +128,11 @@ fn first_helper( _ => todo!(), }, - None => Ok(Value::List { - vals: input_peek.into_iter().take(rows_desired).collect(), - span: head, - } - .into_pipeline_data()), + None => Ok(input_peek + .into_iter() + .take(rows_desired) + .into_pipeline_data(ctrlc) + .set_metadata(metadata)), } } _ => { @@ -139,11 +142,11 @@ fn first_helper( None => Err(ShellError::AccessBeyondEndOfStream(head)), } } else { - Ok(Value::List { - vals: input_peek.into_iter().take(rows_desired).collect(), - span: head, - } - .into_pipeline_data()) + Ok(input_peek + .into_iter() + .take(rows_desired) + .into_pipeline_data(ctrlc) + .set_metadata(metadata)) } } } diff --git a/crates/nu-command/src/filters/last.rs b/crates/nu-command/src/filters/last.rs index b4485e236..2e4835c85 100644 --- a/crates/nu-command/src/filters/last.rs +++ b/crates/nu-command/src/filters/last.rs @@ -47,6 +47,8 @@ impl Command for Last { call: &Call, input: PipelineData, ) -> Result { + let metadata = input.metadata(); + let rows: Option = call.opt(engine_state, stack, 0)?; let v: Vec<_> = input.into_iter().collect(); let vlen: i64 = v.len() as i64; @@ -54,7 +56,9 @@ impl Command for Last { let iter = v.into_iter().skip(beginning_rows_to_skip as usize); - Ok(iter.into_pipeline_data(engine_state.ctrlc.clone())) + Ok(iter + .into_pipeline_data(engine_state.ctrlc.clone()) + .set_metadata(metadata)) } } diff --git a/crates/nu-command/src/filters/reverse.rs b/crates/nu-command/src/filters/reverse.rs index 9995a33a5..41030a9ae 100644 --- a/crates/nu-command/src/filters/reverse.rs +++ b/crates/nu-command/src/filters/reverse.rs @@ -44,10 +44,14 @@ impl Command for Reverse { _call: &Call, input: PipelineData, ) -> Result { + let metadata = input.metadata(); + #[allow(clippy::needless_collect)] let v: Vec<_> = input.into_iter().collect(); let iter = v.into_iter().rev(); - Ok(iter.into_pipeline_data(engine_state.ctrlc.clone())) + Ok(iter + .into_pipeline_data(engine_state.ctrlc.clone()) + .set_metadata(metadata)) } } diff --git a/crates/nu-command/src/filters/skip/skip_.rs b/crates/nu-command/src/filters/skip/skip_.rs index de1733cab..736c28b3e 100644 --- a/crates/nu-command/src/filters/skip/skip_.rs +++ b/crates/nu-command/src/filters/skip/skip_.rs @@ -60,6 +60,7 @@ impl Command for Skip { ) -> Result { let n: Option = call.opt(engine_state, stack, 0)?; let span = call.head; + let metadata = input.metadata(); let n: usize = match n { Some(Value::Int { val, span }) => val.try_into().map_err(|err| { @@ -74,7 +75,11 @@ impl Command for Skip { let ctrlc = engine_state.ctrlc.clone(); - Ok(input.into_iter().skip(n).into_pipeline_data(ctrlc)) + Ok(input + .into_iter() + .skip(n) + .into_pipeline_data(ctrlc) + .set_metadata(metadata)) } } diff --git a/crates/nu-command/src/filters/skip/skip_until.rs b/crates/nu-command/src/filters/skip/skip_until.rs index 15078ea4a..79bbacdde 100644 --- a/crates/nu-command/src/filters/skip/skip_until.rs +++ b/crates/nu-command/src/filters/skip/skip_until.rs @@ -47,6 +47,7 @@ impl Command for SkipUntil { input: PipelineData, ) -> Result { let span = call.head; + let metadata = input.metadata(); let capture_block: CaptureBlock = call.req(engine_state, stack, 0)?; @@ -69,7 +70,8 @@ impl Command for SkipUntil { pipeline_data.into_value(span).is_true() }) }) - .into_pipeline_data(ctrlc)) + .into_pipeline_data(ctrlc) + .set_metadata(metadata)) } } diff --git a/crates/nu-command/src/filters/skip/skip_while.rs b/crates/nu-command/src/filters/skip/skip_while.rs index 8949b334c..4c0ba6c36 100644 --- a/crates/nu-command/src/filters/skip/skip_while.rs +++ b/crates/nu-command/src/filters/skip/skip_while.rs @@ -47,6 +47,7 @@ impl Command for SkipWhile { input: PipelineData, ) -> Result { let span = call.head; + let metadata = input.metadata(); let capture_block: CaptureBlock = call.req(engine_state, stack, 0)?; @@ -69,7 +70,8 @@ impl Command for SkipWhile { pipeline_data.into_value(span).is_true() }) }) - .into_pipeline_data(ctrlc)) + .into_pipeline_data(ctrlc) + .set_metadata(metadata)) } }