Skip to content

Changed the behavior of the field formatting dialog #4275

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

Merged
merged 4 commits into from
Aug 21, 2018
Merged
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
## [Unreleased]

### Changed
- We changed the behavior of the field formatting dialog such that the `bibtexkey` is not changed when formatting all fields or all text fields.
- We added a "Move file to file directory and rename file" option for simultaneously moving and renaming of document file. [#4166](https://github.com/JabRef/jabref/issues/4166)
- Use integrated graphics card instead of discrete on macOS [#4070](https://github.com/JabRef/jabref/issues/4070)
- We changed the minimum required version of Java to 1.8.0_171, as this is the latest release for which the automatic Java update works. [4093](https://github.com/JabRef/jabref/issues/4093)
Expand Down Expand Up @@ -118,9 +119,9 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#

## Older versions

The changelog of JabRef 4.x is available at the [v4.x branch](https://github.com/JabRef/jabref/blob/v4.x/CHANGELOG.md).
The changelog of JabRef 3.x is available at the [v3.8.2 tag](https://github.com/JabRef/jabref/blob/v3.8.2/CHANGELOG.md).
The changelog of JabRef 2.11 and all previous versions is available as [text file in the v2.11.1 tag](https://github.com/JabRef/jabref/blob/v2.11.1/CHANGELOG).
The changelog of JabRef 4.x is available at the [v4.x branch](https://github.com/JabRef/jabref/blob/v4.x/CHANGELOG.md).
The changelog of JabRef 3.x is available at the [v3.8.2 tag](https://github.com/JabRef/jabref/blob/v3.8.2/CHANGELOG.md).
The changelog of JabRef 2.11 and all previous versions is available as [text file in the v2.11.1 tag](https://github.com/JabRef/jabref/blob/v2.11.1/CHANGELOG).

[Unreleased]: https://github.com/JabRef/jabref/compare/v4.3...HEAD
[4.3]: https://github.com/JabRef/jabref/compare/v4.2...v4.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ private List<FieldChange> cleanupAllFields(BibEntry entry) {
List<FieldChange> fieldChanges = new ArrayList<>();

for (String fieldKey : entry.getFieldNames()) {
fieldChanges.addAll(cleanupSingleField(fieldKey, entry));
if (!fieldKey.equals(BibEntry.KEY_FIELD)) {
fieldChanges.addAll(cleanupSingleField(fieldKey, entry));
}
}

return fieldChanges;
Expand All @@ -82,7 +84,9 @@ private List<FieldChange> cleanupAllTextFields(BibEntry entry) {
Set<String> fields = entry.getFieldNames();
fields.removeAll(FieldName.getNotTextFieldNames());
for (String fieldKey : fields) {
fieldChanges.addAll(cleanupSingleField(fieldKey, entry));
if (!fieldKey.equals(BibEntry.KEY_FIELD)) {
fieldChanges.addAll(cleanupSingleField(fieldKey, entry));
}
}

return fieldChanges;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Map;

import org.jabref.logic.formatter.casechanger.UpperCaseFormatter;
import org.jabref.logic.formatter.bibtexfields.UnicodeToLatexFormatter;
import org.jabref.model.cleanup.FieldFormatterCleanup;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibtexEntryTypes;
Expand Down Expand Up @@ -63,4 +64,32 @@ public void testInternalAllTextFieldsField() throws Exception {
assertEquals(fieldMap.get("doi"), entry.getField("doi").get());
assertEquals(fieldMap.get("issn"), entry.getField("issn").get());
}

@Test
public void testCleanupAllFieldsIgnoresKeyField() throws Exception {
FieldFormatterCleanup cleanup = new FieldFormatterCleanup(FieldName.INTERNAL_ALL_FIELD, new UnicodeToLatexFormatter());
entry.setField(BibEntry.KEY_FIELD, "François-Marie Arouet"); // Contains ç, not in Basic Latin
cleanup.cleanup(entry);

assertEquals("François-Marie Arouet", entry.getField(BibEntry.KEY_FIELD).get());
}

@Test
public void testCleanupAllTextFieldsIgnoresKeyField() throws Exception {
FieldFormatterCleanup cleanup = new FieldFormatterCleanup(FieldName.INTERNAL_ALL_TEXT_FIELDS_FIELD, new UnicodeToLatexFormatter());
entry.setField(BibEntry.KEY_FIELD, "François-Marie Arouet"); // Contains ç, not in Basic Latin
cleanup.cleanup(entry);

assertEquals("François-Marie Arouet", entry.getField(BibEntry.KEY_FIELD).get());
}

@Test
public void testCleanupKeyFieldCleansUpKeyField() throws Exception {
FieldFormatterCleanup cleanup = new FieldFormatterCleanup(BibEntry.KEY_FIELD, new UnicodeToLatexFormatter());
entry.setField(BibEntry.KEY_FIELD, "François-Marie Arouet"); // Contains ç, not in Basic Latin
cleanup.cleanup(entry);

assertEquals("Fran{\\c{c}}ois-Marie Arouet", entry.getField(BibEntry.KEY_FIELD).get());
}

}