Skip to content

Commit b5071c4

Browse files
fix(web): find keeps a query typed before its panel's first frame
The search panel reports no matches one frame after opening. A query typed before that frame lost its highlights and stopped navigating. Ignore that first empty report once a search has found matches. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 4e5cee3 commit b5071c4

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

‎patches/@pierre%[email protected]‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,10 @@ index 140f94f..96fc774 100644
330330
if (item.type === "diff") return item.instance.updateCodeViewLayout(item.item.fileDiff, item.top, void 0, item.item.annotations ?? []);
331331
diff --git a/dist/components/CodeViewSearch.js b/dist/components/CodeViewSearch.js
332332
new file mode 100644
333-
index 0000000..2cc5c66
333+
index 0000000..63d9d12
334334
--- /dev/null
335335
+++ b/dist/components/CodeViewSearch.js
336-
@@ -0,0 +1,357 @@
336+
@@ -0,0 +1,364 @@
337337
+import { isPrimaryModifier } from "../editor/platform.js";
338338
+import { resolveFindAgainShortcut } from "../editor/command.js";
339339
+import { SearchPanelWidget } from "../editor/searchPanel.js";
@@ -413,6 +413,9 @@ index 0000000..2cc5c66
413413
+ // The widget runs its first search a frame after opening, so callbacks from a
414414
+ // panel that has since closed must not touch the current search.
415415
+ const isLive = () => this.#widget === widget;
416+
+ // Without a selection that first frame reports no matches; ignore it if a
417+
+ // query typed before then has already found some.
418+
+ let initializing = defaultQuery === "";
416419
+ const widget = new SearchPanelWidget({
417420
+ textDocument: { search: (params) => isLive() ? this.#search(params) : [] },
418421
+ containerElement: anchor,
@@ -427,7 +430,7 @@ index 0000000..2cc5c66
427430
+ onUpdate: (matches, options) => {
428431
+ if (!isLive()) return;
429432
+ if (matches.length === 0) {
430-
+ this.#setEntries([]);
433+
+ if (!initializing || this.#entries.length === 0) this.#setEntries([]);
431434
+ return;
432435
+ }
433436
+ if (options?.syncSelection === false) {
@@ -441,6 +444,10 @@ index 0000000..2cc5c66
441444
+ onClose: () => this.#teardown(true)
442445
+ });
443446
+ this.#widget = widget;
447+
+ // Runs after the widget's own first-frame callback, which was scheduled first.
448+
+ if (initializing) requestAnimationFrame(() => {
449+
+ initializing = false;
450+
+ });
444451
+ widget.focus();
445452
+ }
446453
+ close() {

‎pnpm-lock.yaml‎

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)