Skip to content

Commit e0d2557

Browse files
committed
feedback
1 parent 71cc49b commit e0d2557

File tree

13 files changed

+297
-18
lines changed

13 files changed

+297
-18
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
675675
}
676676

677677
isModified(): boolean {
678-
return this.dirty;
678+
return this.isDirty();
679679
}
680680

681681
setDirty(dirty: boolean): void {

src/vs/workbench/services/textfile/test/browser/textFileEditorModel.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ suite('Files - TextFileEditorModel', () => {
104104
model.updateTextEditorModel(createTextBufferFactory('bar'));
105105
assert.ok(getLastModifiedTime(model) <= Date.now());
106106
assert.ok(model.hasState(TextFileEditorModelState.DIRTY));
107+
assert.ok(model.isModified());
107108

108109
assert.strictEqual(accessor.workingCopyService.dirtyCount, 1);
109110
assert.strictEqual(accessor.workingCopyService.isDirty(model.resource, model.typeId), true);
@@ -123,6 +124,7 @@ suite('Files - TextFileEditorModel', () => {
123124

124125
assert.ok(model.hasState(TextFileEditorModelState.SAVED));
125126
assert.ok(!model.isDirty());
127+
assert.ok(!model.isModified());
126128
assert.ok(savedEvent);
127129
assert.ok((savedEvent as ITextFileEditorModelSaveEvent).stat);
128130
assert.strictEqual((savedEvent as ITextFileEditorModelSaveEvent).reason, SaveReason.AUTO);
@@ -182,6 +184,7 @@ suite('Files - TextFileEditorModel', () => {
182184

183185
assert.ok(model.hasState(TextFileEditorModelState.ERROR));
184186
assert.ok(model.isDirty());
187+
assert.ok(model.isModified());
185188
assert.ok(saveErrorEvent);
186189

187190
assert.strictEqual(accessor.workingCopyService.dirtyCount, 1);
@@ -238,6 +241,7 @@ suite('Files - TextFileEditorModel', () => {
238241

239242
assert.ok(model.hasState(TextFileEditorModelState.ERROR));
240243
assert.ok(model.isDirty());
244+
assert.ok(model.isModified());
241245
assert.ok(saveErrorEvent);
242246

243247
assert.strictEqual(accessor.workingCopyService.dirtyCount, 1);
@@ -268,6 +272,7 @@ suite('Files - TextFileEditorModel', () => {
268272

269273
assert.ok(model.hasState(TextFileEditorModelState.CONFLICT));
270274
assert.ok(model.isDirty());
275+
assert.ok(model.isModified());
271276
assert.ok(saveErrorEvent);
272277

273278
assert.strictEqual(accessor.workingCopyService.dirtyCount, 1);
@@ -457,6 +462,7 @@ suite('Files - TextFileEditorModel', () => {
457462
await model.resolve();
458463
model.updateTextEditorModel(createTextBufferFactory('foo'));
459464
assert.ok(model.isDirty());
465+
assert.ok(model.isModified());
460466

461467
assert.strictEqual(accessor.workingCopyService.dirtyCount, 1);
462468
assert.strictEqual(accessor.workingCopyService.isDirty(model.resource, model.typeId), true);
@@ -471,6 +477,7 @@ suite('Files - TextFileEditorModel', () => {
471477
model = accessor.workingCopyService.get(model) as TextFileEditorModel;
472478

473479
assert.strictEqual(model.isDirty(), false);
480+
assert.strictEqual(model.isModified(), false);
474481
assert.strictEqual(eventCounter, 1);
475482

476483
assert.ok(workingCopyEvent);
@@ -497,12 +504,14 @@ suite('Files - TextFileEditorModel', () => {
497504
await model.resolve();
498505
model.updateTextEditorModel(createTextBufferFactory('foo'));
499506
assert.ok(model.isDirty());
507+
assert.ok(model.isModified());
500508

501509
assert.strictEqual(accessor.workingCopyService.dirtyCount, 1);
502510
assert.strictEqual(accessor.workingCopyService.isDirty(model.resource, model.typeId), true);
503511

504512
await model.revert({ soft: true });
505513
assert.strictEqual(model.isDirty(), false);
514+
assert.strictEqual(model.isModified(), false);
506515
assert.strictEqual(model.textEditorModel!.getValue(), 'foo');
507516
assert.strictEqual(eventCounter, 1);
508517

src/vs/workbench/services/textmodelResolver/test/browser/textModelResolverService.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ suite('Workbench - TextModelResolverService', () => {
157157
test('resolve untitled', async () => {
158158
const service = accessor.untitledTextEditorService;
159159
const untitledModel = service.create();
160-
untitledModel.isModified = untitledModel.isDirty;
161160
const input = instantiationService.createInstance(UntitledTextEditorInput, untitledModel);
162161

163162
await input.resolve();

src/vs/workbench/services/untitled/common/untitledTextEditorModel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export interface IUntitledTextEditorModel extends ITextEditorModel, ILanguageSup
6767
resolve(): Promise<void>;
6868
}
6969

70-
export class UntitledTextEditorModel extends BaseTextEditorModel implements IUntitledTextEditorModel, IWorkingCopy {
70+
export class UntitledTextEditorModel extends BaseTextEditorModel implements IUntitledTextEditorModel {
7171

7272
private static readonly FIRST_LINE_NAME_MAX_LENGTH = 40;
7373
private static readonly FIRST_LINE_NAME_CANDIDATE_MAX_LENGTH = UntitledTextEditorModel.FIRST_LINE_NAME_MAX_LENGTH * 10;
@@ -244,7 +244,7 @@ export class UntitledTextEditorModel extends BaseTextEditorModel implements IUnt
244244
}
245245

246246
isModified(): boolean {
247-
return this.dirty;
247+
return this.isDirty();
248248
}
249249

250250
private setDirty(dirty: boolean): void {

src/vs/workbench/services/workingCopy/browser/workingCopyBackupTracker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class BrowserWorkingCopyBackupTracker extends WorkingCopyBackupTracker im
3838

3939
const modifiedWorkingCopies = this.workingCopyService.modifiedWorkingCopies;
4040
if (!modifiedWorkingCopies.length) {
41-
return false; // no unsaved changes: no veto
41+
return false; // nothing modified: no veto
4242
}
4343

4444
if (this.workingCopyService.hasDirty && !this.filesConfigurationService.isHotExitEnabled) {
@@ -49,10 +49,10 @@ export class BrowserWorkingCopyBackupTracker extends WorkingCopyBackupTracker im
4949
if (!this.workingCopyBackupService.hasBackupSync(modifiedWorkingCopy, this.getContentVersion(modifiedWorkingCopy))) {
5050
this.logService.warn('Unload veto: pending backups');
5151

52-
return true; // unsaved content without backup: veto
52+
return true; // modified without backup: veto
5353
}
5454
}
5555

56-
return false; // unsaved content backed up: no veto
56+
return false; // modified and backed up: no veto
5757
}
5858
}

src/vs/workbench/services/workingCopy/common/resourceWorkingCopy.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,4 @@ export abstract class ResourceWorkingCopy extends Disposable implements IResourc
170170
abstract revert(options?: IRevertOptions): Promise<void>;
171171

172172
//#endregion
173-
174173
}

src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,14 @@ export class UntitledFileWorkingCopy<M extends IUntitledFileWorkingCopyModel> ex
227227

228228
private onModelContentChanged(e: IUntitledFileWorkingCopyModelContentChangedEvent): void {
229229

230-
// Mark the untitled file working copy as non-dirty once its
230+
// Mark the untitled file working copy as non-modified once its
231231
// in case provided by the change event and in case we do not
232232
// have an associated path set
233233
if (!this.hasAssociatedFilePath && e.isInitial) {
234234
this.setModified(false);
235235
}
236236

237-
// Turn dirty otherwise
237+
// Turn modified otherwise
238238
else {
239239
this.setModified(true);
240240
}

src/vs/workbench/services/workingCopy/common/workingCopyBackupTracker.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,13 @@ export abstract class WorkingCopyBackupTracker extends Disposable {
159159
return;
160160
}
161161

162-
// Schedule backup for unsaved content
162+
// Schedule backup for modified working copies
163163
if (workingCopy.isModified()) {
164164
// this listener will make sure that the backup is
165165
// pushed out for as long as the user is still changing
166166
// the content of the working copy.
167167
this.scheduleBackup(workingCopy);
168168
}
169-
else {
170-
this.discardBackup(workingCopy);
171-
}
172169
}
173170

174171
private scheduleBackup(workingCopy: IWorkingCopy): void {

src/vs/workbench/services/workingCopy/common/workingCopyService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ export class WorkingCopyService extends Disposable implements IWorkingCopyServic
272272
}
273273

274274
get modifiedWorkingCopies(): IWorkingCopy[] {
275-
return this.workingCopies.filter(workingCopy => workingCopy.isModified);
275+
return this.workingCopies.filter(workingCopy => workingCopy.isModified());
276276
}
277277

278278
isDirty(resource: URI, typeId?: string): boolean {

src/vs/workbench/services/workingCopy/electron-sandbox/workingCopyBackupTracker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export class NativeWorkingCopyBackupTracker extends WorkingCopyBackupTracker imp
102102
return this.handleModifiedBeforeShutdown(remainingModifiedWorkingCopies, reason);
103103
}
104104

105-
return this.noVeto([...modifiedWorkingCopies]); // no veto (dirty auto-saved)
105+
return this.noVeto([...modifiedWorkingCopies]); // no veto (modified auto-saved)
106106
}
107107

108108
// Auto save is not enabled

0 commit comments

Comments
 (0)