mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-28 16:39:00 +01:00
text files - move revert() error handler into model
This commit is contained in:
@@ -598,26 +598,13 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
|
||||
});
|
||||
|
||||
await Promise.all(fileModels.map(async model => {
|
||||
try {
|
||||
await model.revert(options);
|
||||
await model.revert(options);
|
||||
|
||||
// If model is still dirty, mark the resulting operation as error
|
||||
if (model.isDirty()) {
|
||||
const result = mapResourceToResult.get(model.resource);
|
||||
if (result) {
|
||||
result.error = true;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
// FileNotFound means the file got deleted meanwhile, so ignore it
|
||||
if ((<FileOperationError>error).fileOperationResult === FileOperationResult.FILE_NOT_FOUND) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise bubble up the error
|
||||
else {
|
||||
throw error;
|
||||
// If model is still dirty, mark the resulting operation as error
|
||||
if (model.isDirty()) {
|
||||
const result = mapResourceToResult.get(model.resource);
|
||||
if (result) {
|
||||
result.error = true;
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -230,10 +230,14 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
|
||||
await this.load({ forceReadFromDisk: true });
|
||||
} catch (error) {
|
||||
|
||||
// Set flags back to previous values, we are still dirty if revert failed
|
||||
undo();
|
||||
// FileNotFound means the file got deleted meanwhile, so ignore it
|
||||
if ((<FileOperationError>error).fileOperationResult !== FileOperationResult.FILE_NOT_FOUND) {
|
||||
|
||||
throw error;
|
||||
// Set flags back to previous values, we are still dirty if revert failed
|
||||
undo();
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user