fix(render): map author spans to landedText coords (INV-49/50 coloring alignment) (#64)
renderReview diffs against landedText (current minus pending proposals), so block offsets are landedText-relative while authorSpans arrive in currentText coords. A colored block after a length-changing pending proposal was mis-colored. Map the spans through toLanded so authorship coloring stays aligned. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -392,6 +392,26 @@ describe("renderReview", () => {
|
||||
// the applied paragraph is NOT also emitted as a word-merged changed block
|
||||
expect(html).not.toContain("<del>brown</del>"); // no double-render of the change as a baseline diff
|
||||
});
|
||||
|
||||
test("renderReview keeps author coloring aligned on a block AFTER a length-changing pending proposal (INV-49/50)", () => {
|
||||
// block 1 has a pending proposal whose applied text is MUCH LONGER than its
|
||||
// original; block 2 carries a Claude authorship span (in currentText coords).
|
||||
const baseline = "one short.\n\ntwo stable here.\n";
|
||||
const current = "one MUCH LONGER REPLACED TEXT.\n\ntwo stable here.\n";
|
||||
const proposals: ProposalView[] = [{
|
||||
id: "pr_1",
|
||||
anchorStart: current.indexOf("one MUCH LONGER REPLACED TEXT."),
|
||||
anchorEnd: current.indexOf("one MUCH LONGER REPLACED TEXT.") + "one MUCH LONGER REPLACED TEXT.".length,
|
||||
replaced: "one short.",
|
||||
replacement: "one MUCH LONGER REPLACED TEXT.",
|
||||
original: "one short.",
|
||||
}];
|
||||
const sStart = current.indexOf("stable");
|
||||
const authorSpans = [{ start: sStart, end: sStart + "stable".length, author: "claude" as const }];
|
||||
const html = renderReview(baseline, current, authorSpans, proposals);
|
||||
// the Claude coloring wraps "stable" exactly — not shifted by the proposal's length delta.
|
||||
expect(html).toMatch(/<span class="cw-by-claude">stable<\/span>/);
|
||||
});
|
||||
});
|
||||
|
||||
import { renderTrackChanges as rtc2 } from "../src/trackChangesModel";
|
||||
|
||||
Reference in New Issue
Block a user