提交 e6ff6be9 编写于 作者: M Matt Bierner

Fix focus tracker sometimes not being created properly for webview Editors

Fixes #46974
上级 2c1e126c
......@@ -185,17 +185,15 @@ export class WebviewEditor extends BaseWebviewEditor {
}
this.webviewContent = input.container;
this.trackFocus();
const existing = input.webview;
if (existing) {
this._webview = existing;
return existing;
}
this._webviewFocusTracker = DOM.trackFocus(this.webviewContent);
this._webviewFocusListenerDisposable = this._webviewFocusTracker.onDidFocus(() => {
this._onDidFocusWebview.fire();
});
if (input.options.enableFindWidget) {
this._contextKeyService = this._contextKeyService.createScoped(this.webviewContent);
this.contextKey = KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS.bindTo(this._contextKeyService);
......@@ -226,5 +224,19 @@ export class WebviewEditor extends BaseWebviewEditor {
this.doUpdateContainer();
return this._webview;
}
private trackFocus() {
if (this._webviewFocusTracker) {
this._webviewFocusTracker.dispose();
}
if (this._webviewFocusListenerDisposable) {
this._webviewFocusListenerDisposable.dispose();
}
this._webviewFocusTracker = DOM.trackFocus(this.webviewContent);
this._webviewFocusListenerDisposable = this._webviewFocusTracker.onDidFocus(() => {
this._onDidFocusWebview.fire();
});
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册