Skip to content

Commit b5b6a80

Browse files
authored
auto save - treat autoSaveWhenNoErrors as AutoSaveMode.AFTER_LONG_DELAY (#200676)
* auto save - treat `autoSaveWhenNoErrors` as `AutoSaveMode.AFTER_LONG_DELAY` * .
1 parent 358f15f commit b5b6a80

File tree

11 files changed

+108
-93
lines changed

11 files changed

+108
-93
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,14 +605,14 @@ abstract class AbstractCloseAllAction extends Action2 {
605605

606606
// Editor will be saved on focus change when a
607607
// dialog appears, so just track that separate
608-
else if (filesConfigurationService.getAutoSaveMode(editor) === AutoSaveMode.ON_FOCUS_CHANGE && !editor.hasCapability(EditorInputCapabilities.Untitled)) {
608+
else if (!editor.hasCapability(EditorInputCapabilities.Untitled) && filesConfigurationService.getAutoSaveMode(editor) === AutoSaveMode.ON_FOCUS_CHANGE) {
609609
dirtyAutoSaveOnFocusChangeEditors.add({ editor, groupId });
610610
}
611611

612612
// Windows, Linux: editor will be saved on window change
613613
// when a native dialog appears, so just track that separate
614614
// (see https://github.com/microsoft/vscode/issues/134250)
615-
else if ((isNative && (isWindows || isLinux)) && filesConfigurationService.getAutoSaveMode(editor) === AutoSaveMode.ON_WINDOW_CHANGE && !editor.hasCapability(EditorInputCapabilities.Untitled)) {
615+
else if ((isNative && (isWindows || isLinux)) && !editor.hasCapability(EditorInputCapabilities.Untitled) && filesConfigurationService.getAutoSaveMode(editor) === AutoSaveMode.ON_WINDOW_CHANGE) {
616616
dirtyAutoSaveOnWindowChangeEditors.add({ editor, groupId });
617617
}
618618

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class EditorAutoSave extends Disposable implements IWorkbenchContribution
9090
}
9191
}
9292

93-
private maybeTriggerAutoSave(reason: SaveReason, editorIdentifier?: IEditorIdentifier): void {
93+
private maybeTriggerAutoSave(reason: SaveReason.WINDOW_CHANGE | SaveReason.FOCUS_CHANGE, editorIdentifier?: IEditorIdentifier): void {
9494
if (editorIdentifier) {
9595
if (
9696
!editorIdentifier.editor.isDirty() ||

src/vs/workbench/contrib/files/browser/editors/fileEditorInput.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { IReference, dispose, DisposableStore } from 'vs/base/common/lifecycle';
1616
import { ITextModelService } from 'vs/editor/common/services/resolverService';
1717
import { FILE_EDITOR_INPUT_ID, TEXT_FILE_EDITOR_ID, BINARY_FILE_EDITOR_ID } from 'vs/workbench/contrib/files/common/files';
1818
import { ILabelService } from 'vs/platform/label/common/label';
19-
import { AutoSaveMode, IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
19+
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
2020
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
2121
import { isEqual } from 'vs/base/common/resources';
2222
import { Event } from 'vs/base/common/event';
@@ -318,7 +318,7 @@ export class FileEditorInput extends AbstractTextResourceEditorInput implements
318318
// and it could result in bad UX where an editor can be closed even though
319319
// it shows up as dirty and has not finished saving yet.
320320

321-
if (this.filesConfigurationService.getAutoSaveMode(this) === AutoSaveMode.AFTER_SHORT_DELAY) {
321+
if (this.filesConfigurationService.isShortAutoSaveDelayConfigured(this)) {
322322
return true; // a short auto save is configured, treat this as being saved
323323
}
324324

src/vs/workbench/contrib/files/browser/editors/textFileEditorTracker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { IHostService } from 'vs/workbench/services/host/browser/host';
1313
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
1414
import { RunOnceWorker } from 'vs/base/common/async';
1515
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
16-
import { IFilesConfigurationService, AutoSaveMode } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
16+
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
1717
import { FILE_EDITOR_INPUT_ID } from 'vs/workbench/contrib/files/common/files';
1818
import { Schemas } from 'vs/base/common/network';
1919
import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput';
@@ -69,7 +69,7 @@ export class TextFileEditorTracker extends Disposable implements IWorkbenchContr
6969
return false; // resource must not be pending to save
7070
}
7171

72-
if (resource.scheme !== Schemas.untitled && this.filesConfigurationService.getAutoSaveMode(resource) === AutoSaveMode.AFTER_SHORT_DELAY && !fileModel?.hasState(TextFileEditorModelState.ERROR)) {
72+
if (resource.scheme !== Schemas.untitled && !fileModel?.hasState(TextFileEditorModelState.ERROR) && this.filesConfigurationService.isShortAutoSaveDelayConfigured(resource)) {
7373
// leave models auto saved after short delay unless
7474
// the save resulted in an error and not for untitled
7575
// that are not auto-saved anyway

src/vs/workbench/contrib/files/browser/views/openEditorsView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import { memoize } from 'vs/base/common/decorators';
3939
import { ElementsDragAndDropData, NativeDragAndDropData } from 'vs/base/browser/ui/list/listView';
4040
import { IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService';
4141
import { IWorkingCopy, WorkingCopyCapabilities } from 'vs/workbench/services/workingCopy/common/workingCopy';
42-
import { AutoSaveMode, IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
42+
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
4343
import { IViewDescriptorService } from 'vs/workbench/common/views';
4444
import { IOpenerService } from 'vs/platform/opener/common/opener';
4545
import { Orientation } from 'vs/base/browser/ui/splitview/splitview';
@@ -460,7 +460,7 @@ export class OpenEditorsView extends ViewPane {
460460
private updateDirtyIndicator(workingCopy?: IWorkingCopy): void {
461461
if (workingCopy) {
462462
const gotDirty = workingCopy.isDirty();
463-
if (gotDirty && !(workingCopy.capabilities & WorkingCopyCapabilities.Untitled) && this.filesConfigurationService.getAutoSaveMode(workingCopy.resource) === AutoSaveMode.AFTER_SHORT_DELAY) {
463+
if (gotDirty && !(workingCopy.capabilities & WorkingCopyCapabilities.Untitled) && this.filesConfigurationService.isShortAutoSaveDelayConfigured(workingCopy.resource)) {
464464
return; // do not indicate dirty of working copies that are auto saved after short delay
465465
}
466466
}

src/vs/workbench/contrib/files/common/dirtyFilesIndicator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Disposable, MutableDisposable } from 'vs/base/common/lifecycle';
1111
import { IActivityService, NumberBadge } from 'vs/workbench/services/activity/common/activity';
1212
import { IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService';
1313
import { IWorkingCopy, WorkingCopyCapabilities } from 'vs/workbench/services/workingCopy/common/workingCopy';
14-
import { IFilesConfigurationService, AutoSaveMode } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
14+
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
1515

1616
export class DirtyFilesIndicator extends Disposable implements IWorkbenchContribution {
1717
private readonly badgeHandle = this._register(new MutableDisposable());
@@ -42,7 +42,7 @@ export class DirtyFilesIndicator extends Disposable implements IWorkbenchContrib
4242

4343
private onWorkingCopyDidChangeDirty(workingCopy: IWorkingCopy): void {
4444
const gotDirty = workingCopy.isDirty();
45-
if (gotDirty && !(workingCopy.capabilities & WorkingCopyCapabilities.Untitled) && this.filesConfigurationService.getAutoSaveMode(workingCopy.resource) === AutoSaveMode.AFTER_SHORT_DELAY) {
45+
if (gotDirty && !(workingCopy.capabilities & WorkingCopyCapabilities.Untitled) && this.filesConfigurationService.isShortAutoSaveDelayConfigured(workingCopy.resource)) {
4646
return; // do not indicate dirty of working copies that are auto saved after short delay
4747
}
4848

src/vs/workbench/contrib/notebook/common/notebookEditorInput.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { VSBuffer } from 'vs/base/common/buffer';
2424
import { IWorkingCopyIdentifier } from 'vs/workbench/services/workingCopy/common/workingCopy';
2525
import { NotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/notebookProvider';
2626
import { NotebookPerfMarks } from 'vs/workbench/contrib/notebook/common/notebookPerformance';
27-
import { AutoSaveMode, IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
27+
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
2828
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
2929
import { localize } from 'vs/nls';
3030
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
@@ -181,7 +181,7 @@ export class NotebookEditorInput extends AbstractResourceEditorInput {
181181
}
182182

183183
// if a short auto save is configured, treat this as being saved
184-
return this.filesConfigurationService.getAutoSaveMode(this) === AutoSaveMode.AFTER_SHORT_DELAY;
184+
return this.filesConfigurationService.isShortAutoSaveDelayConfigured(this);
185185
}
186186

187187
override async save(group: GroupIdentifier, options?: ISaveOptions): Promise<EditorInput | IUntypedEditorInput | undefined> {

src/vs/workbench/contrib/search/browser/anythingQuickAccess.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { FileQueryCacheState } from 'vs/workbench/contrib/search/common/cacheSta
3737
import { IHistoryService } from 'vs/workbench/services/history/common/history';
3838
import { IEditorOptions, IResourceEditorInput, ITextEditorOptions } from 'vs/platform/editor/common/editor';
3939
import { Schemas } from 'vs/base/common/network';
40-
import { IFilesConfigurationService, AutoSaveMode } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
40+
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
4141
import { ResourceMap } from 'vs/base/common/map';
4242
import { SymbolsQuickAccessProvider } from 'vs/workbench/contrib/search/browser/symbolsQuickAccess';
4343
import { AnythingQuickAccessProviderRunOptions, DefaultQuickAccessFilterValue, Extensions, IQuickAccessRegistry } from 'vs/platform/quickinput/common/quickAccess';
@@ -963,7 +963,7 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
963963
resource = URI.isUri(resourceOrEditor) ? resourceOrEditor : resourceOrEditor.resource;
964964
label = basenameOrAuthority(resource);
965965
description = this.labelService.getUriLabel(dirname(resource), { relative: true });
966-
isDirty = this.workingCopyService.isDirty(resource) && this.filesConfigurationService.getAutoSaveMode(resource) !== AutoSaveMode.AFTER_SHORT_DELAY;
966+
isDirty = this.workingCopyService.isDirty(resource) && !this.filesConfigurationService.isShortAutoSaveDelayConfigured(resource);
967967
extraClasses = [];
968968
}
969969

src/vs/workbench/electron-sandbox/window.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import { ITunnelService, extractLocalHostUriMetaDataForPortMapping } from 'vs/pl
4949
import { IWorkbenchLayoutService, Parts, positionFromString, Position } from 'vs/workbench/services/layout/browser/layoutService';
5050
import { IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService';
5151
import { WorkingCopyCapabilities } from 'vs/workbench/services/workingCopy/common/workingCopy';
52-
import { AutoSaveMode, IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
52+
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
5353
import { Event } from 'vs/base/common/event';
5454
import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';
5555
import { IAddressProvider, IAddress } from 'vs/platform/remote/common/remoteAgentConnection';
@@ -386,7 +386,7 @@ export class NativeWindow extends BaseWindow {
386386
// Document edited: indicate for dirty working copies
387387
this._register(this.workingCopyService.onDidChangeDirty(workingCopy => {
388388
const gotDirty = workingCopy.isDirty();
389-
if (gotDirty && !(workingCopy.capabilities & WorkingCopyCapabilities.Untitled) && this.filesConfigurationService.getAutoSaveMode(workingCopy.resource) === AutoSaveMode.AFTER_SHORT_DELAY) {
389+
if (gotDirty && !(workingCopy.capabilities & WorkingCopyCapabilities.Untitled) && this.filesConfigurationService.isShortAutoSaveDelayConfigured(workingCopy.resource)) {
390390
return; // do not indicate dirty of working copies that are auto saved after short delay
391391
}
392392

0 commit comments

Comments
 (0)