From 89ab4395d6fe2ce3dbfbc0194499fffa9b0635ba Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 5 Jul 2018 16:00:33 +0200 Subject: [PATCH] slightly better fix for #52447 --- .../services/textfile/common/textFileService.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/services/textfile/common/textFileService.ts b/src/vs/workbench/services/textfile/common/textFileService.ts index 5e1e00594c6..f77b7d2ecc1 100644 --- a/src/vs/workbench/services/textfile/common/textFileService.ts +++ b/src/vs/workbench/services/textfile/common/textFileService.ts @@ -693,13 +693,16 @@ export abstract class TextFileService extends Disposable implements ITextFileSer } create(resource: URI, contents?: string, options?: { overwrite?: boolean }): TPromise { + 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; -- GitLab