fix(highlighter): preserve bounded syntax context - #144
Conversation
|
@codex review |
|
Merged-main verification complete. Merge commit: Post-merge CI: https://github.com/owainlewis/cortex/actions/runs/30405444201
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0e9ad92937
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
docs/issues/130-131-plan.md.Why
The existing checkpoint insertion discarded every later checkpoint during a backward jump, so alternating between distant locations repeatedly rescanned file-depth prefixes. The Markdown checkpoint scanner also missed fences nested under
>containers, causing deep injected Rust context loss. After #124, overflow fallback bypassed truncated-line barriers and could keep visible code styled as a comment.These fixes stay inside the bounded checkpoint/window design. They retain only deterministic window anchors, carry the minimal quote-depth context needed by the scanner, and split conservative overflow at the same boundaries used by normal context recovery.
Test plan
Verified on exact base
b3ef75d0ea74b5a13e022a34699396fb878e03edand headb0040dbe104d6e0d60af0e97ccbba47c007a4a95:cargo test highlighter::tests:: -- --nocapture: 44 passed.cargo test performance:: -- --ignored --nocapture --test-threads=1: all 4 passed; deep highlighting completed in 2.381s initially and 22.473ms after edit.cargo fmt --check.git diff --checkand staged diff validation.cargo test --all-targets: 308 passed, 4 documented performance tests ignored, and all 5 signal cleanup tests passed.cargo clippy --all-targets --all-features -- -D warnings.cargo build --all-targets.C-x C-c, and reused the restored shell (CORTEX_SHELL_OK).improveworkflow to clarify checkpoint and overflow-boundary invariants without changing behavior.b3ef75dwith no findings.Risks
The Markdown checkpoint scanner intentionally supports block-quote containers without becoming a complete CommonMark parser. A quoted fence requires its block-quote container on opener, contents, and closer. Losing that container ends the bounded fence context.
Rust block-comment nesting above 64 levels remains conservative by design. Normal Rust resumes at a truncated-line barrier. Fenced Markdown also resumes at its real closer, a truncated-line barrier, or loss of the required quote container.
Checkpoint memory remains capped at line zero plus eight recent anchors. An edit retains checkpoints at or before its first changed line and invalidates later contexts that may be stale.
Related issue
Closes #130
Closes #131
Closes #142