Skip to content

Orchestrate reading editor bounding boxes across editor renderings#290543

Merged
alexdima merged 1 commit intomainfrom
alexd/yucky-whippet
Jan 26, 2026
Merged

Orchestrate reading editor bounding boxes across editor renderings#290543
alexdima merged 1 commit intomainfrom
alexd/yucky-whippet

Conversation

@alexdima
Copy link
Copy Markdown
Member

Fixes #290537

Copilot AI review requested due to automatic review settings January 26, 2026 20:55
@alexdima alexdima enabled auto-merge (squash) January 26, 2026 20:55
@alexdima alexdima self-assigned this Jan 26, 2026
@vs-code-engineering vs-code-engineering bot added this to the January 2026 milestone Jan 26, 2026
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

This PR refactors the editor rendering pipeline to introduce a coordinated pre-render phase where view parts can read layout-related information (like DOM bounding boxes) before any editor instance mutates the DOM, reducing redundant synchronous layouts across multiple editors. It leverages a new onBeforeRender hook on ViewPart and updates the native edit context to cache container bounds ahead of rendering selection and character bounds.

Changes:

  • Introduced a ViewPart.onBeforeRender(viewportData) lifecycle hook and wired the View to call it for all view parts that need to render, before any text rendering occurs.
  • Updated the coordinated rendering flow (ICoordinatedRendering, EditorRenderingCoordinator, and View._flushAccumulatedAndRenderNow) to compute and pass a shared ViewportData object explicitly between the pre-render and render phases.
  • Modified NativeEditContext and content widgets to use onBeforeRender to cache editor container bounds and to avoid per-render getBoundingClientRect() calls that previously caused multiple synchronous layouts when many rich answers/code blocks are present.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts Marks ViewContentWidgets.onBeforeRender as an override and forwards the new ViewportData to all content widgets so they can participate in the pre-render phase.
src/vs/editor/browser/view/viewPart.ts Adds the ViewportData import and defines a default no-op onBeforeRender(viewportData) hook on ViewPart as the new pre-render extension point.
src/vs/editor/browser/view.ts Refactors the render pipeline to return ViewportData from prepareRenderText, pass it into renderText, invoke onBeforeRender on view parts before text rendering, and updates ICoordinatedRendering / EditorRenderingCoordinator to orchestrate pre-render and render across multiple editors using this shared viewport data.
src/vs/editor/browser/controller/editContext/native/nativeEditContext.ts Adds a cached _parentBounds updated in onBeforeRender, removes the onDidRender-based post-pass, and switches selection/control and character bounds calculations to use the cached bounds to avoid extra layout flushes while keeping them aligned with the current viewport.

@alexdima alexdima merged commit c83bf1d into main Jan 26, 2026
27 of 28 checks passed
@alexdima alexdima deleted the alexd/yucky-whippet branch January 26, 2026 21:27
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Mar 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_updateSelectionAndControlBoundsAfterRender is not orchestrated across editors

3 participants