I'm updating some code that uses a syntax editor to display formatted text (hl7). In some cases, this text can be quite large (5 - 10MB) and the bulk of it can be on a single line (think base64/rtf etc). When displaying something like this, the syntax editor is very slow calculating the wrapping. It makes sense to collapse these large blocks of text as they really don't add anything useful to the end user.
I have used the advanced collapsing sample to collapse these blocks of text *after* the text has rendered, but I have not been able to get things working pre-text-render. In my old code I was manually stripping out these large blocks before handing the text to the syntax editor, and then behind the scenes keeping a collection of tags. While this works, it requires a lot back and forth between the original and collapsed text (for other taggers / highlighters etc).
Is there some way of getting the collapsing working pre-render (and so without the performance penalty)?