feat: add debug logging for terminal width calculation
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -4,6 +4,7 @@ use crate::services::types::ItemWithMeta;
|
||||
use crate::modes::common::ColumnType;
|
||||
use crate::modes::common::{size_column, string_column, OutputFormat};
|
||||
use anyhow::{Result};
|
||||
use log::debug;
|
||||
use prettytable::format::Alignment;
|
||||
use prettytable::{color, row, Attr, Cell, Row, Table};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -86,27 +87,40 @@ pub fn mode_list(
|
||||
|
||||
let mut meta_name: Option<&str> = None;
|
||||
// Get terminal width, default to 80 if not available
|
||||
let term_width = env::var("COLUMNS")
|
||||
.ok()
|
||||
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
|
||||
let column_width = if let Some(max_len_str) = &column.max_len {
|
||||
debug!("Processing max_len for column '{}': {}", column.name, max_len_str);
|
||||
if max_len_str.ends_with('%') {
|
||||
// Parse percentage
|
||||
let percent = max_len_str.trim_end_matches('%')
|
||||
.parse::<f64>()
|
||||
.unwrap_or(0.0);
|
||||
(term_width as f64 * percent / 100.0) as usize
|
||||
let percent_str = max_len_str.trim_end_matches('%');
|
||||
let percent = percent_str.parse::<f64>().unwrap_or(0.0);
|
||||
debug!("Percentage: {}%", percent);
|
||||
let computed_width = (term_width as f64 * percent / 100.0) as usize;
|
||||
debug!("Computed width: {}", computed_width);
|
||||
computed_width
|
||||
} else {
|
||||
// Parse absolute number
|
||||
max_len_str.parse::<usize>().unwrap_or(0)
|
||||
let absolute_width = max_len_str.parse::<usize>().unwrap_or(0);
|
||||
debug!("Absolute width: {}", absolute_width);
|
||||
absolute_width
|
||||
}
|
||||
} else {
|
||||
debug!("No max_len specified for column '{}'", column.name);
|
||||
0
|
||||
};
|
||||
|
||||
debug!("Final column width for '{}': {}", column.name, column_width);
|
||||
|
||||
if let ColumnType::Meta = column_type {
|
||||
let parts: Vec<&str> = column.name.split(':').collect();
|
||||
if parts.len() > 1 {
|
||||
|
||||
Reference in New Issue
Block a user