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

Bug: Undo after deleting styled text causes throw of exception #815

Closed
gandalfas opened this issue May 11, 2019 · 3 comments
Closed

Bug: Undo after deleting styled text causes throw of exception #815

gandalfas opened this issue May 11, 2019 · 3 comments

Comments

@gandalfas
Copy link

Expected Behavior

If you delete a character from styled text, and then Undo, it should work without throwing an exception.

Actual Behavior

An exception is thrown, under these conditions:

  • The styled text must be on a line where there are two styles present, e.g. bold followed by italics.
  • And the deletion must occur on the second styled text.

Variations

  • if the Delete key + undo is done on the first styled text of that line, it works fine.
  • if the line is all bold or all italics, then Delete key + undo works fine on any word on the line.

Reproducible Demo

  • Run the demo program RichTextDemo (provided in your download area), so that stdout and stderr will appear (e.g., under an IDE)
  • Open sample.rtfx
  • go to line 3, the italicized line, copy the word 'Italicized' and paste it onto end of line 2, the bold line. now we have two different styles on the line.
  • click within 'Italicized' on line 2
  • hit the Delete key
  • hit Ctl-Z
  • at this point the exception is thrown:

Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: Unexpected change received.

Expected:
[RichTextChange{
position: 43
removed: Par[; StyledSegment(segment=left() style=true,12,Serif,0x000000ff)]
inserted: Par[; StyledSegment(segment=left(c) style=true,12,Serif,0x000000ff)]
}]

Received:
[RichTextChange{
position: 43
removed: Par[; StyledSegment(segment=left() style=true,12,Serif,0x000000ff)]
inserted: Par[; StyledSegment(segment=left(c) style=true,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)
    (rest of stack deleted)

Environment info:

  • RichTextFX Version: 0.10.0
  • Flowless 0.6.1
  • ReactFX 2.0-M5
  • UndoFX 2.1.0
  • WellBehavedFX 0.3.3
  • Operating System: Windows 10
  • Java version: 8u181

@Jugen
Copy link
Collaborator

Jugen commented May 13, 2019

@Kim4444 Thanks for reporting the bug and providing clear steps to reproduce.
I did some debugging and have found the problem to be here, so will submit a PR soon.

@gandalfas
Copy link
Author

@Jugen excellent news! thanks so much for your quick investigation!

@Jugen
Copy link
Collaborator

Jugen commented May 14, 2019

Fixed by PR #817

@Jugen Jugen closed this as completed May 14, 2019
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