@@ -15,8 +15,6 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
15
15
import { IEditorInput , Verbosity } from 'vs/workbench/common/editor' ;
16
16
import { SaveAllAction , SaveAllInGroupAction , CloseGroupAction } from 'vs/workbench/contrib/files/browser/fileActions' ;
17
17
import { OpenEditorsFocusedContext , ExplorerFocusedContext , IFilesConfiguration , OpenEditor } from 'vs/workbench/contrib/files/common/files' ;
18
- import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles' ;
19
- import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService' ;
20
18
import { CloseAllEditorsAction , CloseEditorAction } from 'vs/workbench/browser/parts/editor/editorActions' ;
21
19
import { ToggleEditorLayoutAction } from 'vs/workbench/browser/actions/layoutActions' ;
22
20
import { IContextKeyService , IContextKey } from 'vs/platform/contextkey/common/contextkey' ;
@@ -43,7 +41,7 @@ import { ElementsDragAndDropData, DesktopDragAndDropData } from 'vs/base/browser
43
41
import { URI } from 'vs/base/common/uri' ;
44
42
import { withNullAsUndefined , withUndefinedAsNull } from 'vs/base/common/types' ;
45
43
import { isWeb } from 'vs/base/common/platform' ;
46
- import { IAutoSaveConfigurationService , AutoSaveMode } from 'vs/workbench/services/autoSaveConfiguration /common/autoSaveConfigurationService ' ;
44
+ import { IWorkingCopyService } from 'vs/workbench/services/workingCopy /common/workingCopyService ' ;
47
45
48
46
const $ = dom . $ ;
49
47
@@ -68,17 +66,15 @@ export class OpenEditorsView extends ViewletPanel {
68
66
options : IViewletViewOptions ,
69
67
@IInstantiationService private readonly instantiationService : IInstantiationService ,
70
68
@IContextMenuService contextMenuService : IContextMenuService ,
71
- @ITextFileService private readonly textFileService : ITextFileService ,
72
69
@IEditorService private readonly editorService : IEditorService ,
73
70
@IEditorGroupsService private readonly editorGroupService : IEditorGroupsService ,
74
71
@IConfigurationService configurationService : IConfigurationService ,
75
72
@IKeybindingService keybindingService : IKeybindingService ,
76
- @IUntitledTextEditorService private readonly untitledTextEditorService : IUntitledTextEditorService ,
77
73
@IContextKeyService private readonly contextKeyService : IContextKeyService ,
78
74
@IThemeService private readonly themeService : IThemeService ,
79
75
@ITelemetryService private readonly telemetryService : ITelemetryService ,
80
76
@IMenuService private readonly menuService : IMenuService ,
81
- @IAutoSaveConfigurationService private readonly autoSaveConfigurationService : IAutoSaveConfigurationService
77
+ @IWorkingCopyService private readonly workingCopyService : IWorkingCopyService
82
78
) {
83
79
super ( {
84
80
...( options as IViewletPanelOptions ) ,
@@ -102,11 +98,7 @@ export class OpenEditorsView extends ViewletPanel {
102
98
this . _register ( this . configurationService . onDidChangeConfiguration ( e => this . onConfigurationChange ( e ) ) ) ;
103
99
104
100
// Handle dirty counter
105
- this . _register ( this . untitledTextEditorService . onDidChangeDirty ( ( ) => this . updateDirtyIndicator ( ) ) ) ;
106
- this . _register ( this . textFileService . models . onModelsDirty ( ( ) => this . updateDirtyIndicator ( ) ) ) ;
107
- this . _register ( this . textFileService . models . onModelsSaved ( ( ) => this . updateDirtyIndicator ( ) ) ) ;
108
- this . _register ( this . textFileService . models . onModelsSaveError ( ( ) => this . updateDirtyIndicator ( ) ) ) ;
109
- this . _register ( this . textFileService . models . onModelsReverted ( ( ) => this . updateDirtyIndicator ( ) ) ) ;
101
+ this . _register ( this . workingCopyService . onDidChangeDirty ( ( ) => this . updateDirtyIndicator ( ) ) ) ;
110
102
}
111
103
112
104
private registerUpdateEvents ( ) : void {
@@ -248,7 +240,7 @@ export class OpenEditorsView extends ViewletPanel {
248
240
const element = e . elements . length ? e . elements [ 0 ] : undefined ;
249
241
if ( element instanceof OpenEditor ) {
250
242
const resource = element . getResource ( ) ;
251
- this . dirtyEditorFocusedContext . set ( this . textFileService . isDirty ( resource ) ) ;
243
+ this . dirtyEditorFocusedContext . set ( element . editor . isDirty ( ) ) ;
252
244
this . resourceContext . set ( withUndefinedAsNull ( resource ) ) ;
253
245
} else if ( ! ! element ) {
254
246
this . groupFocusedContext . set ( true ) ;
@@ -415,8 +407,7 @@ export class OpenEditorsView extends ViewletPanel {
415
407
}
416
408
417
409
private updateDirtyIndicator ( ) : void {
418
- let dirty = this . autoSaveConfigurationService . getAutoSaveMode ( ) !== AutoSaveMode . AFTER_SHORT_DELAY ? this . textFileService . getDirty ( ) . length
419
- : this . untitledTextEditorService . getDirty ( ) . length ;
410
+ let dirty = this . dirtyCount ;
420
411
if ( dirty === 0 ) {
421
412
dom . addClass ( this . dirtyCountElement , 'hidden' ) ;
422
413
} else {
@@ -425,6 +416,18 @@ export class OpenEditorsView extends ViewletPanel {
425
416
}
426
417
}
427
418
419
+ private get dirtyCount ( ) : number {
420
+ let dirtyCount = 0 ;
421
+
422
+ for ( const element of this . elements ) {
423
+ if ( element instanceof OpenEditor && element . editor . isDirty ( ) ) {
424
+ dirtyCount ++ ;
425
+ }
426
+ }
427
+
428
+ return dirtyCount ;
429
+ }
430
+
428
431
private get elementCount ( ) : number {
429
432
return this . editorGroupService . groups . map ( g => g . count )
430
433
. reduce ( ( first , second ) => first + second , this . showGroups ? this . editorGroupService . groups . length : 0 ) ;
0 commit comments