raspu / Highlightr

iOS & OSX Syntax Highlighter.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CodeAttributedString manual rehighlight

matteobart opened this issue · comments

It would be nice if there would be a way to manually trigger a rehighlight from the auto-highlight feature (CodeAttributedString). Essentially, on top of the highlighting, I am using a yellow highlighter to display certain text (like a Find feature). However, the only way to remove this highlighting is when a user start typing, so that it re-highlights the text.

If anyone knows a simple work around that would be great.
Calling processEditing causes an error because no edits were actually made
I tried to reset the theme (setting it to itself), but to no luck

Possible workaround:
textStorage.invalidateAttributes(in: NSMakeRange(0, textStorage.length))
where textStorage is your CodeAttributedString.

You can obviously change the range for increased performance.
Hope that helps!

Possible workaround:
textStorage.invalidateAttributes(in: NSMakeRange(0, textStorage.length))
where textStorage is your CodeAttributedString.

You can obviously change the range for increased performance.
Hope that helps!

Cannot work.