提交 2f9b7807 编写于 作者: B Benjamin Pasero

editors - turn runtime extensions into singleton

上级 a18110ad
......@@ -57,7 +57,7 @@ export class ExtensionHostProfileService extends Disposable implements IExtensio
CommandsRegistry.registerCommand('workbench.action.extensionHostProfilder.stop', () => {
this.stopProfiling();
this._editorService.openEditor(this._instantiationService.createInstance(RuntimeExtensionsInput), { revealIfOpened: true });
this._editorService.openEditor(RuntimeExtensionsInput.instance, { revealIfOpened: true });
});
}
......
......@@ -50,7 +50,7 @@ class RuntimeExtensionsInputFactory implements IEditorInputFactory {
return '';
}
deserialize(instantiationService: IInstantiationService, serializedEditorInput: string): EditorInput {
return new RuntimeExtensionsInput();
return RuntimeExtensionsInput.instance;
}
}
......
......@@ -186,7 +186,7 @@ export class ExtensionsAutoProfiler extends Disposable implements IWorkbenchCont
),
[{
label: localize('show', 'Show Extensions'),
run: () => this._editorService.openEditor(new RuntimeExtensionsInput())
run: () => this._editorService.openEditor(RuntimeExtensionsInput.instance)
},
action
],
......
......@@ -494,14 +494,13 @@ export class ShowRuntimeExtensionsAction extends Action {
constructor(
id: string, label: string,
@IEditorService private readonly _editorService: IEditorService,
@IInstantiationService private readonly _instantiationService: IInstantiationService
@IEditorService private readonly _editorService: IEditorService
) {
super(id, label);
}
public async run(e?: any): Promise<any> {
await this._editorService.openEditor(this._instantiationService.createInstance(RuntimeExtensionsInput), { revealIfOpened: true });
await this._editorService.openEditor(RuntimeExtensionsInput.instance, { revealIfOpened: true });
}
}
......
......@@ -5,12 +5,21 @@
import * as nls from 'vs/nls';
import { URI } from 'vs/base/common/uri';
import { EditorInput } from 'vs/workbench/common/editor';
import { EditorInput, GroupIdentifier } from 'vs/workbench/common/editor';
export class RuntimeExtensionsInput extends EditorInput {
static readonly ID = 'workbench.runtimeExtensions.input';
static _instance: RuntimeExtensionsInput;
static get instance() {
if (!RuntimeExtensionsInput._instance || RuntimeExtensionsInput._instance.isDisposed()) {
RuntimeExtensionsInput._instance = new RuntimeExtensionsInput();
}
return RuntimeExtensionsInput._instance;
}
readonly resource = URI.from({
scheme: 'runtime-extensions',
path: 'default'
......@@ -25,17 +34,20 @@ export class RuntimeExtensionsInput extends EditorInput {
}
matches(other: unknown): boolean {
if (!(other instanceof RuntimeExtensionsInput)) {
return false;
}
return true;
return other instanceof RuntimeExtensionsInput;
}
resolve(): Promise<any> {
return Promise.resolve(null);
async resolve(): Promise<null> {
return null;
}
supportsSplitEditor(): boolean {
return false;
}
close(group: GroupIdentifier, openedInOtherGroups: boolean): void {
if (!openedInOtherGroups) {
this.dispose(); // Only dispose if not opened anymore because all runtime extensions inputs are shared
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册