mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-10-24 10:38:32 +00:00
22 lines
869 B
TypeScript
22 lines
869 B
TypeScript
import { injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
import { EditorCommandContribution as TheiaEditorCommandContribution } from '@theia/editor/lib/browser/editor-command';
|
|
|
|
@injectable()
|
|
export class EditorCommandContribution extends TheiaEditorCommandContribution {
|
|
@postConstruct()
|
|
protected override init(): void {
|
|
// Workaround for https://github.com/eclipse-theia/theia/issues/8722.
|
|
this.editorPreferences.onPreferenceChanged(
|
|
({ preferenceName, newValue, oldValue }) => {
|
|
if (preferenceName === 'files.autoSave') {
|
|
const autoSaveWasOnBeforeChange = !oldValue || oldValue !== 'off';
|
|
const autoSaveIsOnAfterChange = !newValue || newValue !== 'off';
|
|
if (!autoSaveWasOnBeforeChange && autoSaveIsOnAfterChange) {
|
|
this.shell.saveAll();
|
|
}
|
|
}
|
|
}
|
|
);
|
|
}
|
|
}
|