mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Make createEditorInput async (#20038)
This commit is contained in:
@@ -861,7 +861,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
|
||||
// {{SQL CARBON EDIT}} -- add back createEditorInput until we can remove all references
|
||||
private readonly editorInputCache = new ResourceMap<CachedEditorInput>();
|
||||
|
||||
createEditorInput(input: EditorInput | IUntypedEditorInput): EditorInput {
|
||||
async createEditorInput(input: EditorInput | IUntypedEditorInput): Promise<EditorInput> {
|
||||
|
||||
// Typed Editor Input Support (EditorInput)
|
||||
if (input instanceof EditorInput) {
|
||||
@@ -873,8 +873,8 @@ export class EditorService extends Disposable implements EditorServiceImpl {
|
||||
// const original = this.createEditorInput({ ...input.original, forceFile: true /*input.forceFile*/ });
|
||||
// const modified = this.createEditorInput({ ...input.modified, forceFile: true /*input.forceFile*/ });
|
||||
|
||||
const original = this.createEditorInput(input.original);
|
||||
const modified = this.createEditorInput(input.modified);
|
||||
const original = await this.createEditorInput(input.original);
|
||||
const modified = await this.createEditorInput(input.modified);
|
||||
|
||||
return this.instantiationService.createInstance(DiffEditorInput,
|
||||
input.label,
|
||||
@@ -905,7 +905,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
|
||||
untitledModel = this.untitledTextEditorService.create({ associatedResource: untitledInput.resource, ...untitledOptions });
|
||||
}
|
||||
|
||||
return this.createOrGetCached(untitledModel.resource, () => {
|
||||
return this.createOrGetCached(untitledModel.resource, async () => {
|
||||
|
||||
// Factory function for new untitled editor
|
||||
const input = this.instantiationService.createInstance(UntitledTextEditorInput, untitledModel);
|
||||
@@ -918,7 +918,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
|
||||
Event.once(input.onWillDispose)(() => untitledModel.dispose());
|
||||
|
||||
return input;
|
||||
}) as EditorInput;
|
||||
}) as Promise<EditorInput>;
|
||||
}
|
||||
|
||||
// Text Resource Editor Support
|
||||
@@ -937,11 +937,11 @@ export class EditorService extends Disposable implements EditorServiceImpl {
|
||||
// with different resource forms (e.g. path casing on Windows)
|
||||
const canonicalResource = this.uriIdentityService.asCanonicalUri(preferredResource);
|
||||
|
||||
return this.createOrGetCached(canonicalResource, () => {
|
||||
return this.createOrGetCached(canonicalResource, async () => {
|
||||
|
||||
// File
|
||||
//if (textResourceEditorInput.forceFile || this.fileService.canHandleResource(canonicalResource)) {
|
||||
if (this.fileService.canHandleResource(canonicalResource)) {
|
||||
if (await this.fileService.canHandleResource(canonicalResource)) {
|
||||
return this.fileEditorFactory.createFileEditor(canonicalResource, preferredResource, textResourceEditorInput.label, textResourceEditorInput.description, textResourceEditorInput.encoding, textResourceEditorInput.mode, textResourceEditorInput.contents, this.instantiationService);
|
||||
}
|
||||
|
||||
@@ -997,13 +997,13 @@ export class EditorService extends Disposable implements EditorServiceImpl {
|
||||
cachedInput.setPreferredContents(textResourceEditorInput.contents);
|
||||
}
|
||||
}
|
||||
}) as EditorInput;
|
||||
}) as Promise<EditorInput>;
|
||||
}
|
||||
|
||||
throw new Error('Unknown input type');
|
||||
}
|
||||
|
||||
private createOrGetCached(resource: URI, factoryFn: () => CachedEditorInput, cachedFn?: (input: CachedEditorInput) => void): CachedEditorInput {
|
||||
private async createOrGetCached(resource: URI, factoryFn: () => Promise<CachedEditorInput>, cachedFn?: (input: CachedEditorInput) => void): Promise<CachedEditorInput> {
|
||||
|
||||
// Return early if already cached
|
||||
let input = this.editorInputCache.get(resource);
|
||||
@@ -1016,7 +1016,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
|
||||
}
|
||||
|
||||
// Otherwise create and add to cache
|
||||
input = factoryFn();
|
||||
input = await factoryFn();
|
||||
this.editorInputCache.set(resource, input);
|
||||
Event.once(input.onWillDispose)(() => this.editorInputCache.delete(resource));
|
||||
|
||||
|
||||
@@ -259,10 +259,11 @@ export interface IEditorService {
|
||||
findEditors(resource: URI, group: IEditorGroup | GroupIdentifier): readonly EditorInput[];
|
||||
findEditors(editor: IResourceEditorInputIdentifier, group: IEditorGroup | GroupIdentifier): EditorInput | undefined;
|
||||
|
||||
// {{SQL CARBON EDIT}} -- add back createEditorInput until we can remove all references. Make async to handle updated canHandleResource function returning promise
|
||||
/**
|
||||
* Converts a lightweight input to a workbench editor input.
|
||||
*/
|
||||
createEditorInput(input: IUntypedEditorInput): EditorInput;
|
||||
createEditorInput(input: IUntypedEditorInput): Promise<EditorInput>;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user