Highlightr icon indicating copy to clipboard operation
Highlightr copied to clipboard

CodeAttributedString manual rehighlight

Open matteobart opened this issue 5 years ago • 2 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

matteobart avatar Jul 15 '19 00:07 matteobart

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!

sirachlotz avatar Oct 01 '19 11:10 sirachlotz

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.

codeshif avatar Jun 26 '20 07:06 codeshif