Make createEditorInput async (#20038)

This commit is contained in:
Charles Gagnon
2022-07-14 19:39:52 -07:00
committed by GitHub
parent ada87478a7
commit ba1f4db745
9 changed files with 25 additions and 24 deletions

View File

@@ -71,7 +71,7 @@ export default class EditorComponent extends ComponentBase<azdata.EditorProperti
this._editor.setVisible(true);
let uri = this.createUri();
this._editorInput = this.editorService.createEditorInput({ forceUntitled: true, resource: uri, mode: 'plaintext' }) as UntitledTextEditorInput;
this._editorInput = await this.editorService.createEditorInput({ forceUntitled: true, resource: uri, mode: 'plaintext' }) as UntitledTextEditorInput;
await this._editor.setInput(this._editorInput, undefined, undefined);
const model = await this._editorInput.resolve();

View File

@@ -782,15 +782,15 @@ export class NotebookEditorOverrideContribution extends Disposable implements IW
priority: RegisteredEditorPriority.builtin
},
{},
(editorInput, group) => {
const fileInput = this._editorService.createEditorInput(editorInput) as FileEditorInput;
async (editorInput, group) => {
const fileInput = await this._editorService.createEditorInput(editorInput) as FileEditorInput;
// Try to convert the input, falling back to just a plain file input if we're unable to
const newInput = this.convertInput(fileInput);
return { editor: newInput, options: editorInput.options, group: group };
},
undefined,
(diffEditorInput, group) => {
const diffEditorInputImpl = this._editorService.createEditorInput(diffEditorInput) as DiffEditorInput;
async (diffEditorInput, group) => {
const diffEditorInputImpl = await this._editorService.createEditorInput(diffEditorInput) as DiffEditorInput;
// Try to convert the input, falling back to the original input if we're unable to
const newInput = this.convertInput(diffEditorInputImpl);
return { editor: newInput, options: diffEditorInput.options, group: group };

View File

@@ -546,8 +546,8 @@ export class QueryEditorOverrideContribution extends Disposable implements IWork
// Fall back to using the normal text based diff editor - we don't want the query bar and related items showing up in the diff editor
canHandleDiff: () => false
},
(editorInput, group) => {
const fileInput = this._editorService.createEditorInput(editorInput) as FileEditorInput;
async (editorInput, group) => {
const fileInput = await this._editorService.createEditorInput(editorInput) as FileEditorInput;
const langAssociation = languageAssociationRegistry.getAssociationForLanguage(lang);
const queryEditorInput = langAssociation?.syncConvertInput?.(fileInput);
if (!queryEditorInput) {

View File

@@ -309,7 +309,7 @@ export class NotebookService extends Disposable implements INotebookService {
fileInput = this._instantiationService.createInstance(UntitledTextEditorInput, model);
} else {
let input: any = { forceFile: true, resource: uri, mode: languageMode };
fileInput = this._editorService.createEditorInput(input);
fileInput = await this._editorService.createEditorInput(input);
}
}

View File

@@ -58,7 +58,7 @@ export class QueryEditorService implements IQueryEditorService {
// Create a sql document pane with accoutrements
const mode = this._connectionManagementService.getProviderLanguageMode(connectionProviderName);
const fileInput = this._editorService.createEditorInput({ forceUntitled: true, resource: docUri, mode: mode }) as UntitledTextEditorInput;
const fileInput = await this._editorService.createEditorInput({ forceUntitled: true, resource: docUri, mode: mode }) as UntitledTextEditorInput;
let untitledEditorModel = await fileInput.resolve();
if (options.initalContent) {
untitledEditorModel.textEditorModel.setValue(options.initalContent);
@@ -102,7 +102,7 @@ export class QueryEditorService implements IQueryEditorService {
let docUri: URI = URI.from({ scheme: Schemas.untitled, path: filePath });
// Create a sql document pane with accoutrements
const fileInput = this._editorService.createEditorInput({ forceUntitled: true, resource: docUri, mode: 'sql' }) as UntitledTextEditorInput;
const fileInput = await this._editorService.createEditorInput({ forceUntitled: true, resource: docUri, mode: 'sql' }) as UntitledTextEditorInput;
const m = await fileInput.resolve();
//when associatedResource editor is created it is dirty, this must be set to false to be able to detect changes to the editor.
(m as UntitledTextEditorModel).setDirty(false);

View File

@@ -20,8 +20,8 @@ export class TestQueryEditorService implements IQueryEditorService {
@IEditorService private readonly editorService: IEditorService) {
}
newSqlEditor(options?: INewSqlEditorOptions): Promise<IUntitledQueryEditorInput> {
const base = this.editorService.createEditorInput({ resource: undefined, forceUntitled: true }) as UntitledTextEditorInput;
async newSqlEditor(options?: INewSqlEditorOptions): Promise<IUntitledQueryEditorInput> {
const base = await this.editorService.createEditorInput({ resource: undefined, forceUntitled: true }) as UntitledTextEditorInput;
return Promise.resolve(this.instantiationService.createInstance(UntitledQueryEditorInput, '', base, new QueryResultsInput(base.resource.toString(true))));
}