Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into customDarkTheme
Browse files Browse the repository at this point in the history
* upstream/master:
  Fix Shared Database Tests (#7040)
  Bump byte-buddy-parent from 1.10.17 to 1.10.18 (#7059)
  • Loading branch information
Siedlerchr committed Nov 3, 2020
2 parents 12f542a + b5bcea4 commit 155fd0f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
20 changes: 11 additions & 9 deletions src/main/java/org/jabref/model/entry/event/FieldChangedEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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());
}
Expand All @@ -82,7 +84,7 @@ public String getOldValue() {
return oldValue;
}

public int getDelta() {
return delta;
public int getMajorCharacterChange() {
return majorCharacterChange;
}
}

0 comments on commit 155fd0f

Please sign in to comment.