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

CodeArea.getStyleSpans(from, to).append(...) does not append #191

Closed
jmak35 opened this issue Oct 15, 2015 · 2 comments
Closed

CodeArea.getStyleSpans(from, to).append(...) does not append #191

jmak35 opened this issue Oct 15, 2015 · 2 comments

Comments

@jmak35
Copy link

jmak35 commented Oct 15, 2015

Hi Tomas,

I'm getting an issue with using the above method like so:

StyleSpans<Collection<String>> styleSpans = codeArea.getStyleSpans(startIndex, startIndex + text.length());

StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
spansBuilder.add(Collections.singleton("class1"), text.length());
spansBuilder.add(Collections.singleton("class2"), text.length());

spansBuilder.create().forEach(styleSpans::append);

After this code executes, styleSpans still has a length of 0. If it was unmodifiable I'd assume it would've thrown an exception, but I believe that is not the case.

Is there anything I'm doing wrong?

Thank you.

@jmak35 jmak35 changed the title getStyleSpans(to, from).append(...) does not append CodeArea.getStyleSpans(to, from).append(...) does not append Oct 15, 2015
@jmak35 jmak35 changed the title CodeArea.getStyleSpans(to, from).append(...) does not append CodeArea.getStyleSpans(from, to).append(...) does not append Oct 15, 2015
@TomasMikula
Copy link
Member

Hi, StyleSpans is indeed unmodifiable. append returns a new instance. The original one remains intact.

Anyway, if styleSpans has length 0, that would mean that text.length() is 0.

@TomasMikula
Copy link
Member

Closing this as this is not an issue.

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