@devries-cameron20 / t3code-1 / commits / aa725f4bd4
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): file find scrolls to matches below wrapped lines (#39616)

Julius Marminge committed Nov 20, 2026 at 01:32 UTC aa725f4bd422c8649a6160ed97bad05ffeaf3ed2
3 files changed +113 -16
apps/web/src/components/files/FilePreviewPanel.browser.test.tsx
+52
@@ -365,6 +365,58 @@ describe("source file scroll", () => {
365
366 await vi.waitFor(() => expect(scroller()?.scrollTop).toBe(4200));
367 });
368 +
369 + it("scrolls a find match below many wrapped lines into view", async () => {
370 + using _settings = setup();
371 + const style = document.createElement("style");
372 + style.textContent = appCss;
373 + document.head.append(style);
374 + using _style = { [Symbol.dispose]: () => style.remove() };
375 + await preloadHighlighter({ themes: Object.values(DEFAULT_THEMES), langs: ["typescript"] });
376 + const wrapped = "wrap ".repeat(60);
377 + const lines = Array.from({ length: 800 }, (_, i) => `const line${i} = "${wrapped}";`);
378 + lines.push(
379 + "const needle = 1;",
380 + ...Array.from({ length: 40 }, (_, i) => `const tail${i} = ${i};`),
381 + );
382 + const contents = lines.join("\n");
383 + state.file = {
384 + relativePath: "wrapped.ts",
385 + contents,
386 + byteLength: contents.length,
387 + truncated: false,
388 + };
389 + const scroller = () => document.querySelector<HTMLElement>(".file-preview-virtualizer");
390 +
391 + await using _screen = await render(
392 + <div style={{ width: 500, height: 400, display: "flex", flexDirection: "column" }}>
393 + {filePreview("wrapped.ts")}
394 + </div>,
395 + );
396 + await vi.waitFor(() => expect(scroller()?.scrollHeight).toBeGreaterThan(20_000));
397 + const shadowRows = () =>
398 + [...document.querySelectorAll("*")].flatMap((host) =>
399 + host.shadowRoot ? [...host.shadowRoot.querySelectorAll<HTMLElement>("[data-line]")] : [],
400 + );
401 + await userEvent.click(shadowRows().find((row) => row.getAttribute("data-line") === "1")!);
402 + await vi.waitFor(() => expect(deepActiveElement()?.matches("[data-content]")).toBe(true));
403 + await userEvent.keyboard(
404 + isMacPlatform(navigator.platform) ? "{Meta>}f{/Meta}" : "{Control>}f{/Control}",
405 + );
406 + await vi.waitFor(() => expect(deepActiveElement()).toBeInstanceOf(HTMLInputElement));
407 + await userEvent.keyboard("needle{Enter}");
408 +
409 + const visibleLines = () => {
410 + const viewport = scroller()!.getBoundingClientRect();
411 + return shadowRows()
412 + .filter((row) => {
413 + const box = row.getBoundingClientRect();
414 + return box.height > 0 && box.top >= viewport.top && box.bottom <= viewport.bottom;
415 + })
416 + .map((row) => Number(row.getAttribute("data-line")));
417 + };
418 + await vi.waitFor(() => expect(visibleLines()).toContain(801));
419 + });
420 });
421
422 describe("rendered Markdown task saves", () => {
patches/@pierre__diffs@1.7.0-beta.4.patch
+56 -11
@@ -1,16 +1,25 @@
1 diff --git a/dist/editor/editor.js b/dist/editor/editor.js
2 -index b4c280390b52434f63fbe7916d81b150d9006fb4..cb7fb89a22c8adac9ea951b8767b5fd446347746 100644
2 +index b4c280390b52434f63fbe7916d81b150d9006fb4..ae0e8e6f9e0473a152b921a50a8c7833cb466a03 100644
3 --- a/dist/editor/editor.js
4 +++ b/dist/editor/editor.js
5 -@@ -95,6 +95,7 @@ var Editor = class {
5 +@@ -95,6 +95,8 @@ var Editor = class {
6 #deletionsColumn;
7 #overlayElement;
8 #overlayElements;
9 + #fontProbeElement;
10 ++ #lineReveal;
11 #caretElements;
12 #caretHighlightElements;
13 #primaryCaretElement;
13 -@@ -584,6 +585,7 @@ var Editor = class {
14 +@@ -536,6 +538,7 @@ var Editor = class {
15 + const fileInstance = this.#fileInstance;
16 + const recycle = reason === "recycle";
17 + this.#virtualizedInstance?.cancelScroll(this.#handleCaretRevealDone);
18 ++ this.#virtualizedInstance?.cancelScroll(this.#handleLineRevealDone);
19 + this.#cancelEditPrediction(true, false);
20 + if (!recycle) this.#editPredictionHistory = [];
21 + const editSession = this.#editSession;
22 +@@ -584,6 +587,7 @@ var Editor = class {
23 this.#contentHasFocus = false;
24 this.#overlayElement?.remove();
25 this.#overlayElement = void 0;
@@ -18,7 +27,7 @@ index b4c280390b52434f63fbe7916d81b150d9006fb4..cb7fb89a22c8adac9ea951b8767b5fd4
27 this.#resizeObserver?.disconnect();
28 this.#resizeObserver = void 0;
29 this.#fontRemeasureScheduled = false;
21 -@@ -1022,6 +1024,19 @@ var Editor = class {
30 +@@ -1022,6 +1026,19 @@ var Editor = class {
31 this.#tokenizer?.applyStyle();
32 this.#spriteElement = createSpriteElement();
33 this.#overlayElement = h("div", { dataset: "editorOverlay" });
@@ -38,7 +47,7 @@ index b4c280390b52434f63fbe7916d81b150d9006fb4..cb7fb89a22c8adac9ea951b8767b5fd4
47 const replacementFocusTargetIsContent = (event) => {
48 const target = event.composedPath()[0];
49 return target instanceof Node && this.#contentElement?.contains(target) === true;
41 -@@ -1130,6 +1145,7 @@ var Editor = class {
50 +@@ -1130,6 +1147,7 @@ var Editor = class {
51 this.#editorEventDisposes = [
52 addEventListener(contentEl, "focus", () => {
53 this.#contentHasFocus = true;
@@ -46,7 +55,7 @@ index b4c280390b52434f63fbe7916d81b150d9006fb4..cb7fb89a22c8adac9ea951b8767b5fd4
55 onFocus?.();
56 if (!this.#isContentMouseDown && !this.#isComposing && this.#focusRequest == null && this.#selections !== void 0 && this.#selections.length > 0) this.#setWindowSelection(this.#selections.at(-1));
57 }, { passive: true }),
49 -@@ -1397,6 +1413,7 @@ var Editor = class {
58 +@@ -1397,6 +1415,7 @@ var Editor = class {
59 this.#resizeObserver = new ResizeObserver(this.#handleLayoutResize);
60 this.#resizeObserver.observe(contentEl);
61 this.#resizeObserver.observe(contentEl.parentElement);
@@ -54,7 +63,7 @@ index b4c280390b52434f63fbe7916d81b150d9006fb4..cb7fb89a22c8adac9ea951b8767b5fd4
63 this.#computeContentOffset(contentEl);
64 }
65 #handleCustomPasteEvent = async () => {
57 -@@ -1852,7 +1869,9 @@ var Editor = class {
66 +@@ -1852,7 +1871,9 @@ var Editor = class {
67 const change = textDocument.applyEdits(edits, true, selections, nextSelections, true);
68 if (change !== void 0) this.#applyChange(change, nextSelections);
69 }
@@ -65,7 +74,7 @@ index b4c280390b52434f63fbe7916d81b150d9006fb4..cb7fb89a22c8adac9ea951b8767b5fd4
74 const lineAnnotations = this.#lineAnnotations?.length ?? 0;
75 const prevGutterWidth = this.#gutterWidthCache;
76 const prevContentWidth = this.#contentWidthCache;
68 -@@ -1860,12 +1879,12 @@ var Editor = class {
77 +@@ -1860,12 +1881,12 @@ var Editor = class {
78 this.#contentWidthCache = void 0;
79 const gutterWidthChanged = this.#getGutterWidth() !== prevGutterWidth;
80 const contentWidthChanged = this.#getContentWidth() !== prevContentWidth;
@@ -81,8 +90,44 @@ index b4c280390b52434f63fbe7916d81b150d9006fb4..cb7fb89a22c8adac9ea951b8767b5fd4
90 }
91 if (this.#selections !== void 0 || this.#matches !== void 0 || this.#markerRenderer !== void 0) {
92 this.#updateSelections(this.#selections ?? []);
84 -@@ -3369,7 +3388,8 @@ var Editor = class {
85 - });
93 +@@ -2123,6 +2144,16 @@ var Editor = class {
94 + this.#scrollCaretIntoView(line, character, "nearest");
95 + }
96 + };
97 ++ #handleLineRevealDone = (result) => {
98 ++ const target = this.#lineReveal;
99 ++ if (result !== "settled" || target === void 0) return;
100 ++ this.#lineReveal = void 0;
101 ++ const { line, char, noFocus } = target;
102 ++ if (this.#scrollCaretIntoView(line, char, "center") && !noFocus) this.#focusAt({
103 ++ line,
104 ++ character: char
105 ++ });
106 ++ };
107 + #focusAt(position) {
108 + if (this.#focusRequest?.restore != null) this.#restoreReplacementFocus(position);
109 + else this.#focus(position);
110 +@@ -2145,6 +2176,19 @@ var Editor = class {
111 + this.#scrollingToLineNoFocus = false;
112 + return;
113 + }
114 ++ // The host knows wrapped row heights; a line-height estimate stops short of wrapped content.
115 ++ const host = this.#virtualizedInstance;
116 ++ if (host !== void 0) {
117 ++ this.#scrollingToLine = void 0;
118 ++ this.#scrollingToLineFixed = false;
119 ++ this.#lineReveal = {
120 ++ line,
121 ++ char,
122 ++ noFocus
123 ++ };
124 ++ host.scrollToLine(line + 1, "center", this.#handleLineRevealDone);
125 ++ return;
126 ++ }
127 + let yFix = 0;
128 + if (this.#scrollingToLine === line && this.#contentElement !== void 0) for (let i = this.#contentElement.childElementCount - 1; i >= 0; i--) {
129 + const child = this.#contentElement.children[i];
130 +@@ -3370,6 +3414,7 @@ var Editor = class {
131 this.#searchPanel = searchPanel;
132 this.#retainSearchPanelFocus = false;
133 searchPanel.mount();
@@ -135,7 +180,7 @@ index 96d4fb137ea683b66381b1ce6e47e8708a89366c..13f2564897a5bf53a8f311300003b3ea
180 /**
181 * Re-measure the '0' character width against the font that is loaded right
182 diff --git a/dist/utils/parsePatchFiles.js b/dist/utils/parsePatchFiles.js
138 -index 48568bd..f27123f 100644
183 +index 48568bd6f669ba4826de17ba03caad466e1f0000..f27123f7c812c728ee8393792665ba288141771c 100644
184 --- a/dist/utils/parsePatchFiles.js
185 +++ b/dist/utils/parsePatchFiles.js
186 @@ -339,7 +339,7 @@ function parsePatchFiles(data, options = {}) {
pnpm-lock.yaml
+5 -5
@@ -371,7 +371,7 @@ patchedDependencies:
371 '@expo/ui@58.0.27': 9f2547678939f4ec78fe45163b6455aad63d3c80353d7e0cc783f6a61a7ccc2f
372 '@ff-labs/fff-node@0.11.0': 93f62a76399b435a76588b2bef237db0a1e85880c1ac0d0759c416e9cc579252
373 '@muse-code/sdk@1.4.6': 7b495b607fc5d76b444c7c4d58821e839726a30e6f3c53564f0d59f2d5b42101
374 - '@pierre/diffs@1.7.0-beta.4': b24b206d14c79de95be10322b96490b82e41cc13c8a02c7378aaf8e03623431b
374 + '@pierre/diffs@1.7.0-beta.4': b5d99ba050d8ccce3bd4018c2c21b7be2be3cb9bcc0d1f5ca76c481a9240b8c7
375 '@react-native-ai/apple@0.12.0': 2d09870c2848d185cb05b53ed823a46e12dba519324d8dd8e584e28731990f9d
376 '@react-native-menu/menu@2.0.0': 6872ba71b9847c5a0210b1b896923dadc3860faedfe28d9f062bcedfe786ef1d
377 '@react-navigation/native-stack@7.21.0': 990d575444c4af2ce8218b3b7a8280fe244c03abbdb32b822a2e862f791dbf42
@@ -581,7 +581,7 @@ importers:
581 version: 0.3.0
582 '@pierre/diffs':
583 specifier: 1.7.0-beta.4
584 - version: 1.7.0-beta.4(patch_hash=b24b206d14c79de95be10322b96490b82e41cc13c8a02c7378aaf8e03623431b)(@shikijs/themes@4.2.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)
584 + version: 1.7.0-beta.4(patch_hash=b5d99ba050d8ccce3bd4018c2c21b7be2be3cb9bcc0d1f5ca76c481a9240b8c7)(@shikijs/themes@4.2.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)
585 '@pierre/highlights':
586 specifier: 'catalog:'
587 version: 0.5.0
@@ -1105,7 +1105,7 @@ importers:
1105 version: 1.8.0
1106 '@pierre/diffs':
1107 specifier: 1.7.0-beta.4
1108 - version: 1.7.0-beta.4(patch_hash=b24b206d14c79de95be10322b96490b82e41cc13c8a02c7378aaf8e03623431b)(@shikijs/themes@4.2.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)
1108 + version: 1.7.0-beta.4(patch_hash=b5d99ba050d8ccce3bd4018c2c21b7be2be3cb9bcc0d1f5ca76c481a9240b8c7)(@shikijs/themes@4.2.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)
1109 '@pierre/trees':
1110 specifier: 1.0.0-beta.6
1111 version: 1.0.0-beta.6(@pierre/theme@2.0.0)(@shikijs/themes@4.2.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)(shiki@4.2.0)
@@ -1521,7 +1521,7 @@ importers:
1521 dependencies:
1522 '@pierre/diffs':
1523 specifier: 1.7.0-beta.4
1524 - version: 1.7.0-beta.4(patch_hash=b24b206d14c79de95be10322b96490b82e41cc13c8a02c7378aaf8e03623431b)(@shikijs/themes@4.2.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)
1524 + version: 1.7.0-beta.4(patch_hash=b5d99ba050d8ccce3bd4018c2c21b7be2be3cb9bcc0d1f5ca76c481a9240b8c7)(@shikijs/themes@4.2.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)
1525 '@t3tools/contracts':
1526 specifier: workspace:*
1527 version: link:../contracts
@@ -16497,7 +16497,7 @@ snapshots:
16497 tslib: 2.8.1
16498 webcrypto-core: 1.9.2
16499
16500 - '@pierre/diffs@1.7.0-beta.4(patch_hash=b24b206d14c79de95be10322b96490b82e41cc13c8a02c7378aaf8e03623431b)(@shikijs/themes@4.2.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)':
16500 + '@pierre/diffs@1.7.0-beta.4(patch_hash=b5d99ba050d8ccce3bd4018c2c21b7be2be3cb9bcc0d1f5ca76c481a9240b8c7)(@shikijs/themes@4.2.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)':
16501 dependencies:
16502 '@pierre/highlights': 0.5.1
16503 '@pierre/patches': 0.0.1