Editor rendering: add per-line visual cache with document-change invalidation#54
Closed
Copilot wants to merge 3 commits into
Closed
Editor rendering: add per-line visual cache with document-change invalidation#54Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
Agent-Logs-Url: https://github.com/gui-cs/Text/sessions/36b131c3-a566-4e84-af27-716f740c4686 Co-authored-by: tig <585482+tig@users.noreply.github.com>
Agent-Logs-Url: https://github.com/gui-cs/Text/sessions/36b131c3-a566-4e84-af27-716f740c4686 Co-authored-by: tig <585482+tig@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add visual-line cache and invalidation for rendering
Editor rendering: add per-line visual cache with document-change invalidation
May 11, 2026
tig
added a commit
that referenced
this pull request
May 11, 2026
Cherry-picked the cache-the-draw-path idea from PR #54. Adds a second narrow cache (_drawVisualLineCache) keyed by DocumentLine.LineNumber that the draw path consults via GetOrBuildDrawVisualLine when: - no syntax-highlighter segments - no selection - no LineTransformers It's kept separate from _defaultVisualLineCache so the caret/mouse path (Attribute.Default) and the draw path (editor role attributes) don't overwrite each other on alternating reads. Both caches share the same invalidation logic: ranged drop from first affected line down on OnDocumentChanged, wholesale clear on Document swap / IndentationSize / ShowTabs change. What this helps: - A consumer that doesn't enable syntax highlighting now reuses cached visual lines across consecutive frames during static scrolling, instead of rebuilding every visible line each frame. What it doesn't help: - ted, because TedApp sets a TextMateSyntaxHighlighter; segments is always non-null and the eligibility predicate falls through. That's fine — the same predicate gracefully degrades, and the cache will light up automatically once syntax-colorizer (#28/#32) replaces the per-frame segments computation with a transformer. Tests added (EditorVisualLineCacheTests.DrawCache nested class): - Repeated draw with same attributes returns same instance - Different attributes bypass cache - Selection bypasses cache - Document edit drops affected line from draw cache CI perf gate unchanged: VisualLineBuild_Short ratio 1.00× pre vs. post-cherry-pick (5.331 → 5.356 µs on local Windows). The bench doesn't go through Editor.BuildVisualLine, so this commit has no effect on the gated metric — it's a feature-gain commit, not a perf fix for the existing gate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Editor.BuildVisualLinewas rebuilding visual lines for every visible row on every frame, driving high allocation churn during navigation/scroll. This change adds a per-line cache and selective invalidation so unchanged lines are reused and only affected lines are rebuilt.What this PR changes
Editorkeyed byDocumentLine.CellVisualLineinstances on cache-eligible build paths (no selection/styled segments/transformers).Document.Changed(covers insert/remove/replace and downstream line-number shifts).Document,SyntaxHighlighter,SyntaxLanguage,IndentationSize,ShowTabs).Safety/consistency details
DocumentLineaccess).Tests added
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
www.jetbrains.com/usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/.nuget/packages/jetbrains.resharper.globaltools/2025.2.4/tools/netcoreapp3.1/any/cleanupcode.unix.runtimeconfig.json /home/REDACTED/.nuget/packages/jetbrains.resharper.globaltools/2025.2.4/tools/netcoreapp3.1/any/cleanupcode.exe Terminal.Gui.Text.slnx --profile=Full Cleanup(dns block)/usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/.nuget/packages/jetbrains.resharper.globaltools/2025.2.4/tools/netcoreapp3.1/any/cleanupcode.unix.runtimeconfig.json /home/REDACTED/.nuget/packages/jetbrains.resharper.globaltools/2025.2.4/tools/netcoreapp3.1/any/cleanupcode.exe Terminal.Gui.Text.slnx --profile=Built-in: Full Cleanup _TOKEN"; }; f(dns block)If you need me to access, download, or install something from one of these locations, you can either: