66import { URI as Uri } from 'vs/base/common/uri' ;
77import { IBackupFileService } from 'vs/workbench/services/backup/common/backup' ;
88import { Disposable } from 'vs/base/common/lifecycle' ;
9- import { ITextFileService , TextFileModelChangeEvent , StateChange } from 'vs/workbench/services/textfile/common/textfiles' ;
9+ import { ITextFileService , TextFileModelChangeEvent , StateChange , IAutoSaveConfiguration } from 'vs/workbench/services/textfile/common/textfiles' ;
1010import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService' ;
1111import { IWorkbenchContribution } from 'vs/workbench/common/contributions' ;
12- import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
13- import { IFilesConfiguration , AutoSaveConfiguration , CONTENT_CHANGE_EVENT_BUFFER_DELAY } from 'vs/platform/files/common/files' ;
12+ import { CONTENT_CHANGE_EVENT_BUFFER_DELAY } from 'vs/platform/files/common/files' ;
1413
1514const AUTO_SAVE_AFTER_DELAY_DISABLED_TIME = CONTENT_CHANGE_EVENT_BUFFER_DELAY + 500 ;
1615
@@ -22,7 +21,6 @@ export class BackupModelTracker extends Disposable implements IWorkbenchContribu
2221 @IBackupFileService private readonly backupFileService : IBackupFileService ,
2322 @ITextFileService private readonly textFileService : ITextFileService ,
2423 @IUntitledEditorService private readonly untitledEditorService : IUntitledEditorService ,
25- @IConfigurationService private readonly configurationService : IConfigurationService
2624 ) {
2725 super ( ) ;
2826
@@ -32,26 +30,20 @@ export class BackupModelTracker extends Disposable implements IWorkbenchContribu
3230 private registerListeners ( ) {
3331
3432 // Listen for text file model changes
35- this . _register ( this . textFileService . models . onModelContentChanged ( ( e ) => this . onTextFileModelChanged ( e ) ) ) ;
36- this . _register ( this . textFileService . models . onModelSaved ( ( e ) => this . discardBackup ( e . resource ) ) ) ;
37- this . _register ( this . textFileService . models . onModelDisposed ( ( e ) => this . discardBackup ( e ) ) ) ;
33+ this . _register ( this . textFileService . models . onModelContentChanged ( e => this . onTextFileModelChanged ( e ) ) ) ;
34+ this . _register ( this . textFileService . models . onModelSaved ( e => this . discardBackup ( e . resource ) ) ) ;
35+ this . _register ( this . textFileService . models . onModelDisposed ( e => this . discardBackup ( e ) ) ) ;
3836
3937 // Listen for untitled model changes
40- this . _register ( this . untitledEditorService . onDidChangeContent ( ( e ) => this . onUntitledModelChanged ( e ) ) ) ;
41- this . _register ( this . untitledEditorService . onDidDisposeModel ( ( e ) => this . discardBackup ( e ) ) ) ;
38+ this . _register ( this . untitledEditorService . onDidChangeContent ( e => this . onUntitledModelChanged ( e ) ) ) ;
39+ this . _register ( this . untitledEditorService . onDidDisposeModel ( e => this . discardBackup ( e ) ) ) ;
4240
4341 // Listen to config changes
44- this . _register ( this . configurationService . onDidChangeConfiguration ( e => this . onConfigurationChange ( this . configurationService . getValue < IFilesConfiguration > ( ) ) ) ) ;
42+ this . _register ( this . textFileService . onAutoSaveConfigurationChange ( c => this . onAutoSaveConfigurationChange ( c ) ) ) ;
4543 }
4644
47- private onConfigurationChange ( configuration : IFilesConfiguration ) : void {
48- if ( ! configuration || ! configuration . files ) {
49- this . configuredAutoSaveAfterDelay = false ;
50-
51- return ;
52- }
53-
54- this . configuredAutoSaveAfterDelay = ( configuration . files . autoSave === AutoSaveConfiguration . AFTER_DELAY && configuration . files . autoSaveDelay <= AUTO_SAVE_AFTER_DELAY_DISABLED_TIME ) ;
45+ private onAutoSaveConfigurationChange ( configuration : IAutoSaveConfiguration ) : void {
46+ this . configuredAutoSaveAfterDelay = typeof configuration . autoSaveDelay === 'number' && configuration . autoSaveDelay < AUTO_SAVE_AFTER_DELAY_DISABLED_TIME ;
5547 }
5648
5749 private onTextFileModelChanged ( event : TextFileModelChangeEvent ) : void {
0 commit comments