fix: handle disabled text outputs properly

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 18:32:37 -03:00
parent 695c51a97e
commit 3e7f491b74

View File

@@ -48,6 +48,29 @@ impl TextMetaPlugin {
outputs, outputs,
); );
// Set disabled outputs to null based on options
let outputs_to_disable = vec![
("text_word_count", "text_word_count"),
("text_line_count", "text_line_count"),
("text_line_max_len", "text_line_max_len"),
("text_line_mean_len", "text_line_mean_len"),
("text_line_median_len", "text_line_median_len"),
];
for (option_name, output_name) in outputs_to_disable {
if let Some(value) = base.options.get(option_name) {
// Handle both boolean false and string "false"
let should_disable = match value {
serde_yaml::Value::Bool(b) => !b,
serde_yaml::Value::String(s) => s == "false",
_ => false,
};
if should_disable {
base.outputs.insert(output_name.to_string(), serde_yaml::Value::Null);
}
}
}
// Set default options if not provided // Set default options if not provided
let default_options = vec![ let default_options = vec![
("text_detect_size", serde_yaml::Value::Number(PIPESIZE.into())), ("text_detect_size", serde_yaml::Value::Number(PIPESIZE.into())),