-
Notifications
You must be signed in to change notification settings - Fork 236
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
Move UndoManager into EditableStyledDocument so that one UndoManager … #251
Move UndoManager into EditableStyledDocument so that one UndoManager … #251
Conversation
…is shared across multiple clones. Clones can be disposed without affecting access to the UndoManager.
…ditableStyledDocument now holding `preserveStyle`.
Hmm.... looks like we have another instance of IllegalArgumentException appearing from #216 through this approach... |
Stracktrace: 11:25:24.979 [DEBUG] [TestEventLogger] org.fxmisc.richtext.StyledTextAreaModelTest > insureCloneUndoRedoWorks FAILED
11:25:24.980 [DEBUG] [TestEventLogger] java.lang.IllegalArgumentException: Unexpected change received.
11:25:24.980 [DEBUG] [TestEventLogger] Expected:
11:25:24.981 [DEBUG] [TestEventLogger] RichTextChange{
11:25:24.981 [DEBUG] [TestEventLogger] position: 0
11:25:24.981 [DEBUG] [TestEventLogger] removed: Par["":]
11:25:24.981 [DEBUG] [TestEventLogger] inserted: Par["A really short text example.":-fx-font-size: 30px;]
11:25:24.981 [DEBUG] [TestEventLogger] }
11:25:24.981 [DEBUG] [TestEventLogger] Received:
11:25:24.982 [DEBUG] [TestEventLogger] RichTextChange{
11:25:24.982 [DEBUG] [TestEventLogger] position: 0
11:25:24.982 [DEBUG] [TestEventLogger] removed: Par["":-fx-font-size: 30px;]
11:25:24.982 [DEBUG] [TestEventLogger] inserted: Par["A really short text example.":-fx-font-size: 30px;]
11:25:24.982 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: SUCCEEDED
11:25:24.982 [DEBUG] [TestEventLogger] }
11:25:24.983 [DEBUG] [TestEventLogger] at org.fxmisc.undo.impl.UndoManagerImpl.changeObserved(UndoManagerImpl.java:185)
11:25:24.983 [DEBUG] [TestEventLogger] at org.reactfx.util.NonAccumulativeStreamNotifications.lambda$head$278(NotificationAccumulator.java:134)
11:25:24.983 [DEBUG] [TestEventLogger] at org.reactfx.ObservableBase.notifyObservers(ObservableBase.java:68)
11:25:24.983 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Process 'Gradle Test Executor 1' finished with exit value 0 (state: SUCCEEDED)
11:25:24.983 [DEBUG] [TestEventLogger] at org.reactfx.ObservableBase.notifyObservers(ObservableBase.java:57)
11:25:24.984 [DEBUG] [TestEventLogger] at org.reactfx.ProperEventStream.emit(ProperEventStream.java:18)
11:25:24.984 [DEBUG] [TestEventLogger] at org.reactfx.MappedStream.lambda$observeInputs$207(MappedStream.java:25)
11:25:24.984 [DEBUG] [TestEventLogger] at org.reactfx.util.NonAccumulativeStreamNotifications.lambda$head$278(NotificationAccumulator.java:134)
11:25:24.984 [DEBUG] [TestEventLogger] at org.reactfx.ObservableBase.notifyObservers(ObservableBase.java:68)
11:25:24.984 [DEBUG] [TestEventLogger] at org.reactfx.ObservableBase.notifyObservers(ObservableBase.java:57)
11:25:24.984 [DEBUG] [TestEventLogger] at org.reactfx.ProperEventStream.emit(ProperEventStream.java:18)
11:25:24.984 [DEBUG] [TestEventLogger] at org.reactfx.FilterStream.lambda$observeInputs$194(FilterStream.java:20) |
I guess this is another instance of the bug you mentioned in #247: a re-done text (via insertion) will inherit the deleted text's style. |
I did some debugging and now see that org.fxmisc.richtext.StyledTextAreaModelTest > insureCloneUndoRedoWorks STANDARD_OUT
// insert styled text into area
Emtting Doc from RichChanges: RichTextChange{
position: 0
removed: Par["":]
inserted: Par["A really short text example.":-fx-font-size: 30px;]
}
Calling area::undo
Applying change: RichTextChange{
position: 0
removed: Par["A really short text example.":-fx-font-size: 30px;]
inserted: Par["":]
}
Emtting Doc from RichChanges: RichTextChange{
position: 0
removed: Par["A really short text example.":-fx-font-size: 30px;]
inserted: Par["":]
}
Calling area::redo
Applying change: RichTextChange{
position: 0
removed: Par["":]
inserted: Par["A really short text example.":-fx-font-size: 30px;]
}
Emtting Doc from RichChanges: RichTextChange{
position: 0
// `StyledDocumentBase#subsequence()` picks up the deleted text's style
removed: Par["":-fx-font-size: 30px;]
inserted: Par["A really short text example.":-fx-font-size: 30px;]
}
Gradle Test Executor 1 finished executing tests.
org.fxmisc.richtext.StyledTextAreaModelTest > insureCloneUndoRedoWorks FAILED
java.lang.IllegalArgumentException: Unexpected change received.
Expected:
RichTextChange{
position: 0
removed: Par["":]
inserted: Par["A really short text example.":-fx-font-size: 30px;]
}
Received:
RichTextChange{
position: 0
removed: Par["":-fx-font-size: 30px;]
inserted: Par["A really short text example.":-fx-font-size: 30px;]
} One way around this would be to have a different |
…redos inheriting deleted text styles and thus throwing a IllegalArgumentException when UndoFX checks the received RichChange from the Expected one. - Also moved the code body that actually replaces the content of EditableStyledDocument into its own method `replaceContent` to prevent code duplication between `replace()` and `replaceRichUndoRedo()`.
…ke code easier to read
…ichTextChange that only changes the style of a text and not the text itself doesn't emit a plain text change.
In light of Tomas' recent comment in the related issue:
I'm closing this PR as it doesn't address this issue as well as another approach could. |
…is shared across multiple clones. Clones can be disposed without affecting access to the UndoManager.
See comments in #233