RFR: 8366201: RichTextArea: remove allowUndo parameter

Kevin Rushforth kcr at openjdk.org
Wed Oct 22 13:41:00 UTC 2025


On Mon, 20 Oct 2025 23:04:17 GMT, Andy Goryachev <angorya at openjdk.org> wrote:

> Original user feedback (see https://mail.openjdk.org/pipermail/openjfx-discuss/2025-August/000267.html ) called for adding an `allowUndo` parameter to `applyStyle()` and `setStyle()` methods similarly to `replaceText()`.
> 
> Upon further analysis, the `allowUndo` parameter was a mistake: allowing the application code to disable creating undo/redo entries messes up the internal undo/redo stack.
> There is an internal need (`UndoableChange`), but it should not be exposed via public API.
> 
> Whenever the application needs to disable undo/redo functionality (while, for example, building a document from multiple segments), this can be accomplished by calling clearUndoRedo().
> 
> There remains a possible issue with currently unlimited size of the undo/redo stack - perhaps we should limit its depth to maybe 100-200 entries (in a follow-up ticket).

I agree that having this as a per-method argument doesn't make sense.

I think it's worth considering a future enhancement to add a property to enable or disable the undo feature, with a default of `true`. When set to `true`, it stores entries in the undo stack and enables undo/redo. When set to `false`, it discards the current stack and doesn't store anything or allow undo/redo until the next time it is set to true.

-------------

PR Comment: https://git.openjdk.org/jfx/pull/1941#issuecomment-3432416410


More information about the openjfx-dev mailing list