From 9deb2c24c3079dc0e068c90abc7d4868986d670b Mon Sep 17 00:00:00 2001 From: RJavues <48386227+JavuesZhang@users.noreply.github.com> Date: Tue, 20 Apr 2021 23:19:31 +0800 Subject: [PATCH] Fixes #7016 Make a copy of selected entries and change field in the copy so that the sort strategy will not influence the result. --- CHANGELOG.md | 1 + .../java/org/jabref/gui/specialfields/SpecialFieldAction.java | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c8a42e61f1..ec5ddc651e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,6 +77,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue with saving large `.bib` files [#7265](https://github.com/JabRef/jabref/issues/7265) - We fixed an issue with very large page numbers [#7590](https://github.com/JabRef/jabref/issues/7590) - We fixed an issue where the article title with curly brackets fails to download the arXiv link (pdf file). [#7633](https://github.com/JabRef/jabref/issues/7633) +- We fixed an issue with toggle of special fields does not work for sorted entries [#7016](https://github.com/JabRef/jabref/issues/7016) ### Removed diff --git a/src/main/java/org/jabref/gui/specialfields/SpecialFieldAction.java b/src/main/java/org/jabref/gui/specialfields/SpecialFieldAction.java index 130bf0e3b68..d95cff66d47 100644 --- a/src/main/java/org/jabref/gui/specialfields/SpecialFieldAction.java +++ b/src/main/java/org/jabref/gui/specialfields/SpecialFieldAction.java @@ -1,5 +1,6 @@ package org.jabref.gui.specialfields; +import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.Optional; @@ -69,7 +70,8 @@ public void execute() { return; } NamedCompound ce = new NamedCompound(undoText); - for (BibEntry bibEntry : bes) { + List besCopy = new ArrayList<>(bes); + for (BibEntry bibEntry : besCopy) { // if (value==null) and then call nullField has been omitted as updatefield also handles value==null Optional change = UpdateField.updateField(bibEntry, specialField, value, nullFieldIfValueIsTheSame);