mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
Only override editor opening for resource that have potential custom editors
For #88525
This commit is contained in:
@@ -347,9 +347,15 @@ export class CustomEditorContribution implements IWorkbenchContribution {
|
||||
options: ITextEditorOptions | undefined,
|
||||
group: IEditorGroup
|
||||
): IOpenEditorOverride | undefined {
|
||||
const userConfiguredEditors = this.customEditorService.getUserConfiguredCustomEditors(resource);
|
||||
const contributedEditors = this.customEditorService.getContributedCustomEditors(resource);
|
||||
if (!userConfiguredEditors.length && !contributedEditors.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check to see if there already an editor for the resource in the group.
|
||||
// If there is, we want to open that instead of creating a new editor.
|
||||
// This ensures that we preserve whatever state the editor was previously in
|
||||
// This ensures that we preserve whatever type of editor was previously being used
|
||||
// when the user switches back to it.
|
||||
const existingEditorForResource = group.editors.find(editor => isEqual(resource, editor.getResource()));
|
||||
if (existingEditorForResource) {
|
||||
@@ -358,14 +364,12 @@ export class CustomEditorContribution implements IWorkbenchContribution {
|
||||
};
|
||||
}
|
||||
|
||||
const userConfiguredEditors = this.customEditorService.getUserConfiguredCustomEditors(resource);
|
||||
if (userConfiguredEditors.length) {
|
||||
return {
|
||||
override: this.customEditorService.openWith(resource, userConfiguredEditors.allEditors[0].id, options, group),
|
||||
};
|
||||
}
|
||||
|
||||
const contributedEditors = this.customEditorService.getContributedCustomEditors(resource);
|
||||
if (!contributedEditors.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user