Replace editor upon saving (#143144)

This commit is contained in:
Logan Ramos 2022-02-15 17:11:45 -05:00 committed by GitHub
parent a2348fa5f2
commit 69f268f052
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -910,8 +910,16 @@ export class EditorService extends Disposable implements EditorServiceImpl {
if (!result.matches(editor)) {
const targetGroups = editor.hasCapability(EditorInputCapabilities.Untitled) ? this.editorGroupService.groups.map(group => group.id) /* untitled replaces across all groups */ : [groupId];
for (const targetGroup of targetGroups) {
const resolvedEditor = await this.editorResolverService.resolveEditor({ resource: result.resource, }, targetGroup);
const group = this.editorGroupService.getGroup(targetGroup);
await group?.replaceEditors([{ editor, replacement: result, options: editorOptions }]);
if (resolvedEditor !== ResolvedStatus.ABORT && isEditorInputWithOptionsAndGroup(resolvedEditor)) {
// dispose the previous result before replacing with the resolved editor
saveResults.pop()?.dispose();
saveResults.push(resolvedEditor.editor);
await group?.replaceEditors([{ editor, replacement: resolvedEditor.editor, options: editorOptions }]);
} else {
await group?.replaceEditors([{ editor, replacement: result, options: editorOptions }]);
}
}
}
}