Skip to content

Commit 9bea23b

Browse files
Linskeydmjbvz
andauthored
Fix webviews stealing focus when not last focused (microsoft#98847)
Fixes microsoft#61489 Co-authored-by: Matt Bierner <matb@microsoft.com>
1 parent b2c8b2a commit 9bea23b

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/vs/workbench/contrib/webview/browser/webviewEditor.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { WebviewInput } from 'vs/workbench/contrib/webview/browser/webviewEditor
1919
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
2020
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
2121
import { IHostService } from 'vs/workbench/services/host/browser/host';
22+
import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/browser/layoutService';
2223

2324
export class WebviewEditor extends BaseEditor {
2425

@@ -39,6 +40,8 @@ export class WebviewEditor extends BaseEditor {
3940
@IThemeService themeService: IThemeService,
4041
@IStorageService storageService: IStorageService,
4142
@IEditorService private readonly _editorService: IEditorService,
43+
@IWorkbenchLayoutService private readonly _workbenchLayoutService: IWorkbenchLayoutService,
44+
@IEditorGroupsService private readonly _editorGroupsService: IEditorGroupsService,
4245
@IEditorDropService private readonly _editorDropService: IEditorDropService,
4346
@IHostService private readonly _hostService: IHostService,
4447
) {
@@ -76,7 +79,7 @@ export class WebviewEditor extends BaseEditor {
7679
if (!this._onFocusWindowHandler.value && !isWeb) {
7780
// Make sure we restore focus when switching back to a VS Code window
7881
this._onFocusWindowHandler.value = this._hostService.onDidChangeFocus(focused => {
79-
if (focused && this._editorService.activeEditorPane === this) {
82+
if (focused && this._editorService.activeEditorPane === this && this._workbenchLayoutService.hasFocus(Parts.EDITOR_PART)) {
8083
this.focus();
8184
}
8285
});

0 commit comments

Comments
 (0)