perf: bound diff label projection during caret scrolling

The label lag came from repeatedly projecting full viewports while walking backwards from the caret. Skip only candidates whose maximum possible source/wrap and label height cannot reach the target, then retain the original first-target search. Reuse already resolved scope contexts. The conservative bound preserves non-monotonic unified declaration visibility and independent sticky labels. Added regressions for split declaration-visibility ties and unified height changes; architecture updated. Verification: 10,176 differential projections matched; all 964 release tests pass; release binary built. Reduced repro p95: 3.9572ms -> 1.4467ms. Live 160x100 function-dense 360-key burst median catch-up: 22.895ms -> 9.611ms, with final cursor/viewport asserted. Full and no-dependency Clippy checks are blocked by existing repository warnings, including vendored Crossterm, blame, LSP, Markdown, syntax and existing TUI code. Temporary harnesses removed. No remote changes.
This commit is contained in:
Valdemar Lorenzen
2026-10-16 09:26:05 +02:00
parent 1df9e66cd5
commit 60a12110fa
3 changed files with 133 additions and 16 deletions
+1 -1
View File
@@ -105,7 +105,7 @@ Each buffer has a frontend-owned parser/tree cache. Unchanged revision/path skip
Diff highlighting lazily owns two instances of the same syntax cache, keyed by the accepted comparison request ID and selected file. Before detects language from the old path when renamed; After uses the new path. Scrolling, focus changes, and explorer toggling reuse parsed spans without copying/reparsing snapshots. A fresh comparison identity prevents stale Working-checkout colors even when labels and paths are unchanged. Closing the view releases snapshot caches. Syntax styles patch foreground/modifiers over diff backgrounds; historical panes never receive live-buffer semantic tokens.
Scope context is a lazily built row index over the existing primary/injected syntax trees, invalidated by source or grammar changes and warmed by diff updates. Ordinary buffer highlighting does not build it. The frontend's visual-row projection inserts inline/sticky scope labels in wrapped and unwrapped diffs; source alignment and excerpt ranges contain no label rows. Coloring, native selection/caret overlays, and source navigation skip these presentation rows. Before/After labels use their independent trees rather than live-workspace symbol analysis.
Cached scope metadata records the declaration identifier's source point separately from its extent, including decorated definitions. The projection checks that point against each pane's actual source rows and column/wrap ranges, suppressing redundant labels and refilling reclaimed rows. Caret anchoring uses the resulting visual rows rather than a fixed label-height estimate.
Cached scope metadata records the declaration identifier's source point separately from its extent, including decorated definitions. The projection checks that point against each pane's actual source rows and column/wrap ranges, suppressing redundant labels and refilling reclaimed rows. Caret anchoring skips source/wrap positions only while their maximum possible label height cannot reach the target, then projects the remaining candidates. This retains the first matching anchor even when declaration visibility changes label height non-monotonically.
## Clipboard providers