@@ -19,7 +19,6 @@ import { ITextFileService } from 'vs/workbench/services/textfile/common/textfile
19
19
import { IFileService } from 'vs/platform/files/common/files' ;
20
20
import { toResource , SideBySideEditor } from 'vs/workbench/common/editor' ;
21
21
import { ExplorerViewlet } from 'vs/workbench/contrib/files/browser/explorerViewlet' ;
22
- import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService' ;
23
22
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen' ;
24
23
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet' ;
25
24
import { IInstantiationService , ServicesAccessor } from 'vs/platform/instantiation/common/instantiation' ;
@@ -47,6 +46,7 @@ import { onUnexpectedError, getErrorMessage } from 'vs/base/common/errors';
47
46
import { asDomUri , triggerDownload } from 'vs/base/browser/dom' ;
48
47
import { mnemonicButtonLabel } from 'vs/base/common/labels' ;
49
48
import { IAutoSaveConfigurationService } from 'vs/workbench/services/autoSaveConfiguration/common/autoSaveConfigurationService' ;
49
+ import { IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService' ;
50
50
51
51
export const NEW_FILE_COMMAND_ID = 'explorer.newFile' ;
52
52
export const NEW_FILE_LABEL = nls . localize ( 'newFile' , "New File" ) ;
@@ -512,38 +512,30 @@ export abstract class BaseSaveAllAction extends Action {
512
512
constructor (
513
513
id : string ,
514
514
label : string ,
515
- @ITextFileService private readonly textFileService : ITextFileService ,
516
- @IUntitledTextEditorService private readonly untitledTextEditorService : IUntitledTextEditorService ,
517
515
@ICommandService protected commandService : ICommandService ,
518
516
@INotificationService private notificationService : INotificationService ,
517
+ @IWorkingCopyService private readonly workingCopyService : IWorkingCopyService
519
518
) {
520
519
super ( id , label ) ;
521
520
522
- this . lastIsDirty = this . textFileService . isDirty ( ) ;
521
+ this . lastIsDirty = this . workingCopyService . hasDirty ;
523
522
this . enabled = this . lastIsDirty ;
524
523
525
524
this . registerListeners ( ) ;
526
525
}
527
526
528
- protected abstract includeUntitled ( ) : boolean ;
529
527
protected abstract doRun ( context : any ) : Promise < any > ;
530
528
531
529
private registerListeners ( ) : void {
532
530
533
- // listen to files being changed locally
534
- this . _register ( this . textFileService . models . onModelsDirty ( e => this . updateEnablement ( true ) ) ) ;
535
- this . _register ( this . textFileService . models . onModelsSaved ( e => this . updateEnablement ( false ) ) ) ;
536
- this . _register ( this . textFileService . models . onModelsReverted ( e => this . updateEnablement ( false ) ) ) ;
537
- this . _register ( this . textFileService . models . onModelsSaveError ( e => this . updateEnablement ( true ) ) ) ;
538
-
539
- if ( this . includeUntitled ( ) ) {
540
- this . _register ( this . untitledTextEditorService . onDidChangeDirty ( resource => this . updateEnablement ( this . untitledTextEditorService . isDirty ( resource ) ) ) ) ;
541
- }
531
+ // update enablement based on working copy changes
532
+ this . _register ( this . workingCopyService . onDidChangeDirty ( ( ) => this . updateEnablement ( ) ) ) ;
542
533
}
543
534
544
- private updateEnablement ( isDirty : boolean ) : void {
545
- if ( this . lastIsDirty !== isDirty ) {
546
- this . enabled = this . textFileService . isDirty ( ) ;
535
+ private updateEnablement ( ) : void {
536
+ const hasDirty = this . workingCopyService . hasDirty ;
537
+ if ( this . lastIsDirty !== hasDirty ) {
538
+ this . enabled = hasDirty ;
547
539
this . lastIsDirty = this . enabled ;
548
540
}
549
541
}
@@ -569,10 +561,6 @@ export class SaveAllAction extends BaseSaveAllAction {
569
561
protected doRun ( context : any ) : Promise < any > {
570
562
return this . commandService . executeCommand ( SAVE_ALL_COMMAND_ID ) ;
571
563
}
572
-
573
- protected includeUntitled ( ) : boolean {
574
- return true ;
575
- }
576
564
}
577
565
578
566
export class SaveAllInGroupAction extends BaseSaveAllAction {
@@ -587,10 +575,6 @@ export class SaveAllInGroupAction extends BaseSaveAllAction {
587
575
protected doRun ( context : any ) : Promise < any > {
588
576
return this . commandService . executeCommand ( SAVE_ALL_IN_GROUP_COMMAND_ID , { } , context ) ;
589
577
}
590
-
591
- protected includeUntitled ( ) : boolean {
592
- return true ;
593
- }
594
578
}
595
579
596
580
export class CloseGroupAction extends Action {
0 commit comments