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

Only reuse existing custom editor input if we are opening an editor in the same group

上级 bac36e97
......@@ -160,7 +160,7 @@ export class CustomEditorService implements ICustomEditorService {
const webview = this.webviewService.createWebviewEditorOverlay(id, { customClasses: options ? options.customClasses : undefined }, {});
const input = this.instantiationService.createInstance(CustomFileEditorInput, resource, viewType, id, new UnownedDisposable(webview));
if (group) {
input.updateGroup(group!.id);
input.updateGroup(group.id);
}
return input;
}
......@@ -175,18 +175,16 @@ export class CustomEditorService implements ICustomEditorService {
const existingEditors = group.editors.filter(editor => editor.getResource() && isEqual(editor.getResource()!, resource));
if (existingEditors.length) {
const existing = existingEditors[0];
if (input.matches(existing)) {
return;
}
await this.editorService.replaceEditors([{
editor: existing,
replacement: input,
options: options ? EditorOptions.create(options) : undefined,
}], group);
if (existing instanceof CustomFileEditorInput) {
existing.dispose();
if (!input.matches(existing)) {
await this.editorService.replaceEditors([{
editor: existing,
replacement: input,
options: options ? EditorOptions.create(options) : undefined,
}], group);
if (existing instanceof CustomFileEditorInput) {
existing.dispose();
}
}
}
}
......@@ -212,7 +210,9 @@ export class CustomEditorContribution implements IWorkbenchContribution {
group: IEditorGroup
): IOpenEditorOverride | undefined {
if (editor instanceof CustomFileEditorInput) {
return undefined;
if (editor.group === group.id) {
return undefined;
}
}
if (editor instanceof DiffEditorInput) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册