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

edit / update / reopen #315

Closed
tonydroy opened this issue May 7, 2024 · 2 comments
Closed

edit / update / reopen #315

tonydroy opened this issue May 7, 2024 · 2 comments

Comments

@tonydroy
Copy link

tonydroy commented May 7, 2024

I am experiencing a cluster of issues with restoring documents in the RichTextArea that I do not understand. In the 1.1.2 version I can reproduce the issues with a modified version of the FullFeaturedDemo.

Modifications:
The document variable is no longer final and simplified to,

private Document document = new Document("this is\na test");

Buttons are created as follows,

Button updateDocButton = new Button("update doc");
        updateDocButton.setOnAction(e -> document = editor.getDocument() );

Button setDocumentButton = new Button("set doc");
 //       setDocumentButton.setOnAction(e -> editor.setDocument(document) );
        setDocumentButton.setOnAction(e -> editor.getActionFactory().open(document).execute(new ActionEvent()));

And the buttons are added to toolbar.

Behavior:
I expect that I should be able to: open document (with the toolbar button) / edit / press update / press clear / press open or set -- and see my edited document again. Here is what I get:

  1. With the second (action factory) version of 'set' I can: open / add text to the very end / update / clear / set -- and, as expected, the edited text is restored.

  2. Still with the second (action factory) version of 'set': open / edit text not at the end / update / clear / set -- results in StringIndexOutOfBoundsException (PieceTable.java: 83).

  3. With the first (setDocument) version of 'set': open / edit / update / clear / set -- results in no visible change (the visible screen remains clear though I believe the RichTextArea document is in fact updated).

  4. With 'set' to the side: open / edit / update / and the open button again - reverts to the original version of document.

In any case, what I cannot do is create a document, save (perhaps to disk now with Serializable) reopen, edit, and expect it to save/open again.

FullFeaturedDemo.zip

@tonydroy tonydroy changed the title edit / update / reopen: problems edit / update / reopen May 7, 2024
@tonydroy
Copy link
Author

tonydroy commented May 27, 2024

In the version of RichTextArea available on 5/27/24 I no longer see the crash associated with option (2). Options (3) and (4) are the same.

@jperedadnr
Copy link
Collaborator

jperedadnr commented Jun 21, 2024

Please test again with the most recent 1.1.4-SNAPSHOT version.

If you still find exceptions, please post them, with clear steps of how to reproduce.

Ideally, provide a SSCCE simple class, for instance using a simple class like BasicDocumentDemo.

As for the use of RichTextArea::setDocument, you are right, it doesn't work if you call it twice.

But if you check its Javadoc:
https://github.com/gluonhq/rich-text-area/blob/main/rta/src/main/java/com/gluonhq/richtextarea/RichTextArea.java#L95

it wasn't intended to be used directly.

Most likely we need to make documentProperty readOnly, to enforce that (since this will be breaking API, it will need a major release though).

Edit: I've filed #341, and created a PR for it: #342

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

No branches or pull requests

2 participants