Skip to content

Commit f5a52f8

Browse files
author
Benjamin Pasero
committed
text files - move revert() error handler into model
1 parent 432961c commit f5a52f8

2 files changed

Lines changed: 13 additions & 22 deletions

File tree

src/vs/workbench/services/textfile/browser/textFileService.ts

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -598,26 +598,13 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
598598
});
599599

600600
await Promise.all(fileModels.map(async model => {
601-
try {
602-
await model.revert(options);
603-
604-
// If model is still dirty, mark the resulting operation as error
605-
if (model.isDirty()) {
606-
const result = mapResourceToResult.get(model.resource);
607-
if (result) {
608-
result.error = true;
609-
}
610-
}
611-
} catch (error) {
612-
613-
// FileNotFound means the file got deleted meanwhile, so ignore it
614-
if ((<FileOperationError>error).fileOperationResult === FileOperationResult.FILE_NOT_FOUND) {
615-
return;
616-
}
601+
await model.revert(options);
617602

618-
// Otherwise bubble up the error
619-
else {
620-
throw error;
603+
// If model is still dirty, mark the resulting operation as error
604+
if (model.isDirty()) {
605+
const result = mapResourceToResult.get(model.resource);
606+
if (result) {
607+
result.error = true;
621608
}
622609
}
623610
}));

src/vs/workbench/services/textfile/common/textFileEditorModel.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,14 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
230230
await this.load({ forceReadFromDisk: true });
231231
} catch (error) {
232232

233-
// Set flags back to previous values, we are still dirty if revert failed
234-
undo();
233+
// FileNotFound means the file got deleted meanwhile, so ignore it
234+
if ((<FileOperationError>error).fileOperationResult !== FileOperationResult.FILE_NOT_FOUND) {
235235

236-
throw error;
236+
// Set flags back to previous values, we are still dirty if revert failed
237+
undo();
238+
239+
throw error;
240+
}
237241
}
238242
}
239243

0 commit comments

Comments
 (0)