diff --git a/crates/tui/src/tui/views/mod.rs b/crates/tui/src/tui/views/mod.rs index 2befde4f..a91b7bef 100644 --- a/crates/tui/src/tui/views/mod.rs +++ b/crates/tui/src/tui/views/mod.rs @@ -555,6 +555,9 @@ pub struct ConfigView { last_row_hitboxes: RefCell>, } +const CONFIG_MIN_KEY_COLUMN_WIDTH: usize = 19; +const CONFIG_VALUE_COLUMN_WIDTH: usize = 44; + impl ConfigView { pub fn new_for_app(app: &App) -> Self { let settings = Settings::load().unwrap_or_else(|_| Settings::default()); @@ -769,6 +772,15 @@ impl ConfigView { items } + fn key_column_width(&self) -> usize { + self.rows + .iter() + .map(|row| row.key.chars().count()) + .max() + .unwrap_or(CONFIG_MIN_KEY_COLUMN_WIDTH) + .max(CONFIG_MIN_KEY_COLUMN_WIDTH) + } + fn selected_row_index(&self) -> Option { let selected = self.selected; self.matching_row_indices() @@ -1257,6 +1269,7 @@ impl ModalView for ConfigView { self.filter.clone() }; + let key_column_width = self.key_column_width(); let mut lines: Vec = vec![ Line::from(vec![Span::styled( self.tr(MessageId::ConfigTitle), @@ -1271,8 +1284,17 @@ impl ModalView for ConfigView { ), ]), Line::from(""), - Line::from(" Key Value Scope"), - Line::from(" ----------------------------------------------------------------"), + Line::from(format!( + " {:>(); + assert!( + scope_columns.len() >= 3, + "expected composer config rows with scopes:\n{dump}" + ); + assert!( + scope_columns + .iter() + .all(|column| *column == scope_columns[0]), + "scope column should stay aligned even for long keys:\n{dump}" + ); + } + #[test] fn config_view_filter_no_match_does_not_edit_hidden_row() { let app = create_test_app();