mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 19:18:59 +01:00
fix NPE in resolving resource input
This commit is contained in:
@@ -42,6 +42,7 @@ export class ResourceEditorInput extends EditorInput {
|
||||
} else {
|
||||
array.unshift(provider);
|
||||
}
|
||||
|
||||
return {
|
||||
dispose() {
|
||||
let array = ResourceEditorInput.registry[scheme];
|
||||
@@ -76,14 +77,18 @@ export class ResourceEditorInput extends EditorInput {
|
||||
// the loading such that we don't create the same model
|
||||
// twice
|
||||
ResourceEditorInput.loadingModels[resource.toString()] = loadingModel = new TPromise<IModel>((resolve, reject) => {
|
||||
|
||||
let result: IModel;
|
||||
let lastError: any;
|
||||
|
||||
sequence(array.map(provider => {
|
||||
return () => {
|
||||
if (!result) {
|
||||
return provider.provideTextContent(resource).then(value => {
|
||||
const contentPromise = provider.provideTextContent(resource);
|
||||
if (!contentPromise) {
|
||||
return TPromise.wrapError<any>(`No resolver for the scheme '${resource.scheme}' found.`);
|
||||
}
|
||||
|
||||
return contentPromise.then(value => {
|
||||
result = value;
|
||||
}, err => {
|
||||
lastError = err;
|
||||
@@ -98,19 +103,17 @@ export class ResourceEditorInput extends EditorInput {
|
||||
}
|
||||
}, reject);
|
||||
|
||||
}, function() {
|
||||
}, function () {
|
||||
// no cancellation when caching promises
|
||||
});
|
||||
|
||||
// remove the cached promise 'cos the model is now
|
||||
// known to the model service (see above)
|
||||
// remove the cached promise 'cos the model is now known to the model service (see above)
|
||||
loadingModel.then(() => delete ResourceEditorInput.loadingModels[resource.toString()], () => delete ResourceEditorInput.loadingModels[resource.toString()]);
|
||||
}
|
||||
|
||||
return loadingModel;
|
||||
}
|
||||
|
||||
|
||||
public static ID: string = 'workbench.editors.resourceEditorInput';
|
||||
|
||||
protected cachedModel: ResourceEditorModel;
|
||||
|
||||
Reference in New Issue
Block a user