14
14
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
********************************************************************************/
16
16
17
- import { inject , injectable } from 'inversify' ;
17
+ import { inject , injectable , postConstruct } from 'inversify' ;
18
18
import { CommandContribution , CommandRegistry , Command } from '@theia/core/lib/common' ;
19
19
import URI from '@theia/core/lib/common/uri' ;
20
- import { CommonCommands , PreferenceService , QuickPickItem , QuickPickService , LabelProvider , QuickPickValue } from '@theia/core/lib/browser' ;
20
+ import { CommonCommands , PreferenceService , QuickPickItem , QuickPickService , LabelProvider , QuickPickValue , ApplicationShell } from '@theia/core/lib/browser' ;
21
21
import { Languages , Language } from '@theia/languages/lib/browser' ;
22
22
import { EditorManager } from './editor-manager' ;
23
23
import { EncodingMode } from './editor' ;
@@ -140,6 +140,9 @@ export class EditorCommandContribution implements CommandContribution {
140
140
141
141
public static readonly AUTOSAVE_PREFERENCE : string = 'editor.autoSave' ;
142
142
143
+ @inject ( ApplicationShell )
144
+ protected readonly shell : ApplicationShell ;
145
+
143
146
@inject ( PreferenceService )
144
147
protected readonly preferencesService : PreferenceService ;
145
148
@@ -163,6 +166,17 @@ export class EditorCommandContribution implements CommandContribution {
163
166
@inject ( ResourceProvider )
164
167
protected readonly resourceProvider : ResourceProvider ;
165
168
169
+ @postConstruct ( )
170
+ protected init ( ) : void {
171
+ this . editorPreferences . onPreferenceChanged ( e => {
172
+ if ( e . preferenceName === 'editor.autoSave' ) {
173
+ if ( this . isAutoSaveOn ( ) ) {
174
+ this . shell . saveAll ( ) ;
175
+ }
176
+ }
177
+ } ) ;
178
+ }
179
+
166
180
registerCommands ( registry : CommandRegistry ) : void {
167
181
registry . registerCommand ( EditorCommands . SHOW_REFERENCES ) ;
168
182
registry . registerCommand ( EditorCommands . CONFIG_INDENTATION ) ;
0 commit comments