Skip to content

Conversation

@andy-goryachev-oracle
Copy link
Contributor

@andy-goryachev-oracle andy-goryachev-oracle commented Oct 20, 2025

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.

This PR also adds isUndoRedoEnabled() and setUndoRedoEnabled() to the StyledTextModel, as well as its forwarding aliases to RichTextArea to allow for the application to disable undo/redo temporarily, for example, when building a document from multiple segments.

WARNING this is an incompatible change, permitted because of the incubator.

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, see https://bugs.openjdk.org/browse/JDK-8370447 .

/reviewers 2
/csr


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change requires a CSR request matching fixVersion jfx26 to be approved (needs to be created)
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

  • JDK-8366201: RichTextArea: remove allowUndo parameter (Enhancement - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1941/head:pull/1941
$ git checkout pull/1941

Update a local copy of the PR:
$ git checkout pull/1941
$ git pull https://git.openjdk.org/jfx.git pull/1941/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1941

View PR using the GUI difftool:
$ git pr show -t 1941

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1941.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 20, 2025

👋 Welcome back angorya! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Oct 20, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot added the csr Need approved CSR to integrate pull request label Oct 20, 2025
@openjdk
Copy link

openjdk bot commented Oct 20, 2025

@andy-goryachev-oracle has indicated that a compatibility and specification (CSR) request is needed for this pull request.

@andy-goryachev-oracle please create a CSR request for issue JDK-8366201 with the correct fix version. This pull request cannot be integrated until the CSR request is approved.

@openjdk
Copy link

openjdk bot commented Oct 20, 2025

@andy-goryachev-oracle an approved CSR request is already required for this pull request.

@andy-goryachev-oracle andy-goryachev-oracle changed the title 8366201: RichTextArea: add undo parameter to applyStyle/setStyle 8366201: RichTextArea: remove allowUndo parameter Oct 21, 2025
@andy-goryachev-oracle
Copy link
Contributor Author

/reviewers 2

@andy-goryachev-oracle andy-goryachev-oracle marked this pull request as ready for review October 21, 2025 21:24
@openjdk openjdk bot added the rfr Ready for review label Oct 21, 2025
@openjdk
Copy link

openjdk bot commented Oct 21, 2025

@andy-goryachev-oracle
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

@mlbridge
Copy link

mlbridge bot commented Oct 21, 2025

Webrevs

@kevinrushforth
Copy link
Member

This will also need a csr.

/csr

@kevinrushforth
Copy link
Member

This will also need a csr.

Ah, and I see you already marked it as such

@kevinrushforth kevinrushforth self-requested a review October 21, 2025 21:36
@openjdk
Copy link

openjdk bot commented Oct 21, 2025

@kevinrushforth an approved CSR request is already required for this pull request.

@kevinrushforth
Copy link
Member

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.

@andy-goryachev-oracle andy-goryachev-oracle marked this pull request as draft October 22, 2025 17:28
@openjdk openjdk bot removed the rfr Ready for review label Oct 22, 2025
@andy-goryachev-oracle
Copy link
Contributor Author

andy-goryachev-oracle commented Oct 22, 2025

Thank you @kevinrushforth for suggesting the enableUndo (enableUndoRedo ?) property.

Consider a scenario of building a (large) document programmatically: in the absence of such a property, the undo entries will be created, consuming the resources, to be immediately discarded by clearUnoRedo() at the end, as suggested earlier. A better solution is to indeed explicitly disable the undo/redo via a new property. This is especially helpful when we consider that currently the undo/redo stack has no limit - see also https://bugs.openjdk.org/browse/JDK-8370447 .

Converting this PR back to Draft to add the property, since the code is interdependent and we'll need a CSR anyway.

@andy-goryachev-oracle andy-goryachev-oracle marked this pull request as ready for review October 22, 2025 23:15
@openjdk openjdk bot added the rfr Ready for review label Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

csr Need approved CSR to integrate pull request rfr Ready for review

Development

Successfully merging this pull request may close these issues.

2 participants