-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Theia runs save on app startup if "editor.autoSave": "on"
is configured in the settings.json
#8722
Comments
This PR causes the undesired side effect. |
Nice, the default auto-save preference is
But editor command ignores this and assumes auto-save if on when not set:
|
Here is a workaround for the time being:
bind(EditorCommandContribution).toSelf().inSingletonScope();
rebind(TheiaEditorCommandContribution).toService(EditorCommandContribution);
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();
}
}
});
}
} |
1 task
4 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I have the following
settings.json
in my workspace and the app starts, a save event will be fired from the editor commands:settings.json
:theia/packages/editor/src/browser/editor-command.ts
Lines 171 to 175 in d660747
Theia incorrectly assumes there was a preference change, but there wasn't. Auto-save is enabled by default, so I would expect the exact same behavior when I have an empty
settings.json
or one with"editor.autoSave": "on"
.Steps to Reproduce:
Additional Information
The text was updated successfully, but these errors were encountered: