Skip to content

Preserve Find match scrolling when closing the widget - #350820

Open
smolpupperino wants to merge 2 commits into
microsoft:mainfrom
smolpupperino:fix/find-scroll-on-close-215722
Open

smolpupperino wants to merge 2 commits into
microsoft:mainfrom
smolpupperino:fix/find-scroll-on-close-215722

Conversation

@smolpupperino

Copy link
Copy Markdown

Fixes #215722.

When editor.action.nextMatchFindAction starts a smooth scroll and closeFindWidget immediately removes the Find widget's top view zone, setting the scroll position cancels the animation. Skip that adjustment while a scroll animation is pending so the selected match can come into view. Keep the existing scroll adjustment when the viewport is stationary.

Added a browser regression test that opens Find, advances to an off-screen match, closes Find, and checks that the match is visible after scrolling. The test fails on the unchanged widget. With the fix, all 83 Find browser tests pass in Chromium, and both changed files pass oxlint.

Prepared with Codex assistance.

Copilot AI balanced review requested due to automatic review settings November 28, 2026 04:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

With Replace expanded in a short editor, the pending scroll still includes the removed top zone’s offset, which can leave the selected match above the viewport.

1 open issue
What changed in this PR

Addresses #215722 by preventing Find widget closure from cancelling an in-progress scroll to the selected match.

Changes:

  • Skips the top view-zone scroll adjustment while an animation is pending, retaining stationary behavior.
  • Adds a browser regression test that navigates to an off-screen match, closes Find, and checks visibility after scrolling.
File Description
src/​vs/​editor/​contrib/​find/​test/​browser/​findController.test.ts Adds a regression test using a real editor view.
src/​vs/​editor/​contrib/​find/​browser/​findWidget.ts Guards the scroll adjustment during view-zone removal.

Review effort: Balanced

Comment on lines +733 to +734
if (!this._codeEditor.hasPendingScrollAnimation()) {
this._codeEditor.setScrollTop(this._codeEditor.getScrollTop() - this._viewZone.heightInPx);
@smolpupperino

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@smolpupperino

Copy link
Copy Markdown
Author

Fixed in b5bffcb. Closing Find now compensates both the current scroll position and the pending destination for the removed zone. The new short-editor test uses an interior match with Replace expanded. It fails with the previous implementation, and all 29 Find controller tests pass in Chromium with the fix.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

editor.action.nextMatchFindAction won't scroll to target when followed by closeFindWidget

2 participants