Orchestrate reading editor bounding boxes across editor renderings#290543
Merged
Orchestrate reading editor bounding boxes across editor renderings#290543
Conversation
Tyriar
approved these changes
Jan 26, 2026
Contributor
There was a problem hiding this comment.
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 theViewto call it for all view parts that need to render, before any text rendering occurs. - Updated the coordinated rendering flow (
ICoordinatedRendering,EditorRenderingCoordinator, andView._flushAccumulatedAndRenderNow) to compute and pass a sharedViewportDataobject explicitly between the pre-render and render phases. - Modified
NativeEditContextand content widgets to useonBeforeRenderto cache editor container bounds and to avoid per-rendergetBoundingClientRect()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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #290537