mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-24 18:22:38 +00:00
* perf(app): virtualize large diff rendering Render bounded diff row groups through one vertical list and one horizontal surface. Bound retained list ranges when expansion grows the data set so large diffs paint promptly without sacrificing scrolling behavior. * refactor(app): normalize working tree diff options * fix(app): keep wide diff text reachable
52 lines
1.9 KiB
TypeScript
52 lines
1.9 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
compactHighlightTokens,
|
|
formatDiffContentText,
|
|
formatDiffGutterText,
|
|
hasVisibleDiffTokens,
|
|
} from "./diff-rendering";
|
|
|
|
describe("diff-rendering", () => {
|
|
it("keeps header gutters tall even when they do not show a line number", () => {
|
|
// Must be a non-collapsing whitespace: the gutter <Text> uses
|
|
// numberOfLines={1}, which on web wraps in display:-webkit-box;
|
|
// overflow:hidden. A plain ASCII space collapses to zero height
|
|
// there and shifts every line number up by one row.
|
|
expect(formatDiffGutterText(null)).toBe("\u00A0");
|
|
expect(formatDiffGutterText(82)).toBe("82");
|
|
});
|
|
|
|
it("keeps empty split cells tall even when they have no visible content", () => {
|
|
expect(formatDiffContentText(undefined)).toBe(" ");
|
|
expect(formatDiffContentText("")).toBe(" ");
|
|
expect(formatDiffContentText("const value = 1;")).toBe("const value = 1;");
|
|
});
|
|
|
|
it("treats empty highlighted token rows as blank lines instead of visible content", () => {
|
|
expect(hasVisibleDiffTokens(undefined)).toBe(false);
|
|
expect(hasVisibleDiffTokens([])).toBe(false);
|
|
expect(hasVisibleDiffTokens([{ text: "" }])).toBe(false);
|
|
expect(hasVisibleDiffTokens([{ text: "const value = 1;" }])).toBe(true);
|
|
});
|
|
|
|
it("compacts adjacent syntax tokens without changing their text or styles", () => {
|
|
expect(
|
|
compactHighlightTokens([
|
|
{ text: "const", style: "keyword" },
|
|
{ text: " ", style: null },
|
|
{ text: "value", style: null },
|
|
{ text: " ", style: null },
|
|
{ text: "=", style: "operator" },
|
|
{ text: "", style: "operator" },
|
|
{ text: " 1", style: "number" },
|
|
]),
|
|
).toEqual([
|
|
{ text: "const", style: "keyword" },
|
|
{ text: " value ", style: null },
|
|
{ text: "=", style: "operator" },
|
|
{ text: " 1", style: "number" },
|
|
]);
|
|
});
|
|
});
|