fix: add debug logging and set default values for text plugin options

Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-27 10:09:43 -03:00
parent e10605bb7e
commit 9088b76067

View File

@@ -499,6 +499,7 @@ impl MetaPlugin for TextMetaPlugin {
}
fn configure_options(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> anyhow::Result<()> {
log::debug!("TEXT: Configuring options: {:?}", options);
if let Some(text_detect_size) = options.get("text_detect_size") {
if let Some(size) = text_detect_size.as_u64() {
self.max_buffer_size = size as usize;
@@ -511,32 +512,24 @@ impl MetaPlugin for TextMetaPlugin {
}
}
// Update tracking options
if let Some(track) = options.get("text_word_count") {
if let Some(track_bool) = track.as_bool() {
self.track_word_count = track_bool;
}
}
if let Some(track) = options.get("text_line_count") {
if let Some(track_bool) = track.as_bool() {
self.track_line_count = track_bool;
}
}
if let Some(track) = options.get("text_line_max_len") {
if let Some(track_bool) = track.as_bool() {
if track_bool {
self.track_line_lengths = true;
if self.line_lengths.is_none() {
self.line_lengths = Some(Vec::new());
}
}
}
}
// Similar for mean and median, but we'll just check if any are true to enable tracking
// For simplicity, we'll enable tracking if any of the line length options are true
let track_line_max = options.get("text_line_max_len").and_then(|v| v.as_bool()).unwrap_or(false);
let track_line_mean = options.get("text_line_mean_len").and_then(|v| v.as_bool()).unwrap_or(false);
let track_line_median = options.get("text_line_median_len").and_then(|v| v.as_bool()).unwrap_or(false);
// Update tracking options - use default values if not present in options
self.track_word_count = options.get("text_word_count")
.and_then(|v| v.as_bool())
.unwrap_or(true);
self.track_line_count = options.get("text_line_count")
.and_then(|v| v.as_bool())
.unwrap_or(true);
// For line length tracking, check if any of the line length options are enabled
let track_line_max = options.get("text_line_max_len")
.and_then(|v| v.as_bool())
.unwrap_or(true);
let track_line_mean = options.get("text_line_mean_len")
.and_then(|v| v.as_bool())
.unwrap_or(true);
let track_line_median = options.get("text_line_median_len")
.and_then(|v| v.as_bool())
.unwrap_or(true);
self.track_line_lengths = track_line_max || track_line_mean || track_line_median;
if self.track_line_lengths && self.line_lengths.is_none() {