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::ColumnType;
|
||||||
use crate::modes::common::{size_column, string_column, OutputFormat};
|
use crate::modes::common::{size_column, string_column, OutputFormat};
|
||||||
use anyhow::{Result};
|
use anyhow::{Result};
|
||||||
|
use log::debug;
|
||||||
use prettytable::format::Alignment;
|
use prettytable::format::Alignment;
|
||||||
use prettytable::{color, row, Attr, Cell, Row, Table};
|
use prettytable::{color, row, Attr, Cell, Row, Table};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -86,26 +87,39 @@ pub fn mode_list(
|
|||||||
|
|
||||||
let mut meta_name: Option<&str> = None;
|
let mut meta_name: Option<&str> = None;
|
||||||
// Get terminal width, default to 80 if not available
|
// Get terminal width, default to 80 if not available
|
||||||
let term_width = env::var("COLUMNS")
|
let columns_env = env::var("COLUMNS").ok();
|
||||||
.ok()
|
debug!("COLUMNS environment variable: {:?}", columns_env);
|
||||||
|
|
||||||
|
let term_width = columns_env
|
||||||
|
.as_ref()
|
||||||
.and_then(|w| w.parse::<usize>().ok())
|
.and_then(|w| w.parse::<usize>().ok())
|
||||||
.unwrap_or(80);
|
.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 {
|
||||||
|
debug!("Processing max_len for column '{}': {}", column.name, max_len_str);
|
||||||
if max_len_str.ends_with('%') {
|
if max_len_str.ends_with('%') {
|
||||||
// Parse percentage
|
// Parse percentage
|
||||||
let percent = max_len_str.trim_end_matches('%')
|
let percent_str = max_len_str.trim_end_matches('%');
|
||||||
.parse::<f64>()
|
let percent = percent_str.parse::<f64>().unwrap_or(0.0);
|
||||||
.unwrap_or(0.0);
|
debug!("Percentage: {}%", percent);
|
||||||
(term_width as f64 * percent / 100.0) as usize
|
let computed_width = (term_width as f64 * percent / 100.0) as usize;
|
||||||
|
debug!("Computed width: {}", computed_width);
|
||||||
|
computed_width
|
||||||
} else {
|
} else {
|
||||||
// Parse absolute number
|
// 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 {
|
} else {
|
||||||
|
debug!("No max_len specified for column '{}'", column.name);
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
debug!("Final column width for '{}': {}", column.name, column_width);
|
||||||
|
|
||||||
if let ColumnType::Meta = column_type {
|
if let ColumnType::Meta = column_type {
|
||||||
let parts: Vec<&str> = column.name.split(':').collect();
|
let parts: Vec<&str> = column.name.split(':').collect();
|
||||||
|
|||||||
Reference in New Issue
Block a user