Skip to content

fix: prevent find widget from overlapping sticky scroll when editor is narrow#320290

Closed
Mr-Ahmadi wants to merge 1 commit into
microsoft:mainfrom
Mr-Ahmadi:fix/find-widget-sticky-scroll-overlap
Closed

fix: prevent find widget from overlapping sticky scroll when editor is narrow#320290
Mr-Ahmadi wants to merge 1 commit into
microsoft:mainfrom
Mr-Ahmadi:fix/find-widget-sticky-scroll-overlap

Conversation

@Mr-Ahmadi
Copy link
Copy Markdown

@Mr-Ahmadi Mr-Ahmadi commented Jun 7, 2026

The find widget uses OverlayWidgetPositionPreference.TOP_RIGHT_CORNER which always positions at top: 0 of the editor viewport. When sticky scroll is visible, it renders on top of the sticky scroll content due to the find widget's higher z-index (35 vs 4).

This is especially noticeable when the editor window is narrowed (e.g., split-screen layout), where the find widget can encroach and partially obscure the sticky scroll function names.

Closes

Fix

Listens to the sticky scroll controller for height changes and shifts the find widget down accordingly via margin-top:

  • Uses StickyScrollController.get() (the canonical VS Code pattern) instead of a magic string ID
  • When sticky scroll is visible: margin-top = stickyScrollHeight + 4px (4px is the base CSS margin, extracted as FIND_WIDGET_TOP_MARGIN)
  • When sticky scroll is hidden or disabled: inline style cleared, falls back to CSS margin-top: 4px
  • Re-queries the controller in _reveal() if unavailable at construction time (defensive, since it's registered AfterFirstRender)

Changes

  • FIND_WIDGET_TOP_MARGIN — named constant for the base CSS margin-top
  • _stickyScrollInitialized / _stickyScrollHeight — tracks setup state and current height
  • _initStickyScroll() — retrieves the controller via StickyScrollController.get(), subscribes to onDidChangeStickyScrollHeight, and records initial height
  • _updateStickyScrollOffset() — applies or clears the inline margin-top based on _stickyScrollHeight

Verification

  • Sticky scroll enabled + find widget open → widget positioned below sticky scroll
  • Sticky scroll height changes (e.g., multiline scope name) → widget follows dynamically
  • Sticky scroll hidden/disabled → normal position restored
  • Find widget visibility animation (CSS transform) unaffected
  • Sticky scroll controller not yet created → re-queried on _reveal()

Copilot AI review requested due to automatic review settings June 7, 2026 15:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds sticky scroll awareness to the editor Find widget so it can offset itself when sticky scroll is visible.

Changes:

  • Retrieve the sticky scroll controller contribution and track its height changes
  • Store sticky scroll height and apply a top offset to the Find widget DOM node
  • Refresh the offset when the widget is revealed

Comment on lines +246 to +253
const stickyScrollController = this._codeEditor.getContribution<IStickyScrollController>(StickyScrollController.ID);
if (stickyScrollController) {
this._stickyScrollHeight = stickyScrollController.stickyScrollWidgetHeight;
this._register(stickyScrollController.onDidChangeStickyScrollHeight(({ height }) => {
this._stickyScrollHeight = height;
this._updateStickyScrollOffset();
}));
}
Comment on lines +559 to +565
private _updateStickyScrollOffset(): void {
if (this._stickyScrollHeight > 0) {
this._domNode.style.marginTop = `${this._stickyScrollHeight + 4}px`;
} else {
this._domNode.style.marginTop = '';
}
}
import * as strings from '../../../../base/common/strings.js';
import './findWidget.css';
import { ICodeEditor, IOverlayWidget, IOverlayWidgetPosition, IViewZone, OverlayWidgetPositionPreference } from '../../../browser/editorBrowser.js';
import { IStickyScrollController, StickyScrollController } from '../../stickyScroll/browser/stickyScrollController.js';
@Mr-Ahmadi Mr-Ahmadi force-pushed the fix/find-widget-sticky-scroll-overlap branch from 3a70f94 to 587c58a Compare June 7, 2026 15:33
@Mr-Ahmadi
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@Mr-Ahmadi Mr-Ahmadi force-pushed the fix/find-widget-sticky-scroll-overlap branch from 587c58a to ae56928 Compare June 8, 2026 11:56
Mr-Ahmadi added a commit to Mr-Ahmadi/vscode that referenced this pull request Jun 8, 2026
…0290)

The find widget uses OverlayWidgetPositionPreference.TOP_RIGHT_CORNER
which positions it at top: 0 of the editor. When sticky scroll is
visible, the find widget renders on top of it due to a higher z-index
(35 vs 4).

Shifts the find widget down by the sticky scroll height via margin-top
when sticky scroll is present, preventing overlap.

Uses StickyScrollController.get() to retrieve the controller and
subscribes to onDidChangeStickyScrollHeight for dynamic updates.
Re-queries in _reveal() if the controller wasn't yet available at
construction time (registred AfterFirstRender).

Closes microsoft#316851
@Mr-Ahmadi
Copy link
Copy Markdown
Author

Updated the fix with improvements over the initial version:

  • Proper import: Uses StickyScrollController class import and StickyScrollController.get() (canonical VS Code pattern) instead of a magic string ID
  • No import type needed: The class is imported directly, consistent with how every other VS Code contribution references cross-contributions
  • Deduplicated logic: Extracted sticky scroll setup into _initStickyScroll() helper, called from both constructor and _reveal()
  • Cleaner state tracking: Uses _stickyScrollInitialized boolean flag instead of storing the entire controller reference, avoiding duplicate event registration on re-setup

…0290)

The find widget uses OverlayWidgetPositionPreference.TOP_RIGHT_CORNER
which positions it at top: 0 of the editor. When sticky scroll is
visible, the find widget renders on top of it due to a higher z-index
(35 vs 4).

Shifts the find widget down by the sticky scroll height via margin-top
when sticky scroll is present, preventing overlap.

Uses StickyScrollController.get() to retrieve the controller and
subscribes to onDidChangeStickyScrollHeight for dynamic updates.
Re-queries in _reveal() if the controller wasn't yet available at
construction time (registred AfterFirstRender).

Closes microsoft#316851
@Mr-Ahmadi Mr-Ahmadi force-pushed the fix/find-widget-sticky-scroll-overlap branch from ae56928 to 79f0210 Compare June 8, 2026 12:06
@Mr-Ahmadi
Copy link
Copy Markdown
Author

Closing this PR — pivoting to a different fix.

@Mr-Ahmadi Mr-Ahmadi closed this Jun 8, 2026
@Mr-Ahmadi Mr-Ahmadi deleted the fix/find-widget-sticky-scroll-overlap branch June 8, 2026 12:22
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.

3 participants