Compare plain list item counter.
This commit is contained in:
@@ -52,6 +52,7 @@ use crate::types::Paragraph;
|
||||
use crate::types::PlainLink;
|
||||
use crate::types::PlainList;
|
||||
use crate::types::PlainListItem;
|
||||
use crate::types::PlainListItemCounter;
|
||||
use crate::types::PlainListType;
|
||||
use crate::types::PlainText;
|
||||
use crate::types::Planning;
|
||||
@@ -754,6 +755,7 @@ fn compare_plain_list<'s>(
|
||||
let mut this_status = DiffStatus::Good;
|
||||
let mut message = None;
|
||||
|
||||
// Compare type
|
||||
// :type is an unquoted atom of either descriptive, ordered, or unordered
|
||||
let list_type = get_property_unquoted_atom(emacs, ":type")?;
|
||||
match (list_type, &rust.list_type) {
|
||||
@@ -831,17 +833,41 @@ fn compare_plain_list_item<'s>(
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
child_status.push(artificial_diff_scope("contents", contents_status)?);
|
||||
|
||||
// TODO: Compare :counter :pre-blank
|
||||
// Compare bullet
|
||||
let bullet = get_property_quoted_string(emacs, ":bullet")?
|
||||
.ok_or("Plain list items must have a :bullet.")?;
|
||||
if bullet != rust.bullet {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Plain list item bullet mismatch (emacs != rust) {:?} != {:?}",
|
||||
"Bullet mismatch (emacs != rust) {:?} != {:?}",
|
||||
bullet, rust.bullet
|
||||
));
|
||||
}
|
||||
|
||||
// Compare counter
|
||||
let counter = get_property_unquoted_atom(emacs, ":counter")?;
|
||||
let counter: Option<PlainListItemCounter> = counter
|
||||
.map(|val| val.parse())
|
||||
.map_or(Ok(None), |r| r.map(Some))?;
|
||||
match (counter, rust.counter) {
|
||||
(None, None) => {}
|
||||
(None, Some(_)) | (Some(_), None) => {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Counter mismatch (emacs != rust) {:?} != {:?}",
|
||||
counter, rust.counter
|
||||
));
|
||||
}
|
||||
(Some(e), Some(r)) if e != r => {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Counter mismatch (emacs != rust) {:?} != {:?}",
|
||||
counter, rust.counter
|
||||
));
|
||||
}
|
||||
(Some(_), Some(_)) => {}
|
||||
};
|
||||
|
||||
// Compare checkbox
|
||||
let checkbox = get_property(emacs, ":checkbox")?
|
||||
.map(Token::as_atom)
|
||||
@@ -861,6 +887,8 @@ fn compare_plain_list_item<'s>(
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: Compare :pre-blank
|
||||
|
||||
Ok(DiffResult {
|
||||
status: this_status,
|
||||
name: rust.get_elisp_name(),
|
||||
|
||||
Reference in New Issue
Block a user