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

Exception while using a spans builder to set styles #505

Closed
grigoriliev opened this issue May 12, 2017 · 4 comments
Closed

Exception while using a spans builder to set styles #505

grigoriliev opened this issue May 12, 2017 · 4 comments

Comments

@grigoriliev
Copy link
Contributor

Consider the following test case:

 @Test
    public void testSetStylesUsingSpansBuilder() {
        String style1 = "style1";
        String style2 = "style2";
    	CodeArea document = new CodeArea();
    	document.replaceText(0, 0, "a\n\nb");
    	document.setStyle(0, 4, Collections.singleton(style1));
        StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
        spansBuilder.add(Collections.singleton(style2), 1);
        spansBuilder.add(Collections.emptyList(), 1);
        spansBuilder.add(Collections.singleton(style2), 2);
        document.setStyleSpans(0, spansBuilder.create());
    }

I got the following exception:

java.lang.IllegalArgumentException: Cannot construct a Paragraph with an empty list of segments
	at org.fxmisc.richtext.model.Paragraph.<init>(Paragraph.java:67)
	at org.fxmisc.richtext.model.Paragraph.restyle(Paragraph.java:249)
	at org.fxmisc.richtext.model.GenericEditableStyledDocumentBase.lambda$5(GenericEditableStyledDocumentBase.java:160)
	at org.fxmisc.richtext.model.ReadOnlyStyledDocument.lambda$10(ReadOnlyStyledDocument.java:272)
	at org.reactfx.util.Tuple2.map(Tuple2.java:31)
	at org.fxmisc.richtext.model.ReadOnlyStyledDocument.lambda$7(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.replace(ReadOnlyStyledDocument.java:260)
	at org.fxmisc.richtext.model.GenericEditableStyledDocumentBase.setStyleSpans(GenericEditableStyledDocumentBase.java:154)
	at org.fxmisc.richtext.model.SimpleEditableStyledDocument.setStyleSpans(SimpleEditableStyledDocument.java:1)
	at org.fxmisc.richtext.GenericStyledArea.setStyleSpans(GenericStyledArea.java:1282)

I wasn't getting this exception with version 0.7-M3.

@JordanMartinez
Copy link
Contributor

Is this another case of #481?

@JordanMartinez
Copy link
Contributor

I mean #345?

@JordanMartinez
Copy link
Contributor

I just tested this with 0.7-M3 and your test fails in that version, too.

@JordanMartinez
Copy link
Contributor

Closed by #509

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

No branches or pull requests

2 participants