Skip to content

Commit e12fc11

Browse files
author
Benjamin Pasero
committed
split revertAll into method for files and untitled
1 parent 5d064d3 commit e12fc11

1 file changed

Lines changed: 20 additions & 17 deletions

File tree

src/vs/workbench/parts/files/common/textFileServices.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@ export abstract class TextFileService implements ITextFileService {
3434

3535
public _serviceBrand: any;
3636

37-
protected listenerToUnbind: IDisposable[];
38-
37+
private listenerToUnbind: IDisposable[];
3938
private _onAutoSaveConfigurationChange: Emitter<IAutoSaveConfiguration>;
40-
4139
private configuredAutoSaveDelay: number;
42-
protected configuredAutoSaveOnFocusChange: boolean;
43-
protected configuredAutoSaveOnWindowChange: boolean;
40+
private configuredAutoSaveOnFocusChange: boolean;
41+
private configuredAutoSaveOnWindowChange: boolean;
4442

4543
constructor(
4644
@ILifecycleService private lifecycleService: ILifecycleService,
@@ -206,11 +204,7 @@ export abstract class TextFileService implements ITextFileService {
206204
public isDirty(resource?: URI): boolean {
207205

208206
// Check for dirty file
209-
let dirty = CACHE
210-
.getAll(resource)
211-
.some(model => model.isDirty());
212-
213-
if (dirty) {
207+
if (CACHE.getAll(resource).some(model => model.isDirty())) {
214208
return true;
215209
}
216210

@@ -442,6 +436,19 @@ export abstract class TextFileService implements ITextFileService {
442436
}
443437

444438
public revertAll(resources?: URI[], force?: boolean): TPromise<ITextFileOperationResult> {
439+
440+
// Revert files first
441+
return this.doRevertAllFiles(resources, force).then(operation => {
442+
443+
// Revert untitled
444+
const reverted = this.untitledEditorService.revertAll(resources);
445+
reverted.forEach(res => operation.results.push({ source: res, success: true }));
446+
447+
return operation;
448+
});
449+
}
450+
451+
private doRevertAllFiles(resources?: URI[], force?: boolean): TPromise<ITextFileOperationResult> {
445452
const fileModels = force ? this.getFileModels(resources) : this.getDirtyFileModels(resources);
446453

447454
const mapResourceToResult: { [resource: string]: IResult } = Object.create(null);
@@ -478,13 +485,9 @@ export abstract class TextFileService implements ITextFileService {
478485
}
479486
});
480487
})).then(r => {
481-
const operation = { results: Object.keys(mapResourceToResult).map(k => mapResourceToResult[k]) };
482-
483-
// Revert untitled
484-
const reverted = this.untitledEditorService.revertAll(resources);
485-
reverted.forEach(res => operation.results.push({ source: res, success: true }));
486-
487-
return operation;
488+
return {
489+
results: Object.keys(mapResourceToResult).map(k => mapResourceToResult[k])
490+
};
488491
});
489492
}
490493

0 commit comments

Comments
 (0)