From 0fc3bb024539d1973483e2b495f9df601496b1dc Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 24 Apr 2023 18:21:38 -0400 Subject: [PATCH] Compare text length for plain text in the diffing. --- src/compare/diff.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/compare/diff.rs b/src/compare/diff.rs index 80df736..fbb008e 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -915,6 +915,18 @@ fn compare_plain_text<'s>( let mut this_status = DiffStatus::Good; let mut message = None; let text = emacs.as_text()?; + let emacs_text_length = { + let start_ind: usize = text.properties.get(0).expect("Should have start index.").as_atom()?.parse()?; + let end_ind: usize = text.properties.get(1).expect("Should have end index.").as_atom()?.parse()?; + end_ind - start_ind + }; + if rust.source.len() != emacs_text_length { + this_status = DiffStatus::Bad; + message = Some(format!( + "(emacs len != rust len) {:?} != {:?}", + emacs_text_length, rust.source.len() + )); + } let unquoted_text = text.unquote()?; if unquoted_text != rust.source { this_status = DiffStatus::Bad;