From b7ea6ec8ee6c7573ab267d721dd814b7018c053a Mon Sep 17 00:00:00 2001 From: trivernis Date: Fri, 4 Sep 2020 19:06:55 +0200 Subject: [PATCH] Fix ordered entries containing some entries multiple times Signed-off-by: trivernis --- Cargo.toml | 2 +- src/bib_manager.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 23d4af1..ecfeba9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bibliographix" description = "A bibliography management crate." -version = "0.3.1" +version = "0.3.2" authors = ["trivernis "] edition = "2018" license = "Apache-2.0" diff --git a/src/bib_manager.rs b/src/bib_manager.rs index e7d4e6f..e55157b 100644 --- a/src/bib_manager.rs +++ b/src/bib_manager.rs @@ -57,11 +57,15 @@ impl BibManager { /// Returns the list of bibliography entries ordered by first referenced pub fn get_entry_list_by_occurrence(&self) -> Vec { let mut entries = Vec::new(); + let mut inserted_keys = Vec::new(); let entry_dict = self.entry_dictionary.lock().unwrap(); for bib_ref in self.root_ref_anchor.lock().unwrap().references() { if let Some(bib_entry) = entry_dict.get(bib_ref.key()) { - entries.push(bib_entry); + if !inserted_keys.contains(bib_ref.key()) { + entries.push(bib_entry); + inserted_keys.push(bib_ref.key().clone()) + } } }