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

Unexpected change when undoing a paragraph copy with a preceding paragraph style #904

Closed
cengels opened this issue Feb 28, 2020 · 1 comment · Fixed by #908
Closed

Unexpected change when undoing a paragraph copy with a preceding paragraph style #904

cengels opened this issue Feb 28, 2020 · 1 comment · Fixed by #908
Labels

Comments

@cengels
Copy link

cengels commented Feb 28, 2020

Expected Behavior

After copying a newline operator that directly follows a line of text that is completely styled, there should not be an exception when undoing that copy & paste.

Actual Behavior

The following exception appears:

Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: Unexpected change received.
Expected:
[RichTextChange{
	position: 59
	removed: Par[; StyledSegment(segment=left() style=true,12,Serif,0x000000ff)]
Par[; StyledSegment(segment=left(this is the copied line) style=12,Serif,0x000000ff)]
	inserted: Par[; StyledSegment(segment=left() style=12,Serif,0x000000ff)]
}]
Received:
[RichTextChange{
	position: 59
	removed: Par[; StyledSegment(segment=left() style=12,Serif,0x000000ff)]
Par[; StyledSegment(segment=left(this is the copied line) style=12,Serif,0x000000ff)]
	inserted: Par[; StyledSegment(segment=left() style=12,Serif,0x000000ff)]
}]
	at org.fxmisc.undo.impl.UndoManagerImpl.changeObserved(UndoManagerImpl.java:234)
	at org.reactfx.util.QueuingStreamNotifications.lambda$head$0(NotificationAccumulator.java:217)
	at org.reactfx.ObservableBase.notifyObservers(ObservableBase.java:68)
	at org.reactfx.SuspendableBase.resume(SuspendableBase.java:64)
	at org.reactfx.CloseableOnceGuard.close(Guard.java:49)
	at org.reactfx.MultiGuard.close(Guard.java:83)
        ...

After this exception, all input to the text area is broken. It is not even possible anymore to move the caret.

Steps To Reproduce

  1. Run the RichTextDemo example
  2. Add two lines
  3. The first line should be styled in its entirety
  4. The second line's styling seems to be irrelevant (based on my testing)
  5. Copy the second line along with the preceding newline (so that the selection looks like this:
    image
  6. Paste the clipboard contents after the second line
  7. Hit CTRL + Z to undo

Let me know if I was unclear in some step. I was able to consistently reproduce this in both my own repository and the RichTextDemo. As far as I can see, #903 is unrelated to this issue, though I could be wrong about that.

@Jugen
Copy link
Collaborator

Jugen commented Mar 2, 2020

It appears that this bug was introduced way back in v0.8.0 with PR #565 to resolve issue #554.
Reverting that change resolves the case outlined above, unfortunately there's no test case for 565 .... ?

Will continue to look into it and try to develop test cases ..... but the undo manager's merge changes timeout is a problem in accomplishing that.

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

Successfully merging a pull request may close this issue.

2 participants