Compare text length for plain text in the diffing.

This commit is contained in:
Tom Alexander 2023-04-24 18:21:38 -04:00
parent 11081f6936
commit 0fc3bb0245
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -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;