JDK-8370447 : RichTextArea: undo/redo improvements
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: jfx25
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2025-10-22
  • Updated: 2025-10-31
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Relates :  
Description
This is a follow-up to https://bugs.openjdk.org/browse/JDK-8366201

The undo/redo code needs to

1. Possibly limit the depth of undo/redo stack.  Example: a text editor application that remains open for weeks editing the same document, the undo-redo stack growing uncontrollably.  Practically speaking, there is little need to keep more that 100 or 200 undo/redo entries, it is hardly a necessity to go back more than a dozen or two steps back.

2. The simple undo events need to coalesce, similarly to what TextArea does.  As a reference, these are the conditions listed in TextInputControl:613

        /*
         * A new undo record is created, if
         * 1. createNewUndoRecord is true, currently it is set to true for paste operation
         * 2. Text is selected and a character is typed
         * 3. This is the first operation to be added to undo record
         * 4. forceNewUndoRecord is true, currently it is set to true if there is no text present
         * 5. Space character is typed
         * 6. 2500 milliseconds are elapsed since the undo record was created
         * 7. Cursor position is changed and a character is typed
         * 8. A range of text is replaced programmatically using replaceText()
         * Otherwise, the last undo record is updated or discarded.
         */

3. IME calls RichTextArea.replaceText() to insert composed text which accumulates undo events.  These should probably be coalesced.

4. Need to test how the IME works with undo/redo keyboard bindings - see RichTextAreaSkin:265