feat: add support for negative column widths relative to terminal width

Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-25 22:25:22 -03:00
parent 9e133d9527
commit 2a233b3d43

View File

@@ -113,10 +113,19 @@ pub fn mode_list(
let mut meta_name: Option<&str> = None; let mut meta_name: Option<&str> = None;
// Parse max_len, handling both numbers and percentages // Parse max_len, handling numbers, percentages, and negative values
let column_width = if let Some(max_len_str) = &column.max_len { let column_width = if let Some(max_len_str) = &column.max_len {
debug!("Processing max_len for column '{}': {}", column.name, max_len_str); debug!("Processing max_len for column '{}': {}", column.name, max_len_str);
if max_len_str.ends_with('%') { // Check if it's a negative number
if max_len_str.starts_with('-') {
// Parse as negative number
let abs_value = max_len_str[1..].parse::<usize>().unwrap_or(0);
if abs_value > term_width {
0
} else {
term_width - abs_value
}
} else if max_len_str.ends_with('%') {
// Parse percentage // Parse percentage
let percent_str = max_len_str.trim_end_matches('%'); let percent_str = max_len_str.trim_end_matches('%');
let percent = percent_str.parse::<f64>().unwrap_or(0.0); let percent = percent_str.parse::<f64>().unwrap_or(0.0);