@@ -9,7 +9,6 @@ import { IFilesConfigurationService, AutoSaveMode } from 'vs/workbench/services/
9
9
import { IHostService } from 'vs/workbench/services/host/browser/host' ;
10
10
import { SaveReason , IEditorIdentifier , IEditorInput , GroupIdentifier } from 'vs/workbench/common/editor' ;
11
11
import { IEditorService } from 'vs/workbench/services/editor/common/editorService' ;
12
- import { ICodeEditor , isCodeEditor , isDiffEditor } from 'vs/editor/browser/editorBrowser' ;
13
12
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService' ;
14
13
import { withNullAsUndefined } from 'vs/base/common/types' ;
15
14
@@ -57,19 +56,11 @@ export class EditorAutoSave extends Disposable implements IWorkbenchContribution
57
56
this . lastActiveEditorControlDisposable . clear ( ) ;
58
57
59
58
// Listen to focus changes on control for auto save
60
- if ( activeGroup && activeEditor ) {
61
- const activeTextEditorWidget = this . editorService . activeTextEditorWidget ;
62
- const controlsToObserve : ICodeEditor [ ] = [ ] ;
63
-
64
- if ( isCodeEditor ( activeTextEditorWidget ) ) {
65
- controlsToObserve . push ( activeTextEditorWidget ) ;
66
- } else if ( isDiffEditor ( activeTextEditorWidget ) ) {
67
- controlsToObserve . push ( activeTextEditorWidget . getOriginalEditor ( ) , activeTextEditorWidget . getModifiedEditor ( ) ) ;
68
- }
69
-
70
- controlsToObserve . forEach ( control => this . lastActiveEditorControlDisposable . add ( control . onDidBlurEditorWidget ( ( ) => {
59
+ const activeEditorControl = this . editorService . activeControl ;
60
+ if ( activeEditor && activeEditorControl ) {
61
+ this . lastActiveEditorControlDisposable . add ( activeEditorControl . onDidBlur ( ( ) => {
71
62
this . maybeTriggerAutoSave ( SaveReason . FOCUS_CHANGE , { groupId : activeGroup . id , editor : activeEditor } ) ;
72
- } ) ) ) ;
63
+ } ) ) ;
73
64
}
74
65
}
75
66
@@ -78,10 +69,9 @@ export class EditorAutoSave extends Disposable implements IWorkbenchContribution
78
69
return ; // no auto save for readonly or untitled editors
79
70
}
80
71
72
+ // Determine if we need to save all. In case of a window focus change we also save if
73
+ // auto save mode is configured to be ON_FOCUS_CHANGE (editor focus change)
81
74
const mode = this . filesConfigurationService . getAutoSaveMode ( ) ;
82
-
83
- // Determine if we need to save all. In case of a window focus change we also save if auto save mode
84
- // is configured to be ON_FOCUS_CHANGE (editor focus change)
85
75
if (
86
76
( reason === SaveReason . WINDOW_CHANGE && ( mode === AutoSaveMode . ON_FOCUS_CHANGE || mode === AutoSaveMode . ON_WINDOW_CHANGE ) ) ||
87
77
( reason === SaveReason . FOCUS_CHANGE && mode === AutoSaveMode . ON_FOCUS_CHANGE )
0 commit comments