|
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, Saveable } 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';
|
@@ -163,6 +163,17 @@ export class EditorCommandContribution implements CommandContribution {
|
163 | 163 | @inject(ResourceProvider)
|
164 | 164 | protected readonly resourceProvider: ResourceProvider;
|
165 | 165 |
|
| 166 | + @postConstruct() |
| 167 | + protected async init(): Promise<void> { |
| 168 | + this.editorPreferences.onPreferenceChanged(e => { |
| 169 | + if (e.preferenceName === 'editor.autoSave' && e.newValue === 'on') { |
| 170 | + this.editorManager.all |
| 171 | + .filter(editor => Saveable.isDirty(editor)) |
| 172 | + .forEach(editor => Saveable.save(editor)); |
| 173 | + } |
| 174 | + }); |
| 175 | + } |
| 176 | + |
166 | 177 | registerCommands(registry: CommandRegistry): void {
|
167 | 178 | registry.registerCommand(EditorCommands.SHOW_REFERENCES);
|
168 | 179 | registry.registerCommand(EditorCommands.CONFIG_INDENTATION);
|
|
0 commit comments