From 2215c32e57250ffafe86ff3c2466e77fea31781e Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Tue, 10 Oct 2023 00:11:05 -0400 Subject: [PATCH] compare_properties table cell. --- src/compare/diff.rs | 29 +++++++++++++++++++++++------ src/parser/table.rs | 3 ++- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/compare/diff.rs b/src/compare/diff.rs index 5b654ab..7509d36 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -1798,16 +1798,33 @@ fn compare_table_row<'b, 's>( } fn compare_table_cell<'b, 's>( - _source: &'s str, + source: &'s str, emacs: &'b Token<'s>, rust: &'b TableCell<'s>, ) -> Result, Box> { - let children = emacs.as_list()?; - let child_status = Vec::new(); - let this_status = DiffStatus::Good; - let message = None; + let mut this_status = DiffStatus::Good; + let mut child_status = Vec::new(); + let mut message = None; - for (_emacs_child, _rust_child) in children.iter().skip(2).zip(rust.children.iter()) {} + compare_children( + source, + emacs, + &rust.children, + &mut child_status, + &mut this_status, + &mut message, + )?; + + for diff in compare_properties!(emacs) { + match diff { + ComparePropertiesResult::NoChange => {} + ComparePropertiesResult::SelfChange(new_status, new_message) => { + this_status = new_status; + message = new_message + } + ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry), + } + } Ok(DiffResult { status: this_status, diff --git a/src/parser/table.rs b/src/parser/table.rs index ac0083d..f3b5a33 100644 --- a/src/parser/table.rs +++ b/src/parser/table.rs @@ -176,12 +176,13 @@ fn org_mode_table_cell<'b, 'g, 'r, 's>( let table_cell_set_object_matcher = parser_with_context!(table_cell_set_object)(&parser_context); let exit_matcher = parser_with_context!(exit_matcher_parser)(&parser_context); + let (remaining, _) = space0(input)?; let (remaining, (children, _exit_contents)) = verify( many_till(table_cell_set_object_matcher, exit_matcher), |(children, exit_contents)| { !children.is_empty() || Into::<&str>::into(exit_contents).ends_with("|") }, - )(input)?; + )(remaining)?; let (remaining, _tail) = org_mode_table_cell_end(&parser_context, remaining)?;