Skip to content

Commit 8edc58a

Browse files
authored
auto save - skip non-dirty editors (#200468)
1 parent 71966e4 commit 8edc58a

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/vs/workbench/browser/parts/editor/editorAutoSave.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ export class EditorAutoSave extends Disposable implements IWorkbenchContribution
9292

9393
private maybeTriggerAutoSave(reason: SaveReason, editorIdentifier?: IEditorIdentifier): void {
9494
if (editorIdentifier) {
95-
if (editorIdentifier.editor.isReadonly() || editorIdentifier.editor.hasCapability(EditorInputCapabilities.Untitled)) {
95+
if (
96+
!editorIdentifier.editor.isDirty() ||
97+
editorIdentifier.editor.isReadonly() ||
98+
editorIdentifier.editor.hasCapability(EditorInputCapabilities.Untitled)
99+
) {
96100
return; // no auto save for readonly or untitled editors
97101
}
98102

@@ -170,15 +174,15 @@ export class EditorAutoSave extends Disposable implements IWorkbenchContribution
170174
}
171175

172176
private scheduleAutoSave(workingCopy: IWorkingCopy): void {
177+
if (workingCopy.capabilities & WorkingCopyCapabilities.Untitled) {
178+
return; // we never auto save untitled working copies
179+
}
180+
173181
const autoSaveAfterDelay = this.filesConfigurationService.getAutoSaveConfiguration(workingCopy.resource).autoSaveDelay;
174182
if (typeof autoSaveAfterDelay !== 'number') {
175183
return; // auto save after delay must be enabled
176184
}
177185

178-
if (workingCopy.capabilities & WorkingCopyCapabilities.Untitled) {
179-
return; // we never auto save untitled working copies
180-
}
181-
182186
// Clear any running auto save operation
183187
this.discardAutoSave(workingCopy);
184188

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,11 @@ export abstract class WorkingCopyBackupTracker extends Disposable {
229229
return workingCopy.backupDelay; // respect working copy override
230230
}
231231

232-
let autoSaveMode = this.filesConfigurationService.getAutoSaveMode(workingCopy.resource);
232+
let autoSaveMode: AutoSaveMode;
233233
if (workingCopy.capabilities & WorkingCopyCapabilities.Untitled) {
234234
autoSaveMode = AutoSaveMode.OFF; // auto-save is never on for untitled working copies
235+
} else {
236+
autoSaveMode = this.filesConfigurationService.getAutoSaveMode(workingCopy.resource);
235237
}
236238

237239
return WorkingCopyBackupTracker.DEFAULT_BACKUP_SCHEDULE_DELAYS[autoSaveMode];

0 commit comments

Comments
 (0)