diff --git a/src/main/java/org/jabref/gui/fieldeditors/AbstractEditorViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/AbstractEditorViewModel.java index 22306c2e40f..a8d1fb7632e 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/AbstractEditorViewModel.java +++ b/src/main/java/org/jabref/gui/fieldeditors/AbstractEditorViewModel.java @@ -63,12 +63,13 @@ public void bindToEntry(BibEntry entry) { fieldBinding, newValue -> { if (newValue != null) { - String oldValue = entry.getField(field).orElse(null); - if (!newValue.equals(oldValue)) { - entry.setField(field, newValue); - UndoManager undoManager = JabRefGUI.getMainFrame().getUndoManager(); - undoManager.addEdit(new UndoableFieldChange(entry, field, oldValue, newValue)); - } + entry.getField(field).ifPresent(oldValue -> { + if (!(newValue.trim()).equals(oldValue.trim())) { + entry.setField(field, newValue); + UndoManager undoManager = JabRefGUI.getMainFrame().getUndoManager(); + undoManager.addEdit(new UndoableFieldChange(entry, field, oldValue, newValue)); + } + }); } }); }