Added a workaround for Theia's auto-save issue.

Ref: eclipse-theia/theia#8722
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta
2020-11-06 11:32:47 +01:00
committed by Akos Kitta
parent ca1b288706
commit 2e00e2db35
2 changed files with 28 additions and 1 deletions

View File

@@ -0,0 +1,21 @@
import { injectable, postConstruct } from 'inversify';
import { EditorCommandContribution as TheiaEditorCommandContribution } from '@theia/editor/lib/browser/editor-command';
@injectable()
export class EditorCommandContribution extends TheiaEditorCommandContribution {
@postConstruct()
protected init(): void {
// Workaround for https://github.com/eclipse-theia/theia/issues/8722.
this.editorPreferences.onPreferenceChanged(({ preferenceName, newValue, oldValue }) => {
if (preferenceName === 'editor.autoSave') {
const autoSaveWasOnBeforeChange = !oldValue || oldValue === 'on';
const autoSaveIsOnAfterChange = !newValue || newValue === 'on';
if (!autoSaveWasOnBeforeChange && autoSaveIsOnAfterChange) {
this.shell.saveAll();
}
}
});
}
}