Skip to content
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

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

Closed
koppor opened this issue Jun 24, 2024 · 7 comments · Fixed by #11421
Closed

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

koppor opened this issue Jun 24, 2024 · 7 comments · Fixed by #11421
Milestone

Comments

@koppor
Copy link
Member

koppor commented Jun 24, 2024

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 [email protected]/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).

@koppor koppor added this to the 5.14 milestone Jun 24, 2024
@koppor koppor mentioned this issue Jun 24, 2024
6 tasks
@koppor
Copy link
Member Author

koppor commented Jun 24, 2024

In parallel to a fix, we should create an MWE showing the error inside (!) JavaFX and report a bug.

@Siedlerchr
Copy link
Member

I think when previously the field was empty, and you now enter something
ctrl + z
exception occurs

Now type again and ctrl + z again it works fine

@ryan-carpenter
Copy link

I think when previously the field was empty, and you now enter something ctrl + z exception occurs

Now type again and ctrl + z again it works fine

I think when previously the field was empty, and you now enter something ctrl + z exception occurs

Now type again and ctrl + z again it works fine

The exception also occurs when there is text in the field.

@koppor
Copy link
Member Author

koppor commented Jun 26, 2024

I think, it was introduced with our bindings

https://github.com/JabRef/jabref/pull/11282/files#diff-12c8d5c64666483ab38360768d084135c872d59c6798fe13184dfdec888d99eb

As said at #11421 (comment): New reproducer (I started to work on one but did not push 🙈)

@LoayGhreeb
Copy link
Collaborator

Using the menu bar (Edit -> Undo) to undo changes works without any exceptions.

Another issue, which may or may not be related, is that when updating a field using the context menu (Clear, Change Case, Normalize) and using Ctrl+Z to undo this change, nothing happens and no exception occurs. I can only undo this change from the menu bar. However, when using "Protect Selection" from the context menu, this change is undoable but with the exception.

@koppor
Copy link
Member Author

koppor commented Jul 6, 2024

JavaFX TextField issue: Asked in #java-german (https://jvm-german.slack.com/archives/C4H2FQKND/p1720297099980919) and created an MWE: Siedlerchr/javafxreproducer#22

@koppor
Copy link
Member Author

koppor commented Jul 6, 2024

I checked the source code at https://github.com/openjdk/jfx17u/blob/a205815f99903a1a55c3fbb65a904b20584fb3fc/modules/javafx.controls/src/main/java/javafx/scene/control/TextInputControl.java#L1482 - it should work. However, if I decompile TextInputControll, I get a different source. -- Currently investigating.

Update I asked about it at the openjfx-discuss mailing list: https://mail.openjdk.org/pipermail/openjfx-discuss/2024-July/000226.html

Update: https://bugs.openjdk.org/browse/JDK-8336065 - our discussion at Siedlerchr/javafxreproducer#22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants