@theia/preferences 1.53.0-next.55 → 1.53.0-next.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +81 -81
- package/package.json +8 -8
- package/src/browser/abstract-resource-preference-provider.spec.ts +95 -95
- package/src/browser/abstract-resource-preference-provider.ts +232 -232
- package/src/browser/folder-preference-provider.ts +58 -58
- package/src/browser/folders-preferences-provider.ts +244 -244
- package/src/browser/index.ts +23 -23
- package/src/browser/monaco-jsonc-editor.ts +67 -67
- package/src/browser/package.spec.ts +28 -28
- package/src/browser/preference-bindings.ts +65 -65
- package/src/browser/preference-frontend-contribution.ts +38 -38
- package/src/browser/preference-frontend-module.ts +66 -66
- package/src/browser/preference-open-handler.ts +53 -53
- package/src/browser/preference-transaction-manager.ts +287 -287
- package/src/browser/preference-tree-model.ts +260 -260
- package/src/browser/preferences-contribution.ts +263 -263
- package/src/browser/preferences-json-schema-contribution.ts +86 -86
- package/src/browser/preferences-monaco-contribution.ts +27 -27
- package/src/browser/section-preference-provider.ts +83 -83
- package/src/browser/style/index.css +506 -506
- package/src/browser/style/preference-array.css +94 -94
- package/src/browser/style/preference-context-menu.css +74 -74
- package/src/browser/style/preference-file.css +31 -31
- package/src/browser/style/preference-object.css +49 -49
- package/src/browser/style/search-input.css +66 -66
- package/src/browser/user-configs-preference-provider.ts +127 -127
- package/src/browser/user-preference-provider.ts +35 -35
- package/src/browser/util/preference-layout.ts +381 -381
- package/src/browser/util/preference-scope-command-manager.ts +75 -75
- package/src/browser/util/preference-tree-generator.ts +260 -260
- package/src/browser/util/preference-tree-label-provider.spec.ts +110 -110
- package/src/browser/util/preference-tree-label-provider.ts +72 -72
- package/src/browser/util/preference-types.ts +177 -177
- package/src/browser/views/components/preference-array-input.ts +174 -174
- package/src/browser/views/components/preference-boolean-input.ts +69 -69
- package/src/browser/views/components/preference-file-input.ts +104 -104
- package/src/browser/views/components/preference-json-input.ts +78 -78
- package/src/browser/views/components/preference-markdown-renderer.ts +68 -68
- package/src/browser/views/components/preference-node-renderer-creator.ts +141 -141
- package/src/browser/views/components/preference-node-renderer.ts +477 -477
- package/src/browser/views/components/preference-number-input.ts +147 -147
- package/src/browser/views/components/preference-select-input.ts +131 -131
- package/src/browser/views/components/preference-string-input.ts +76 -76
- package/src/browser/views/preference-editor-widget.ts +349 -349
- package/src/browser/views/preference-scope-tabbar-widget.tsx +344 -344
- package/src/browser/views/preference-searchbar-widget.tsx +183 -183
- package/src/browser/views/preference-tree-widget.tsx +102 -102
- package/src/browser/views/preference-widget-bindings.ts +102 -102
- package/src/browser/views/preference-widget.tsx +118 -118
- package/src/browser/workspace-file-preference-provider.ts +100 -100
- package/src/browser/workspace-preference-provider.ts +134 -134
- package/src/common/cli-preferences.ts +22 -22
- package/src/node/preference-backend-module.ts +33 -33
- package/src/node/preference-cli-contribution.ts +48 -48
package/README.md
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
<div align='center'>
|
|
2
|
-
|
|
3
|
-
<br />
|
|
4
|
-
|
|
5
|
-
<img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
|
|
6
|
-
|
|
7
|
-
<h2>ECLIPSE THEIA - PREFERENCES EXTENSION</h2>
|
|
8
|
-
|
|
9
|
-
<hr />
|
|
10
|
-
|
|
11
|
-
</div>
|
|
12
|
-
|
|
13
|
-
## Description
|
|
14
|
-
|
|
15
|
-
The `@theia/preferences` extension implements the preferences API defined in `@theia/core`, including the four preference providers:
|
|
16
|
-
- `Default` Preference, which serves as default values of preferences,
|
|
17
|
-
- `User` Preference for the user home directory, which has precedence over the default values,
|
|
18
|
-
- `Workspace` Preference for the workspace, which has precedence over User Preference, and
|
|
19
|
-
- `Folder` Preference for the root folder, which has precedence over the Workspace Preference
|
|
20
|
-
|
|
21
|
-
To set:
|
|
22
|
-
- `User` Preferences: Create or edit a `settings.json` under the `.theia` folder located either in the user home.
|
|
23
|
-
- `Workspace` Preference: If one folder is opened as the workspace, create or edit a `settings.json` under the root of the workspace. If a multi-root workspace is opened, create or edit the "settings" property in the workspace file.
|
|
24
|
-
- `Folder` Preferences: Create or edit a `settings.json` under any of the root folders.
|
|
25
|
-
|
|
26
|
-
Example of a `settings.json` below:
|
|
27
|
-
|
|
28
|
-
```typescript
|
|
29
|
-
{
|
|
30
|
-
// Enable/Disable the line numbers in the monaco editor
|
|
31
|
-
"editor.lineNumbers": "off",
|
|
32
|
-
// Tab width in the editor
|
|
33
|
-
"editor.tabSize": 4,
|
|
34
|
-
"files.watcherExclude": "path/to/file"
|
|
35
|
-
}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
Example of a workspace file below:
|
|
39
|
-
|
|
40
|
-
```typescript
|
|
41
|
-
{
|
|
42
|
-
"folders": [
|
|
43
|
-
{
|
|
44
|
-
"path": "file:///home/username/helloworld"
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"path": "file:///home/username/dev/byeworld"
|
|
48
|
-
}
|
|
49
|
-
],
|
|
50
|
-
"settings": {
|
|
51
|
-
// Enable/Disable the line numbers in the monaco editor
|
|
52
|
-
"editor.lineNumbers": "off",
|
|
53
|
-
// Tab width in the editor
|
|
54
|
-
"editor.tabSize": 4,
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Additional Information
|
|
60
|
-
|
|
61
|
-
- [API documentation for `@theia/preferences`](https://eclipse-theia.github.io/theia/docs/next/modules/preferences.html)
|
|
62
|
-
- [Theia - GitHub](https://github.com/eclipse-theia/theia)
|
|
63
|
-
- [Theia - Website](https://theia-ide.org/)
|
|
64
|
-
|
|
65
|
-
## License
|
|
66
|
-
|
|
67
|
-
- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
|
|
68
|
-
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
|
|
69
|
-
|
|
70
|
-
## Trademark
|
|
71
|
-
"Theia" is a trademark of the Eclipse Foundation
|
|
72
|
-
https://www.eclipse.org/theia
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
# Theia - Preferences Extension
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
## License
|
|
80
|
-
- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
|
|
81
|
-
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
|
|
1
|
+
<div align='center'>
|
|
2
|
+
|
|
3
|
+
<br />
|
|
4
|
+
|
|
5
|
+
<img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
|
|
6
|
+
|
|
7
|
+
<h2>ECLIPSE THEIA - PREFERENCES EXTENSION</h2>
|
|
8
|
+
|
|
9
|
+
<hr />
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
## Description
|
|
14
|
+
|
|
15
|
+
The `@theia/preferences` extension implements the preferences API defined in `@theia/core`, including the four preference providers:
|
|
16
|
+
- `Default` Preference, which serves as default values of preferences,
|
|
17
|
+
- `User` Preference for the user home directory, which has precedence over the default values,
|
|
18
|
+
- `Workspace` Preference for the workspace, which has precedence over User Preference, and
|
|
19
|
+
- `Folder` Preference for the root folder, which has precedence over the Workspace Preference
|
|
20
|
+
|
|
21
|
+
To set:
|
|
22
|
+
- `User` Preferences: Create or edit a `settings.json` under the `.theia` folder located either in the user home.
|
|
23
|
+
- `Workspace` Preference: If one folder is opened as the workspace, create or edit a `settings.json` under the root of the workspace. If a multi-root workspace is opened, create or edit the "settings" property in the workspace file.
|
|
24
|
+
- `Folder` Preferences: Create or edit a `settings.json` under any of the root folders.
|
|
25
|
+
|
|
26
|
+
Example of a `settings.json` below:
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
{
|
|
30
|
+
// Enable/Disable the line numbers in the monaco editor
|
|
31
|
+
"editor.lineNumbers": "off",
|
|
32
|
+
// Tab width in the editor
|
|
33
|
+
"editor.tabSize": 4,
|
|
34
|
+
"files.watcherExclude": "path/to/file"
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Example of a workspace file below:
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
{
|
|
42
|
+
"folders": [
|
|
43
|
+
{
|
|
44
|
+
"path": "file:///home/username/helloworld"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"path": "file:///home/username/dev/byeworld"
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"settings": {
|
|
51
|
+
// Enable/Disable the line numbers in the monaco editor
|
|
52
|
+
"editor.lineNumbers": "off",
|
|
53
|
+
// Tab width in the editor
|
|
54
|
+
"editor.tabSize": 4,
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Additional Information
|
|
60
|
+
|
|
61
|
+
- [API documentation for `@theia/preferences`](https://eclipse-theia.github.io/theia/docs/next/modules/preferences.html)
|
|
62
|
+
- [Theia - GitHub](https://github.com/eclipse-theia/theia)
|
|
63
|
+
- [Theia - Website](https://theia-ide.org/)
|
|
64
|
+
|
|
65
|
+
## License
|
|
66
|
+
|
|
67
|
+
- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
|
|
68
|
+
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
|
|
69
|
+
|
|
70
|
+
## Trademark
|
|
71
|
+
"Theia" is a trademark of the Eclipse Foundation
|
|
72
|
+
https://www.eclipse.org/theia
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
# Theia - Preferences Extension
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
|
|
81
|
+
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/preferences",
|
|
3
|
-
"version": "1.53.0-next.
|
|
3
|
+
"version": "1.53.0-next.64+23b351d26",
|
|
4
4
|
"description": "Theia - Preferences Extension",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/core": "1.53.0-next.
|
|
7
|
-
"@theia/editor": "1.53.0-next.
|
|
8
|
-
"@theia/filesystem": "1.53.0-next.
|
|
9
|
-
"@theia/monaco": "1.53.0-next.
|
|
6
|
+
"@theia/core": "1.53.0-next.64+23b351d26",
|
|
7
|
+
"@theia/editor": "1.53.0-next.64+23b351d26",
|
|
8
|
+
"@theia/filesystem": "1.53.0-next.64+23b351d26",
|
|
9
|
+
"@theia/monaco": "1.53.0-next.64+23b351d26",
|
|
10
10
|
"@theia/monaco-editor-core": "1.83.101",
|
|
11
|
-
"@theia/userstorage": "1.53.0-next.
|
|
12
|
-
"@theia/workspace": "1.53.0-next.
|
|
11
|
+
"@theia/userstorage": "1.53.0-next.64+23b351d26",
|
|
12
|
+
"@theia/workspace": "1.53.0-next.64+23b351d26",
|
|
13
13
|
"async-mutex": "^0.3.1",
|
|
14
14
|
"fast-deep-equal": "^3.1.3",
|
|
15
15
|
"jsonc-parser": "^2.2.0",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"nyc": {
|
|
56
56
|
"extends": "../../configs/nyc.json"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "23b351d26346a2b5d6aca3ee81fba59c056132f7"
|
|
59
59
|
}
|
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2021 Ericsson and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
18
|
-
|
|
19
|
-
import { enableJSDOM } from '@theia/core/lib/browser/test/jsdom';
|
|
20
|
-
const disableJSDOM = enableJSDOM();
|
|
21
|
-
|
|
22
|
-
import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider';
|
|
23
|
-
FrontendApplicationConfigProvider.set({});
|
|
24
|
-
|
|
25
|
-
import { expect } from 'chai';
|
|
26
|
-
import { Container } from '@theia/core/shared/inversify';
|
|
27
|
-
import { AbstractResourcePreferenceProvider } from './abstract-resource-preference-provider';
|
|
28
|
-
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
29
|
-
import { bindPreferenceService } from '@theia/core/lib/browser/frontend-application-bindings';
|
|
30
|
-
import { bindMockPreferenceProviders } from '@theia/core/lib/browser/preferences/test';
|
|
31
|
-
import { Deferred } from '@theia/core/lib/common/promise-util';
|
|
32
|
-
import { Disposable, MessageService } from '@theia/core/lib/common';
|
|
33
|
-
import { MonacoWorkspace } from '@theia/monaco/lib/browser/monaco-workspace';
|
|
34
|
-
import { PreferenceSchemaProvider } from '@theia/core/lib/browser';
|
|
35
|
-
import { EditorManager } from '@theia/editor/lib/browser';
|
|
36
|
-
import { PreferenceTransactionFactory } from './preference-transaction-manager';
|
|
37
|
-
|
|
38
|
-
disableJSDOM();
|
|
39
|
-
|
|
40
|
-
class MockFileService {
|
|
41
|
-
releaseContent = new Deferred();
|
|
42
|
-
async read(): Promise<{ value: string }> {
|
|
43
|
-
await this.releaseContent.promise;
|
|
44
|
-
return { value: JSON.stringify({ 'editor.fontSize': 20 }) };
|
|
45
|
-
}
|
|
46
|
-
watch = RETURN_DISPOSABLE;
|
|
47
|
-
onDidFilesChange = RETURN_DISPOSABLE;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const RETURN_DISPOSABLE = () => Disposable.NULL;
|
|
51
|
-
|
|
52
|
-
const mockSchemaProvider = { getCombinedSchema: () => ({ properties: {} }) };
|
|
53
|
-
|
|
54
|
-
class LessAbstractPreferenceProvider extends AbstractResourcePreferenceProvider {
|
|
55
|
-
getUri(): any { }
|
|
56
|
-
getScope(): any { }
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
describe('AbstractResourcePreferenceProvider', () => {
|
|
60
|
-
let provider: AbstractResourcePreferenceProvider;
|
|
61
|
-
let fileService: MockFileService;
|
|
62
|
-
|
|
63
|
-
beforeEach(() => {
|
|
64
|
-
fileService = new MockFileService();
|
|
65
|
-
const testContainer = new Container();
|
|
66
|
-
bindPreferenceService(testContainer.bind.bind(testContainer));
|
|
67
|
-
bindMockPreferenceProviders(testContainer.bind.bind(testContainer), testContainer.unbind.bind(testContainer));
|
|
68
|
-
testContainer.rebind(<any>PreferenceSchemaProvider).toConstantValue(mockSchemaProvider);
|
|
69
|
-
testContainer.bind(<any>FileService).toConstantValue(fileService);
|
|
70
|
-
testContainer.bind(<any>MessageService).toConstantValue(undefined);
|
|
71
|
-
testContainer.bind(<any>MonacoWorkspace).toConstantValue(undefined);
|
|
72
|
-
testContainer.bind(<any>EditorManager).toConstantValue(undefined);
|
|
73
|
-
testContainer.bind(<any>PreferenceTransactionFactory).toConstantValue(undefined);
|
|
74
|
-
provider = testContainer.resolve(<any>LessAbstractPreferenceProvider);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('should not store any preferences before it is ready.', async () => {
|
|
78
|
-
const resolveWhenFinished = new Deferred();
|
|
79
|
-
const errorIfReadyFirst = provider.ready.then(() => Promise.reject());
|
|
80
|
-
|
|
81
|
-
expect(provider.get('editor.fontSize')).to.be.undefined;
|
|
82
|
-
|
|
83
|
-
resolveWhenFinished.resolve();
|
|
84
|
-
fileService.releaseContent.resolve(); // Allow the initialization to run
|
|
85
|
-
|
|
86
|
-
// This promise would reject if the provider had declared itself ready before we resolve `resolveWhenFinished`
|
|
87
|
-
await Promise.race([resolveWhenFinished.promise, errorIfReadyFirst]);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('should report values in file when `ready` resolves.', async () => {
|
|
91
|
-
fileService.releaseContent.resolve();
|
|
92
|
-
await provider.ready;
|
|
93
|
-
expect(provider.get('editor.fontSize')).to.equal(20); // The value provided by the mock FileService implementation.
|
|
94
|
-
});
|
|
95
|
-
});
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2021 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
18
|
+
|
|
19
|
+
import { enableJSDOM } from '@theia/core/lib/browser/test/jsdom';
|
|
20
|
+
const disableJSDOM = enableJSDOM();
|
|
21
|
+
|
|
22
|
+
import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider';
|
|
23
|
+
FrontendApplicationConfigProvider.set({});
|
|
24
|
+
|
|
25
|
+
import { expect } from 'chai';
|
|
26
|
+
import { Container } from '@theia/core/shared/inversify';
|
|
27
|
+
import { AbstractResourcePreferenceProvider } from './abstract-resource-preference-provider';
|
|
28
|
+
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
29
|
+
import { bindPreferenceService } from '@theia/core/lib/browser/frontend-application-bindings';
|
|
30
|
+
import { bindMockPreferenceProviders } from '@theia/core/lib/browser/preferences/test';
|
|
31
|
+
import { Deferred } from '@theia/core/lib/common/promise-util';
|
|
32
|
+
import { Disposable, MessageService } from '@theia/core/lib/common';
|
|
33
|
+
import { MonacoWorkspace } from '@theia/monaco/lib/browser/monaco-workspace';
|
|
34
|
+
import { PreferenceSchemaProvider } from '@theia/core/lib/browser';
|
|
35
|
+
import { EditorManager } from '@theia/editor/lib/browser';
|
|
36
|
+
import { PreferenceTransactionFactory } from './preference-transaction-manager';
|
|
37
|
+
|
|
38
|
+
disableJSDOM();
|
|
39
|
+
|
|
40
|
+
class MockFileService {
|
|
41
|
+
releaseContent = new Deferred();
|
|
42
|
+
async read(): Promise<{ value: string }> {
|
|
43
|
+
await this.releaseContent.promise;
|
|
44
|
+
return { value: JSON.stringify({ 'editor.fontSize': 20 }) };
|
|
45
|
+
}
|
|
46
|
+
watch = RETURN_DISPOSABLE;
|
|
47
|
+
onDidFilesChange = RETURN_DISPOSABLE;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const RETURN_DISPOSABLE = () => Disposable.NULL;
|
|
51
|
+
|
|
52
|
+
const mockSchemaProvider = { getCombinedSchema: () => ({ properties: {} }) };
|
|
53
|
+
|
|
54
|
+
class LessAbstractPreferenceProvider extends AbstractResourcePreferenceProvider {
|
|
55
|
+
getUri(): any { }
|
|
56
|
+
getScope(): any { }
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
describe('AbstractResourcePreferenceProvider', () => {
|
|
60
|
+
let provider: AbstractResourcePreferenceProvider;
|
|
61
|
+
let fileService: MockFileService;
|
|
62
|
+
|
|
63
|
+
beforeEach(() => {
|
|
64
|
+
fileService = new MockFileService();
|
|
65
|
+
const testContainer = new Container();
|
|
66
|
+
bindPreferenceService(testContainer.bind.bind(testContainer));
|
|
67
|
+
bindMockPreferenceProviders(testContainer.bind.bind(testContainer), testContainer.unbind.bind(testContainer));
|
|
68
|
+
testContainer.rebind(<any>PreferenceSchemaProvider).toConstantValue(mockSchemaProvider);
|
|
69
|
+
testContainer.bind(<any>FileService).toConstantValue(fileService);
|
|
70
|
+
testContainer.bind(<any>MessageService).toConstantValue(undefined);
|
|
71
|
+
testContainer.bind(<any>MonacoWorkspace).toConstantValue(undefined);
|
|
72
|
+
testContainer.bind(<any>EditorManager).toConstantValue(undefined);
|
|
73
|
+
testContainer.bind(<any>PreferenceTransactionFactory).toConstantValue(undefined);
|
|
74
|
+
provider = testContainer.resolve(<any>LessAbstractPreferenceProvider);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('should not store any preferences before it is ready.', async () => {
|
|
78
|
+
const resolveWhenFinished = new Deferred();
|
|
79
|
+
const errorIfReadyFirst = provider.ready.then(() => Promise.reject());
|
|
80
|
+
|
|
81
|
+
expect(provider.get('editor.fontSize')).to.be.undefined;
|
|
82
|
+
|
|
83
|
+
resolveWhenFinished.resolve();
|
|
84
|
+
fileService.releaseContent.resolve(); // Allow the initialization to run
|
|
85
|
+
|
|
86
|
+
// This promise would reject if the provider had declared itself ready before we resolve `resolveWhenFinished`
|
|
87
|
+
await Promise.race([resolveWhenFinished.promise, errorIfReadyFirst]);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('should report values in file when `ready` resolves.', async () => {
|
|
91
|
+
fileService.releaseContent.resolve();
|
|
92
|
+
await provider.ready;
|
|
93
|
+
expect(provider.get('editor.fontSize')).to.equal(20); // The value provided by the mock FileService implementation.
|
|
94
|
+
});
|
|
95
|
+
});
|