Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unnecessary disambiguation around ibids #250

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/csl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ impl<T: EntryLike> Default for BibliographyDriver<'_, T> {
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
struct SpeculativeItemRender<'a, T: EntryLike> {
rendered: ElemChildren,
rendered_without_ibid: ElemChildren,
entry: &'a T,
cite_props: CiteProperties<'a>,
checked_disambiguate: bool,
Expand Down Expand Up @@ -182,6 +183,17 @@ impl<'a, T: EntryLike + Hash + PartialEq + Eq + Debug> BibliographyDriver<'a, T>
None,
);

let mut cite_props_without_ibid = cite_props.clone();
cite_props_without_ibid.speculative.ibid = IbidState::Different;
let ctx_without_ibid = style.do_citation(
*entry,
cite_props_without_ibid,
item.locale.as_ref(),
citation.locale.as_ref(),
item.purpose,
None,
);

// Copy the identifier usage from the context. Assume it does
// not change throughout disambiguation.
cite_props.speculative.identifier_usage =
Expand All @@ -196,6 +208,7 @@ impl<'a, T: EntryLike + Hash + PartialEq + Eq + Debug> BibliographyDriver<'a, T>
group_idx: None,
locator: item.locator,
rendered: ctx.flush(),
rendered_without_ibid: ctx_without_ibid.flush(),
hidden: item.hidden,
locale: item.locale.clone(),
purpose: item.purpose,
Expand Down Expand Up @@ -850,7 +863,7 @@ fn find_ambiguous_sets<T: EntryLike + PartialEq>(
continue;
}

let buf = format!("{:?}", item.rendered);
let buf = format!("{:?}", item.rendered_without_ibid);
match map.entry(buf) {
HmEntry::Occupied(entry) => match *entry.get() {
PotentialDisambiguation::Single(pos) => {
Expand Down
Loading