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

[0.7-M5] Calling setParagraphStyle on an empty Paragraph [p.length() == 0] throws Exception #481

Closed
neilccbrown opened this issue Apr 6, 2017 · 3 comments
Labels

Comments

@neilccbrown
Copy link

With version 0.7M5, if I call setParagraphStyle, I get an exception saying that it's invalid to have a (rich text) change which doesn't add or remove text. This seems like a bug given that setParagraphStyle does exactly that, and in general it should be valid to have a rich text change which only changes styles. Stack trace:

java.lang.IllegalStateException: Cannot get the type of a change that neither inserts nor deletes anything.
	at org.fxmisc.richtext.model.TextChange.<init>(TextChange.java:31)
	at org.fxmisc.richtext.model.RichTextChange.<init>(RichTextChange.java:6)
	at org.fxmisc.richtext.model.ReadOnlyStyledDocument.lambda$null$7(ReadOnlyStyledDocument.java:274)
	at org.reactfx.util.Tuple2.map(Tuple2.java:31)
	at org.fxmisc.richtext.model.ReadOnlyStyledDocument.lambda$replace$8(ReadOnlyStyledDocument.java:271)
	at org.reactfx.util.Tuple2.map(Tuple2.java:31)
	at org.fxmisc.richtext.model.ReadOnlyStyledDocument.replace(ReadOnlyStyledDocument.java:270)
	at org.fxmisc.richtext.model.ReadOnlyStyledDocument.replaceParagraph(ReadOnlyStyledDocument.java:285)
	at org.fxmisc.richtext.model.GenericEditableStyledDocumentBase.setParagraphStyle(GenericEditableStyledDocumentBase.java:179)
	at org.fxmisc.richtext.model.SimpleEditableStyledDocument.setParagraphStyle(SimpleEditableStyledDocument.java:7)
@alt-grr
Copy link

alt-grr commented Apr 6, 2017

Another regression introduced in #458?

@JordanMartinez
Copy link
Contributor

:-/ Yup, I forgot about the possibility of a style change

This is another issue that would have been found had I tested the code using the rich text demo before merging it into master. However, that just shows that we need to have more automated tests that test the basic functionality of these methods.

@JordanMartinez
Copy link
Contributor

This regression only appears if the paragraph does not have any text on it whatsoever.

@JordanMartinez JordanMartinez changed the title setParagraphStyle throws exception [0.7-M5] Calling setParagraphStyle on an empty Paragraph [p.length() == 0] throws Exception Apr 7, 2017
benedictleejh added a commit to narrativeandplay/hypedyn2 that referenced this issue Apr 15, 2017
RichTextFX 0.7-M5 seems to complain if we try to set the style of a 0
length piece of text (might be related to FXMisc/RichTextFX#481).

This is a temp fix until a possible new version that fixes this issue
Bytekeeper pushed a commit to SimpleTimeTracking/StandaloneClient that referenced this issue May 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants