fix(highlighter): reseed fenced Markdown segments - #148
Conversation
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Merged-main verification complete. Merge commit: Main CI: https://github.com/owainlewis/cortex/actions/runs/30407212734
|
Summary
docs/issues/146-plan.md.Why
PR #144 retained Markdown fence context after a truncated line, but each post-barrier parser segment still started as a standalone Markdown document. Without a synthetic fence opener, visible Rust after the oversized line lost injected-language highlighting until a later window rebuild.
This change keeps the existing segmentation and checkpoint design. It gives each already-bounded segment the context Tree-sitter needs, then advances the same compact lexical state used by checkpoints before parsing the next segment.
Test plan
Verified on exact base
90f2823ded43d102650a8bce1e80e652fdb3740fand head0ee87bb797539acef0dcb8afe56ea417d7d9db14:cargo test highlighter::tests:: -- --nocapture: 46 passed.cargo test performance:: -- --ignored --nocapture --test-threads=1: all 4 passed; deep highlighting completed in 1.281s initially and 25.104ms after edit.cargo test --all-targets: 317 unit tests passed, 4 documented performance tests ignored and run separately, and all 5 signal cleanup tests passed.cargo fmt --check.git diff --check origin/main...HEAD.cargo clippy --all-targets --all-features -- -D warnings.cargo build --all-targets.improveworkflow to clarify the segment-barrier invariant and preserve behavior.Risks
The fix deliberately does not remove or relax truncated-line barriers. Each existing parser segment receives only the bounded synthetic wrapper for its retained context, and parser call count remains one per segment. Window lines, per-line source prefixes, checkpoints, scanned work, and the #124 exact Rust wrapper cap keep their existing limits.
Real fence closers are scanned and parsed inside their segment, so following Markdown resumes on the next line. Block-quoted fences keep the retained quote depth. The separate #124 overflow branches and #142 overflow recovery policy are unchanged.
Related issue
Closes #146