fix(diff): keep file headers synchronized while scrolling (#4240)

The fixed header overlay repainted after compositor-driven scroll, so ordinary headers visibly lagged behind the diff body. Paint in-flow headers with the scrolling canvas and reserve a bounded sticky canvas pool for push-off behavior.
This commit is contained in:
Mohamed Boudra
2026-09-02 22:54:38 +02:00
committed by GitHub
parent a835136854
commit ce07732d62
8 changed files with 303 additions and 186 deletions
@@ -1,9 +1,5 @@
import { describe, expect, it } from "vitest";
import {
diffHeaderViewportKey,
diffInteractionWindowTop,
resolveVisibleFileSections,
} from "./header-layout";
import { diffInteractionWindowTop, resolveVisibleFileSections } from "./header-layout";
import type { DiffFileSection } from "./types";
describe("diff header viewport", () => {
@@ -48,15 +44,6 @@ describe("diff header viewport", () => {
?.y,
).toBe(0);
});
it("reuses a fixed sticky header until its visible layout changes", () => {
const files = [section(0, 0, 4_000, false), section(1, 4_000, 4_030, true)];
const keyAt = (scrollTop: number) =>
diffHeaderViewportKey({ files, scrollTop, viewportHeight: 600, activePath: null });
expect(keyAt(100)).toBe(keyAt(2_000));
expect(keyAt(3_985)).not.toBe(keyAt(2_000));
});
});
describe("diff interaction window", () => {