From 3d40e169ce60c81809ba1640b7b63070be598ac5 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Sat, 22 Jan 2022 17:36:27 -0600 Subject: [PATCH] fix to retain ls_colors coloring from ls (#824) fixes #823 --- crates/nu-command/src/filters/sort_by.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/nu-command/src/filters/sort_by.rs b/crates/nu-command/src/filters/sort_by.rs index d84585dec2..b5a8055950 100644 --- a/crates/nu-command/src/filters/sort_by.rs +++ b/crates/nu-command/src/filters/sort_by.rs @@ -79,6 +79,7 @@ impl Command for SortBy { ) -> Result { let columns: Vec = call.rest(engine_state, stack, 0)?; let reverse = call.has_flag("reverse"); + let metadata = &input.metadata(); let mut vec: Vec<_> = input.into_iter().collect(); sort(&mut vec, columns, call)?; @@ -88,7 +89,12 @@ impl Command for SortBy { } let iter = vec.into_iter(); - Ok(iter.into_pipeline_data(engine_state.ctrlc.clone())) + match &*metadata { + Some(m) => { + Ok(iter.into_pipeline_data_with_metadata(m.clone(), engine_state.ctrlc.clone())) + } + None => Ok(iter.into_pipeline_data(engine_state.ctrlc.clone())), + } } }