feat: Task 7 — decorateCommitted fills committed author-colored changes in the editor (reverses INV-32)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -250,6 +250,29 @@ describe("wordDiffByAuthor", () => {
|
||||
|
||||
import { renderPlain } from "../src/trackChangesModel";
|
||||
|
||||
import { wordEditHunks, decorationPlan } from "../src/trackChangesModel";
|
||||
|
||||
test("committed change: wordEditHunks(current, baseline) → start/end index current; replacement is baseline text", () => {
|
||||
const baseline = "the light mode";
|
||||
const current = "the dark mode";
|
||||
const [h] = wordEditHunks(current, baseline);
|
||||
expect(current.slice(h.start, h.end)).toContain("dark"); // applied (current) side
|
||||
expect(h.replacement).toContain("light"); // baseline (deleted) side
|
||||
const plan = decorationPlan(h.start, h.replacement, current.slice(h.start, h.end));
|
||||
expect(plan.insertions.length).toBeGreaterThan(0);
|
||||
expect(plan.deletions.some((d) => d.text.includes("light"))).toBe(true);
|
||||
});
|
||||
|
||||
test("committed change with NO shared prefix: current offsets + deleted text both correct", () => {
|
||||
const baseline = "alpha tail";
|
||||
const current = "beta tail";
|
||||
const [h] = wordEditHunks(current, baseline);
|
||||
expect(h.start).toBe(0);
|
||||
expect(current.slice(h.start, h.end)).toContain("beta"); // applied
|
||||
const plan = decorationPlan(h.start, h.replacement, current.slice(h.start, h.end));
|
||||
expect(plan.deletions.some((d) => d.text.includes("alpha"))).toBe(true); // deletion not lost
|
||||
});
|
||||
|
||||
describe("renderPlain", () => {
|
||||
test("renderPlain renders current buffer as plain markdown (no marks)", () => {
|
||||
const html = renderPlain("# Title\n\nhello");
|
||||
|
||||
Reference in New Issue
Block a user