fix(app): stabilize canvas diff rendering

Keep diff headers and painted content on the same scroll clock while preserving native scrolling and independent per-file horizontal offsets.

Complete review, selection, typography, tree, and palette parity without returning line rendering to React.
This commit is contained in:
Mohamed Boudra
2026-08-17 21:14:38 +02:00
parent 4d23905587
commit c7b103a2cd
50 changed files with 2180 additions and 580 deletions
@@ -1,28 +1,17 @@
import { hitTestDiffDocument } from "./hit-testing";
import type { DiffDocumentModel, DiffHit } from "./types";
import type { DiffDocumentModel, DiffFileSection, DiffHit } from "./types";
export interface SurfaceWindowOrigin {
x: number;
y: number;
}
export function hitTestDiffPagePoint(input: {
export function hitTestDiffBodyPoint(input: {
model: DiffDocumentModel;
pageX: number;
pageY: number;
surfaceOrigin: SurfaceWindowOrigin;
scrollTop: number;
horizontalOffsetForPath: (path: string) => number;
file: DiffFileSection;
locationX: number;
locationY: number;
horizontalOffset: number;
}): DiffHit | null {
const x = input.pageX - input.surfaceOrigin.x;
const documentY = input.pageY - input.surfaceOrigin.y + input.scrollTop;
const file = input.model.files.find(
(entry) => entry.top <= documentY && documentY < entry.bottom,
);
return hitTestDiffDocument({
model: input.model,
x,
documentY,
horizontalOffset: file ? input.horizontalOffsetForPath(file.path) : 0,
x: input.locationX,
documentY: input.file.bodyTop + input.locationY,
horizontalOffset: input.horizontalOffset,
});
}