Skip to content

[performance] Preserve useful highlight checkpoints across distant jumps #130

Description

@owainlewis

Goal

Keep syntax-context work bounded when a user alternates between distant locations in a large file.

Evidence

At exact main 1d6d60189e4b350649f591a858746368de78064c, WindowedHighlightCache::push_checkpoint in src/highlighter.rs retains only checkpoints before the new line and then removes old nonzero checkpoints beyond the recent cap. After warming a deep viewport, a sufficiently large backward jump can rescan from line 0 and delete the useful later checkpoints. Jumping forward again repeats depth-proportional work.

Original review thread: #119 (comment)

Acceptance criteria

  • Alternating among distant warmed viewports performs work bounded independently of file depth after bounded warm-up.
  • The checkpoint set has a deterministic memory cap and preserves strategically useful context on both sides of a jump.
  • Edits invalidate only checkpoints whose syntax context may be stale.
  • Rust comments and strings plus Markdown fences retain correct context.

Checks

  • Add a deterministic regression that alternates between locations farther apart than the current recent-checkpoint window and asserts scanned lines and request bytes stay bounded.
  • Cover an edit between the distant locations.
  • Run focused highlighter tests and opt-in highlighting performance checks.
  • Run cargo fmt --check, cargo test --all-targets, strict Clippy, and an all-target build.

Scope

Keep the fix inside the bounded checkpoint/window design. Do not add background parsing or a new parser framework.

Metadata

Metadata

Assignees

No one assigned

    Labels

    factory-readyClear, focused, unblocked work an agent may implementqualityTests, performance, refactors, CI, or internal code health

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions