Browser: better focus transfering (#298819)

* Browser: better focus transfering

* fix
This commit is contained in:
Kyle Cutler
2026-03-02 16:23:19 -08:00
committed by GitHub
parent 122e527a81
commit 1da6f72eba
3 changed files with 15 additions and 9 deletions

View File

@@ -169,8 +169,8 @@ export class BrowserViewMainService extends Disposable implements IBrowserViewMa
// Request the workbench to open the editor
this.windowsMainService.sendToFocused('vscode:runAction', {
id: 'vscode.open',
args: [BrowserViewUri.forUrl(url, targetId)]
id: '_workbench.open',
args: [BrowserViewUri.forUrl(url, targetId), [undefined, { preserveFocus: true }], undefined]
});
return view;

View File

@@ -391,7 +391,8 @@ export class BrowserEditor extends EditorPane {
this._inputDisposables.clear();
// Resolve the browser view model from the input
this._model = await input.resolve();
const model = await input.resolve();
this._model = model;
if (token.isCancellationRequested || this.input !== input) {
return;
}
@@ -425,12 +426,16 @@ export class BrowserEditor extends EditorPane {
});
this.setBackgroundImage(this._model.screenshot);
if (context.newInGroup) {
if (this._model.url) {
this._browserContainer.focus();
} else {
this.focusUrlInput();
}
if (!options?.preserveFocus) {
setTimeout(() => {
if (this._model === model) {
if (this._model.url) {
this._browserContainer.focus();
} else {
this.focusUrlInput();
}
}
}, 0);
}
// Start / stop screenshots when the model visibility changes

View File

@@ -105,6 +105,7 @@ export class BrowserFindWidget extends SimpleFindWidget {
// Stop find and clear highlights in the browser view
this._model?.stopFindInPage(true);
this._model?.focus();
this._lastFindResult = undefined;
this._hasFoundMatch = false;
}