Skip to content

Ctrl+Z (undo) not working any more #11420

@koppor

Description

@koppor

Originally reported at #11282 (comment)

An exception is thrown when trying to use Ctrl+Z on any text field in the entry editor.

2024-06-19 06:13:03 [JavaFX Application Thread] org.jabref.gui.FallbackExceptionHandler.uncaughtException()
ERROR: Uncaught exception occurred in Thread[#54,JavaFX Application Thread,5,main]: java.lang.NullPointerException: Cannot read field "next" because "this.undoChange" is null
	at javafx.controls@22.0.1/javafx.scene.control.TextInputControl.updateUndoRedoState(TextInputControl.java:1250)

A work-around is to disable the key combinations Ctrl+Z and Ctrrl+Y for the field:

        // We need to consume the key event to avoid the default behavior of undo/redo and enable JabRef's undo/redo
        // Source: https://stackoverflow.com/a/37575818/873282
        textInputControl.addEventFilter(KeyEvent.ANY, e -> {
            if (e.getCode() == KeyCode.Z && e.isShortcutDown()) {
                e.consume();
            }
        });

However, the undo/redo should still work. I went through the code a bit, but org.jabref.gui.frame.JabRefFrame.UndoRedoEventManager#updateTexts is "dead" code and I don't know further (yet).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions