From 975a89269e9a11bbba199d3bf6c94ac5c3a01782 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Thu, 19 Jun 2025 11:22:18 -0500 Subject: [PATCH] repect color_config.header color for record key (#16006) # Description This PR fixes an oversight where the record key value was not being colored as the color_config.header color when used with the `table` command in some circumstances. It respected it with `table -e` but just not `table`. ### Before ![image](https://github.com/user-attachments/assets/a41e609f-9b3a-415b-af90-037e6ee47318) ### After ![image](https://github.com/user-attachments/assets/c3afb293-ebb3-4cb3-8ee6-4f7e2e96723b) # User-Facing Changes # Tests + Formatting # After Submitting --- crates/nu-table/src/types/general.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/nu-table/src/types/general.rs b/crates/nu-table/src/types/general.rs index ebae8660c7..2727e89022 100644 --- a/crates/nu-table/src/types/general.rs +++ b/crates/nu-table/src/types/general.rs @@ -40,9 +40,13 @@ fn list_table(input: Vec, opts: TableOpts<'_>) -> Result, Ok(table) } +fn get_key_style(topts: &TableOpts<'_>) -> TextStyle { + get_header_style(&topts.style_computer).alignment(nu_color_config::Alignment::Left) +} + fn kv_table(record: Record, opts: TableOpts<'_>) -> StringResult { let mut table = NuTable::new(record.len(), 2); - table.set_index_style(TextStyle::default_field()); + table.set_index_style(get_key_style(&opts)); table.set_indent(opts.config.table.padding); for (i, (key, value)) in record.into_iter().enumerate() {