Cap rendering and editing of extremely long lines - #607
Open
ollieb-unity wants to merge 1 commit into
Open
Conversation
A single very long line (e.g. a minified blob or a Unity YAML asset with an inline binary payload serialized as hex) froze the UI thread as it scrolled into view: TextMate tokenized and colorized the whole line, and TextFormatter shaped every character. - VisualLine shapes only the first LENGTH_LIMIT characters and collapses the remainder into a short "..." marker (a FormattedTextElement, the same mechanism used for collapsed fold regions). Document offsets are unchanged, so caret, selection and highlighting keep working. - TextMateColoringTransformer skips tokenizing/colorizing lines past LENGTH_LIMIT. - New LongLineEditProtection disallows edits inside the collapsed tail, and TextArea routes CanInsert/GetDeletableSegments through it so callers cannot insert into or delete the hidden region (deleting the delimiter would merge the next line into the hidden text). Co-authored-by: Daniel Penalba <daniel.penalba@unity3d.com>
danipen
self-requested a review
August 7, 2026 11:17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A single very long line — e.g. a minified blob, or a Unity YAML asset with an inline binary payload serialized as hex — freezes the UI thread as it scrolls into view. Two full-line passes run synchronously: TextMate tokenizes and colorizes the whole line, and
TextFormattershapes every character.Change
VisualLineshapes only the firstLENGTH_LIMITcharacters and collapses the remainder into a short...marker via aFormattedTextElement— the same mechanism already used for collapsed fold regions. Document offsets are unchanged, so caret, selection and highlighting keep working.TextMateColoringTransformerskips tokenizing/colorizing lines pastLENGTH_LIMIT.LongLineEditProtectiondisallows edits inside the collapsed tail;TextArearoutesCanInsert/GetDeletableSegmentsthrough it so callers cannot insert into or delete the hidden region (deleting the line delimiter would otherwise merge the next line into the hidden text).This builds on the existing
VisualLine.LENGTH_LIMIT(3000) short-circuit, which previously still added a single full-lengthVisualLineTextfor over-limit lines.Builds cleanly against
net8.0andnet10.0.