Integrated Browser: Fix buggy Right Click -> Copy into New Window#288207
Merged
Integrated Browser: Fix buggy Right Click -> Copy into New Window#288207
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request adds support for copying integrated browser editors into new windows. The main change is implementing the copy() method in BrowserEditorInput to create independent browser view instances with new unique IDs. Additionally, the PR refactors the view initialization logic in BrowserEditor to use a ResizeObserver for handling window layout changes, replacing the previous scheduleAtNextAnimationFrame approach.
Changes:
- Implemented
copy()method inBrowserEditorInputto create new browser instances with unique IDs when copying to new windows - Replaced animation frame scheduling with
ResizeObserverfor more reliable layout handling during window moves/resizes - Added
layoutAsync()helper method to ensure proper view attachment before operations
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/vs/workbench/contrib/browserView/electron-browser/browserEditorInput.ts | Added copy() method to create independent browser editor instances with new UUIDs and injected IInstantiationService |
| src/vs/workbench/contrib/browserView/electron-browser/browserEditor.ts | Refactored initialization to use ResizeObserver for layout handling and added layoutAsync() method; removed unused scheduleAtNextAnimationFrame import |
Comments suppressed due to low confidence (1)
src/vs/workbench/contrib/browserView/electron-browser/browserEditor.ts:725
- The
layout()andlayoutAsync()methods contain duplicated logic for calculating and passing layout parameters. Consider refactoring to extract the common layout logic into a shared helper method that both methods can call, with only the async/await handling differing between them.
override layout(): void {
void this.layoutAsync();
}
/**
* Async version of layout that waits for the layout to complete.
*/
private async layoutAsync(): Promise<void> {
if (this._model) {
this.checkOverlays();
const containerRect = this._browserContainer.getBoundingClientRect();
await this._model.layout({
windowId: this.group.windowId,
x: containerRect.left,
y: containerRect.top,
width: containerRect.width,
height: containerRect.height,
zoomFactor: getZoomFactor(this.window)
});
}
}
override clearInput(): void {
this._inputDisposables.clear();
// Cancel any active element selection
if (this._elementSelectionCts) {
this._elementSelectionCts.dispose(true);
this._elementSelectionCts = undefined;
}
void this._model?.setVisible(false);
this._model = undefined;
this._canGoBackContext.reset();
kycutler
reviewed
Jan 16, 2026
kycutler
approved these changes
Jan 20, 2026
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 #284525
(Copy into New Window was very buggy. Not to be confused with Move into New Window, which has been working fine.)
This PR does the following:
Related feature: #286579