refactor: move terminal width calculation outside the loop
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -60,6 +60,17 @@ pub fn mode_list(
|
|||||||
return show_list_structured(items_with_meta, data_path, settings, output_format);
|
return show_list_structured(items_with_meta, data_path, settings, output_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get terminal width once, default to 80 if not available
|
||||||
|
let columns_env = env::var("COLUMNS").ok();
|
||||||
|
debug!("COLUMNS environment variable: {:?}", columns_env);
|
||||||
|
|
||||||
|
let term_width = columns_env
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|w| w.parse::<usize>().ok())
|
||||||
|
.unwrap_or(80);
|
||||||
|
|
||||||
|
debug!("Terminal width: {}", term_width);
|
||||||
|
|
||||||
let mut table = Table::new();
|
let mut table = Table::new();
|
||||||
table.set_format(*prettytable::format::consts::FORMAT_CLEAN);
|
table.set_format(*prettytable::format::consts::FORMAT_CLEAN);
|
||||||
|
|
||||||
@@ -86,16 +97,6 @@ pub fn mode_list(
|
|||||||
.unwrap_or_else(|_| panic!("Unknown column {:?}", column.name));
|
.unwrap_or_else(|_| panic!("Unknown column {:?}", column.name));
|
||||||
|
|
||||||
let mut meta_name: Option<&str> = None;
|
let mut meta_name: Option<&str> = None;
|
||||||
// Get terminal width, default to 80 if not available
|
|
||||||
let columns_env = env::var("COLUMNS").ok();
|
|
||||||
debug!("COLUMNS environment variable: {:?}", columns_env);
|
|
||||||
|
|
||||||
let term_width = columns_env
|
|
||||||
.as_ref()
|
|
||||||
.and_then(|w| w.parse::<usize>().ok())
|
|
||||||
.unwrap_or(80);
|
|
||||||
|
|
||||||
debug!("Terminal width: {}", term_width);
|
|
||||||
|
|
||||||
// Parse max_len, handling both numbers and percentages
|
// Parse max_len, handling both numbers and percentages
|
||||||
let column_width = if let Some(max_len_str) = &column.max_len {
|
let column_width = if let Some(max_len_str) = &column.max_len {
|
||||||
|
|||||||
Reference in New Issue
Block a user