From efc6bd11d940a5285387fa984adbbadda773b0a8 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Wed, 11 Oct 2023 18:59:13 -0400 Subject: [PATCH] Do not exit on first loop. --- src/compare/compare_field.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/compare/compare_field.rs b/src/compare/compare_field.rs index 27a7922..ed15224 100644 --- a/src/compare/compare_field.rs +++ b/src/compare/compare_field.rs @@ -460,6 +460,8 @@ pub(crate) fn compare_property_list_of_list_of_list_of_ast_nodes< (Some(value), Some(rust_value)) => (value, rust_value), }; + let mut child_status: Vec> = Vec::with_capacity(rust_value.len()); + // Iterate the outer lists for (value, (rust_optional, rust_value)) in value.iter().zip(rust_value.iter()) { let mut middle_value = value.as_list()?.iter(); @@ -476,7 +478,6 @@ pub(crate) fn compare_property_list_of_list_of_list_of_ast_nodes< return Ok(ComparePropertiesResult::SelfChange(this_status, message)); } }; - let mut child_status: Vec> = Vec::with_capacity(rust_value.len()); // Compare optional value if let Some(rust_optional) = rust_optional { @@ -489,6 +490,7 @@ pub(crate) fn compare_property_list_of_list_of_list_of_ast_nodes< return Ok(ComparePropertiesResult::SelfChange(this_status, message)); } for (e, r) in middle_value.zip(rust_optional) { + eprintln!("Comparing optval! {:?} {:?}", e, r); child_status.push(compare_ast_node(source, e, r.into())?); } } @@ -504,12 +506,16 @@ pub(crate) fn compare_property_list_of_list_of_list_of_ast_nodes< return Ok(ComparePropertiesResult::SelfChange(this_status, message)); } for (e, r) in mandatory_value.iter().zip(rust_value) { + eprintln!("Comparing mandatory! {:?} {:?}", e, r); child_status.push(compare_ast_node(source, e, r.into())?); } - let diff_scope = artificial_owned_diff_scope(emacs_field, child_status)?; - return Ok(ComparePropertiesResult::DiffEntry(diff_scope)); } - Ok(ComparePropertiesResult::NoChange) + if child_status.is_empty() { + Ok(ComparePropertiesResult::NoChange) + } else { + let diff_scope = artificial_owned_diff_scope(emacs_field, child_status)?; + Ok(ComparePropertiesResult::DiffEntry(diff_scope)) + } } pub(crate) fn compare_property_number_lines<