feat: native diff surface — QuickDiff + cowriting-baseline: provider + Review Changes + status bar (spec §6.4, INV-13)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,10 +16,14 @@ suite("baseline router (PUC-1, INV-7/D13/D14)", () => {
|
||||
assert.strictEqual(api.diffViewController.modeOf(doc.uri.toString()), "snapshot");
|
||||
assert.strictEqual(api.diffViewController.getBaseline(doc.uri.toString())?.text, "one\n");
|
||||
await ed.edit((b) => b.insert(new vscode.Position(1, 0), "two\n"));
|
||||
// Task 3 (INV-13): the status-bar/SCM change count tracks the live edit.
|
||||
await settleUntil(() => api.scmSurfaceController.changeCount(doc.uri.toString()) === 1);
|
||||
await vscode.commands.executeCommand("cowriting.markReviewed");
|
||||
const b = api.diffViewController.getBaseline(doc.uri.toString());
|
||||
assert.strictEqual(b?.text, "one\ntwo\n");
|
||||
assert.strictEqual(b?.reason, "pinned");
|
||||
// A pin re-baselines to the clean current text, so the change count resets.
|
||||
await settleUntil(() => api.scmSurfaceController.changeCount(doc.uri.toString()) === 0);
|
||||
});
|
||||
|
||||
test("head mode: baseline = HEAD; commit advances it", async function () {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as assert from "node:assert";
|
||||
import * as vscode from "vscode";
|
||||
import { activateApi, settle } from "./helpers";
|
||||
|
||||
async function api() {
|
||||
const ext = vscode.extensions.getExtension("benstull.vscode-cowriting-plugin")!;
|
||||
@@ -17,4 +18,18 @@ suite("coediting registry (PUC-7)", () => {
|
||||
await vscode.commands.executeCommand("cowriting.stopCoediting");
|
||||
assert.strictEqual(coeditingRegistry.isCoediting(doc.uri), false);
|
||||
});
|
||||
|
||||
// Task 3 (INV-10): a document that was never entered into coediting gets no
|
||||
// native-diff surface at all. QuickDiff's `provideOriginalResource` isn't
|
||||
// directly queryable from a host-E2E test, so this asserts the gate INPUTS
|
||||
// structurally: `isCoediting` stays false and the SCM change count — which
|
||||
// `ScmSurfaceController` only ever populates for a coediting doc — stays 0.
|
||||
test("non-entered doc: no coediting, no change count (structural, INV-10)", async () => {
|
||||
const api = await activateApi();
|
||||
const doc = await vscode.workspace.openTextDocument({ language: "markdown", content: "untouched\n" });
|
||||
await vscode.window.showTextDocument(doc);
|
||||
await settle();
|
||||
assert.strictEqual(api.coeditingRegistry.isCoediting(doc.uri), false);
|
||||
assert.strictEqual(api.scmSurfaceController.changeCount(doc.uri.toString()), 0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, test, expect } from "vitest";
|
||||
import MarkdownIt from "markdown-it";
|
||||
import { splitBlocks, splitBlocksWithRanges, diffBlocks, diffToHunks, diffToBlockHunks, renderTrackChanges, colorByAuthor, authorAt, wordDiffByAuthor, type AuthorSpan } from "../src/trackChangesModel";
|
||||
import { splitBlocks, splitBlocksWithRanges, diffBlocks, diffToHunks, diffToBlockHunks, renderTrackChanges, colorByAuthor, authorAt, wordDiffByAuthor, countLineHunks, type AuthorSpan } from "../src/trackChangesModel";
|
||||
const md = new MarkdownIt({ html: true, linkify: false, breaks: false });
|
||||
|
||||
describe("splitBlocks", () => {
|
||||
@@ -825,3 +825,19 @@ describe("F11 data-src emission (INV-36)", () => {
|
||||
expect(renderReview(doc, doc, [], [])).not.toContain('href="https://example.com/spec"');
|
||||
});
|
||||
});
|
||||
|
||||
describe("countLineHunks", () => {
|
||||
it("0 for identical text", () => {
|
||||
expect(countLineHunks("a\nb\n", "a\nb\n")).toBe(0);
|
||||
});
|
||||
it("1 for one contiguous change", () => {
|
||||
expect(countLineHunks("a\nb\nc\n", "a\nX\nc\n")).toBe(1);
|
||||
});
|
||||
it("2 for two separated changes", () => {
|
||||
expect(countLineHunks("a\nb\nc\nd\ne\n", "a\nX\nc\nd\nY\n")).toBe(2);
|
||||
});
|
||||
it("counts pure insertions and deletions", () => {
|
||||
expect(countLineHunks("a\n", "a\nb\n")).toBe(1);
|
||||
expect(countLineHunks("a\nb\n", "a\n")).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user