diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8272f44b43f..fe57e60d3d0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -91,7 +91,7 @@ jobs: runs-on: ubuntu-latest services: postgres: - image: postgres:10.8 + image: postgres:13-alpine env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres diff --git a/build.gradle b/build.gradle index d60add7d268..e58b659c2a7 100644 --- a/build.gradle +++ b/build.gradle @@ -204,7 +204,7 @@ dependencies { testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.7.0' testImplementation 'org.junit.platform:junit-platform-launcher:1.7.0' - testImplementation 'net.bytebuddy:byte-buddy-parent:1.10.17' + testImplementation 'net.bytebuddy:byte-buddy-parent:1.10.18' testRuntime group: 'org.apache.logging.log4j', name: 'log4j-core', version: '3.0.0-SNAPSHOT' testRuntime group: 'org.apache.logging.log4j', name: 'log4j-jul', version: '3.0.0-SNAPSHOT' testImplementation 'org.mockito:mockito-core:3.6.0' diff --git a/src/main/java/org/jabref/logic/util/CoarseChangeFilter.java b/src/main/java/org/jabref/logic/util/CoarseChangeFilter.java index ead72efe4d5..ed3ef873aaa 100644 --- a/src/main/java/org/jabref/logic/util/CoarseChangeFilter.java +++ b/src/main/java/org/jabref/logic/util/CoarseChangeFilter.java @@ -46,7 +46,7 @@ public synchronized void listen(BibDatabaseContextChangedEvent event) { boolean isChangedEntry = lastEntryChanged.filter(e -> !e.equals(fieldChange.getBibEntry())).isPresent(); boolean isEditChanged = !isNewEdit && (isChangedField || isChangedEntry); // Only deltas of 1 when typing in manually, major change means pasting something (more than one character) - boolean isMajorChange = fieldChange.getDelta() > 1; + boolean isMajorChange = fieldChange.getMajorCharacterChange() > 1; fieldChange.setFilteredOut(!(isEditChanged || isMajorChange)); // Post each FieldChangedEvent - even the ones being marked as "filtered" diff --git a/src/main/java/org/jabref/model/entry/event/FieldChangedEvent.java b/src/main/java/org/jabref/model/entry/event/FieldChangedEvent.java index 45d9ae2ec1d..3f4eda3838e 100644 --- a/src/main/java/org/jabref/model/entry/event/FieldChangedEvent.java +++ b/src/main/java/org/jabref/model/entry/event/FieldChangedEvent.java @@ -12,7 +12,7 @@ public class FieldChangedEvent extends EntryChangedEvent { private final Field field; private final String newValue; private final String oldValue; - private int delta = 0; + private int majorCharacterChange = 0; /** * @param bibEntry Affected BibEntry object @@ -27,7 +27,7 @@ public FieldChangedEvent(BibEntry bibEntry, Field field, String newValue, String this.field = field; this.newValue = newValue; this.oldValue = oldValue; - this.delta = computeDelta(oldValue, newValue); + this.majorCharacterChange = computeMajorCharacterChange(oldValue, newValue); } /** @@ -40,7 +40,7 @@ public FieldChangedEvent(BibEntry bibEntry, Field field, String newValue, String this.field = field; this.newValue = newValue; this.oldValue = oldValue; - this.delta = computeDelta(oldValue, newValue); + this.majorCharacterChange = computeMajorCharacterChange(oldValue, newValue); } /** @@ -51,20 +51,22 @@ public FieldChangedEvent(FieldChange fieldChange, EntriesEventSource location) { this.field = fieldChange.getField(); this.newValue = fieldChange.getNewValue(); this.oldValue = fieldChange.getOldValue(); - this.delta = computeDelta(oldValue, newValue); + this.majorCharacterChange = computeMajorCharacterChange(oldValue, newValue); } public FieldChangedEvent(FieldChange fieldChange) { this(fieldChange, EntriesEventSource.LOCAL); } - private int computeDelta(String oldValue, String newValue) { + private int computeMajorCharacterChange(String oldValue, String newValue) { if (oldValue == newValue) { return 0; - } else if (oldValue == null && newValue != null) { + } else if ((oldValue == null) && (newValue != null)) { return newValue.length(); - } else if (newValue == null && oldValue != null) { + } else if ((newValue == null) && (oldValue != null)) { return oldValue.length(); + } else if ((oldValue.length() == newValue.length()) && !oldValue.equals(newValue)) { + return newValue.length(); } else { return Math.abs(newValue.length() - oldValue.length()); } @@ -82,7 +84,7 @@ public String getOldValue() { return oldValue; } - public int getDelta() { - return delta; + public int getMajorCharacterChange() { + return majorCharacterChange; } }