Skip to content

Commit

Permalink
Refactor auto save mechanism (#13683)
Browse files Browse the repository at this point in the history
  • Loading branch information
msujew authored May 20, 2024
1 parent 44b4f27 commit d9e58c3
Show file tree
Hide file tree
Showing 24 changed files with 510 additions and 306 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
<a name="breaking_changes_not_yet_released">[Breaking Changes:](#breaking_changes_not_yet_released)</a> -->

## 1.50.0

<a name="breaking_changes_1.50.0">[Breaking Changes:](#breaking_changes_1.50.0)</a>

- [core] Classes implementing the `Saveable` interface no longer need to implement the `autoSave` field. However, a new `onContentChanged` event has been added instead.

## v1.49.0 - 04/29/2024

- [application-manager] added logic to generate Extension Info in server application to avoid empty About Dialog [#13590](https://github.com/eclipse-theia/theia/pull/13590) - contributed on behalf of STMicroelectronics
Expand Down
2 changes: 1 addition & 1 deletion examples/api-tests/src/saveable.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ describe('Saveable', function () {

afterEach(async () => {
toTearDown.dispose();
await preferences.set('files.autoSave', autoSave, undefined, rootUri.toString());
// @ts-ignore
editor = undefined;
// @ts-ignore
widget = undefined;
await editorManager.closeAll({ save: false });
await fileService.delete(fileUri.parent, { fromUserGesture: false, useTrash: false, recursive: true });
await preferences.set('files.autoSave', autoSave, undefined, rootUri.toString());
});

it('normal save', async function () {
Expand Down
9 changes: 5 additions & 4 deletions examples/api-tests/src/typescript.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('TypeScript', function () {
const rootUri = workspaceService.tryGetRoots()[0].resource;
const demoFileUri = rootUri.resolveToAbsolute('../api-tests/test-ts-workspace/demo-file.ts');
const definitionFileUri = rootUri.resolveToAbsolute('../api-tests/test-ts-workspace/demo-definitions-file.ts');
let originalAutoSaveValue = preferences.inspect('files.autoSave').globalValue;
let originalAutoSaveValue = preferences.get('files.autoSave');

before(async function () {
await pluginService.didStart;
Expand All @@ -73,8 +73,9 @@ describe('TypeScript', function () {
throw new Error(pluginId + ' should be started');
}
await pluginService.activatePlugin(pluginId);
}).concat(preferences.set('files.autoSave', 'off', PreferenceScope.User)));
await preferences.set('files.refactoring.autoSave', 'off', PreferenceScope.User);
}));
await preferences.set('files.autoSave', 'off');
await preferences.set('files.refactoring.autoSave', 'off');
});

beforeEach(async function () {
Expand All @@ -90,7 +91,7 @@ describe('TypeScript', function () {
});

after(async () => {
await preferences.set('files.autoSave', originalAutoSaveValue, PreferenceScope.User);
await preferences.set('files.autoSave', originalAutoSaveValue);
})

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/browser/common-frontend-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import { WindowService } from './window/window-service';
import { FrontendApplicationConfigProvider } from './frontend-application-config-provider';
import { DecorationStyle } from './decoration-style';
import { isPinned, Title, togglePinned, Widget } from './widgets';
import { SaveResourceService } from './save-resource-service';
import { SaveableService } from './saveable-service';
import { UserWorkingDirectoryProvider } from './user-working-directory-provider';
import { UNTITLED_SCHEME, UntitledResourceResolver } from '../common';
import { LanguageQuickPickService } from './i18n/language-quick-pick-service';
Expand Down Expand Up @@ -385,7 +385,7 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
@inject(OpenerService) protected readonly openerService: OpenerService,
@inject(AboutDialog) protected readonly aboutDialog: AboutDialog,
@inject(AsyncLocalizationProvider) protected readonly localizationProvider: AsyncLocalizationProvider,
@inject(SaveResourceService) protected readonly saveResourceService: SaveResourceService,
@inject(SaveableService) protected readonly saveResourceService: SaveableService,
) { }

@inject(ContextKeyService)
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/browser/frontend-application-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ import { DockPanel, RendererHost } from './widgets';
import { TooltipService, TooltipServiceImpl } from './tooltip-service';
import { BackendRequestService, RequestService, REQUEST_SERVICE_PATH } from '@theia/request';
import { bindFrontendStopwatch, bindBackendStopwatch } from './performance';
import { SaveResourceService } from './save-resource-service';
import { SaveableService } from './saveable-service';
import { SecondaryWindowHandler } from './secondary-window-handler';
import { UserWorkingDirectoryProvider } from './user-working-directory-provider';
import { WindowTitleService } from './window/window-title-service';
Expand Down Expand Up @@ -449,7 +449,9 @@ export const frontendApplicationModule = new ContainerModule((bind, _unbind, _is
bindFrontendStopwatch(bind);
bindBackendStopwatch(bind);

bind(SaveResourceService).toSelf().inSingletonScope();
bind(SaveableService).toSelf().inSingletonScope();
bind(FrontendApplicationContribution).toService(SaveableService);

bind(UserWorkingDirectoryProvider).toSelf().inSingletonScope();
bind(FrontendApplicationContribution).toService(UserWorkingDirectoryProvider);

Expand Down
1 change: 1 addition & 0 deletions packages/core/src/browser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ export * from './tooltip-service';
export * from './decoration-style';
export * from './styling-service';
export * from './hover-service';
export * from './saveable-service';
60 changes: 0 additions & 60 deletions packages/core/src/browser/save-resource-service.ts

This file was deleted.

Loading

0 comments on commit d9e58c3

Please sign in to comment.