From 9088b76067590c2d837f9b3632b5fc08ec21e150 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 27 Aug 2025 10:09:43 -0300 Subject: [PATCH] fix: add debug logging and set default values for text plugin options Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) --- src/meta_plugin/text.rs | 45 +++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/src/meta_plugin/text.rs b/src/meta_plugin/text.rs index 047cb75..bee5a2a 100644 --- a/src/meta_plugin/text.rs +++ b/src/meta_plugin/text.rs @@ -499,6 +499,7 @@ impl MetaPlugin for TextMetaPlugin { } fn configure_options(&mut self, options: &std::collections::HashMap) -> 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() {