slightly better fix for #52447

This commit is contained in:
Benjamin Pasero
2018-07-05 16:00:33 +02:00
parent e283c32b9d
commit 89ab4395d6
@@ -693,13 +693,16 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
}
create(resource: URI, contents?: string, options?: { overwrite?: boolean }): TPromise<void> {
const existingModel = this.models.get(resource);
return this.fileService.createFile(resource, contents, options).then(() => {
// If we had an existing model for the given resource, load
// it again to make sure it is up to date with the contents
// we just wrote into the underlying resource.
if (!!this.models.get(resource)) {
return this.models.loadOrCreate(resource, { reload: { async: false } }).then(() => void 0);
// we just wrote into the underlying resource by calling
// revert()
if (existingModel && !existingModel.isDisposed()) {
return existingModel.revert();
}
return void 0;