mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
webview - clear group listener when it gets disposed
//cc @lramos15
This commit is contained in:
parent
fe1547c251
commit
d0884f4a1e
|
@ -3,7 +3,8 @@
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
import { Event } from 'vs/base/common/event';
|
||||||
|
import { Disposable } from 'vs/base/common/lifecycle';
|
||||||
import { localize } from 'vs/nls';
|
import { localize } from 'vs/nls';
|
||||||
import { registerAction2 } from 'vs/platform/actions/common/actions';
|
import { registerAction2 } from 'vs/platform/actions/common/actions';
|
||||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||||
|
@ -28,26 +29,28 @@ import { IWebviewWorkbenchService, WebviewEditorService } from './webviewWorkben
|
||||||
|
|
||||||
class WebviewPanelContribution extends Disposable implements IWorkbenchContribution {
|
class WebviewPanelContribution extends Disposable implements IWorkbenchContribution {
|
||||||
|
|
||||||
private readonly _disposables = new DisposableStore();
|
|
||||||
constructor(
|
constructor(
|
||||||
@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService,
|
@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService,
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
// Add all the initial groups to be listened to
|
// Add all the initial groups to be listened to
|
||||||
this.editorGroupService.whenReady.then(() => this.editorGroupService.groups.forEach(group => {
|
this.editorGroupService.whenReady.then(() => this.editorGroupService.groups.forEach(group => {
|
||||||
this.registerGroupListener(group);
|
this.registerGroupListener(group);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Additional groups added should also be listened to
|
// Additional groups added should also be listened to
|
||||||
this._register(this.editorGroupService.onDidAddGroup((group) => this.registerGroupListener(group)));
|
this._register(this.editorGroupService.onDidAddGroup(group => this.registerGroupListener(group)));
|
||||||
|
|
||||||
this._register(this._disposables);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private registerGroupListener(group: IEditorGroup): void {
|
private registerGroupListener(group: IEditorGroup): void {
|
||||||
const listener = group.onWillOpenEditor(e => this.onEditorOpening(e.editor, group));
|
const listener = group.onWillOpenEditor(e => this.onEditorOpening(e.editor, group));
|
||||||
this._disposables.add(listener);
|
|
||||||
|
Event.once(group.onWillDispose)(() => {
|
||||||
|
listener.dispose();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private onEditorOpening(
|
private onEditorOpening(
|
||||||
editor: IEditorInput,
|
editor: IEditorInput,
|
||||||
group: IEditorGroup
|
group: IEditorGroup
|
||||||
|
@ -74,7 +77,6 @@ class WebviewPanelContribution extends Disposable implements IWorkbenchContribut
|
||||||
}
|
}
|
||||||
|
|
||||||
previousGroup.closeEditor(editor);
|
previousGroup.closeEditor(editor);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +89,6 @@ Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).
|
||||||
|
|
||||||
registerSingleton(IWebviewWorkbenchService, WebviewEditorService, true);
|
registerSingleton(IWebviewWorkbenchService, WebviewEditorService, true);
|
||||||
|
|
||||||
|
|
||||||
registerAction2(ShowWebViewEditorFindWidgetAction);
|
registerAction2(ShowWebViewEditorFindWidgetAction);
|
||||||
registerAction2(HideWebViewEditorFindCommand);
|
registerAction2(HideWebViewEditorFindCommand);
|
||||||
registerAction2(WebViewEditorFindNextCommand);
|
registerAction2(WebViewEditorFindNextCommand);
|
||||||
|
|
Loading…
Reference in a new issue