mirror of
https://github.com/Microsoft/vscode
synced 2024-09-20 19:18:03 +00:00
fix NPE in resolving resource input
This commit is contained in:
parent
1e23c593ff
commit
fc2539e7cc
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue