Skip to content
TypeScript

fix(web): keep wrapped split diffs from jumping while scrolling (#20022)

Julius Marminge4036e1859771
diff --git a/apps/web/src/components/diffs/StyledDiffCodeView.tsx b/apps/web/src/components/diffs/StyledDiffCodeView.tsx
index 9522f53b6d1..85344ebafb9 100644
--- a/apps/web/src/components/diffs/StyledDiffCodeView.tsx
+++ b/apps/web/src/components/diffs/StyledDiffCodeView.tsx
@@ -14,6 +14,13 @@ import { DiffWorkerPoolProvider } from "../DiffWorkerPoolProvider";
/** The app's diff stylesheet, shared by single-file renderers so their separators match. */
export const DIFF_VIEW_UNSAFE_CSS = `${DIFF_SURFACE_THEME_UNSAFE_CSS}
+/* A 1fr track's automatic minimum grows with the currently mounted lines. In split
+ wrap mode that shifts width between columns, rewraps rows and makes the virtualizer
+ repeatedly correct the scroll position. Keep both code columns at the same width. */
+[data-diff-type="split"][data-overflow="wrap"] {
+ --diffs-code-grid: var(--diffs-grid-number-column-width) minmax(0, 1fr);
+}
+
:is(
[data-line],
[data-line-annotation],