@theia/api-tests 1.24.0-next.7 → 1.24.0-next.71
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/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/api-tests",
|
|
3
|
-
"version": "1.24.0-next.
|
|
3
|
+
"version": "1.24.0-next.71+b3d41033c29",
|
|
4
4
|
"description": "Theia API tests",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/core": "1.24.0-next.
|
|
6
|
+
"@theia/core": "1.24.0-next.71+b3d41033c29"
|
|
7
7
|
},
|
|
8
8
|
"license": "EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0",
|
|
9
9
|
"repository": {
|
|
@@ -20,5 +20,5 @@
|
|
|
20
20
|
"publishConfig": {
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "b3d41033c29cb4f0ed8efbe969cfce41986c48e0"
|
|
24
24
|
}
|
|
@@ -492,7 +492,7 @@ describe('Launch Preferences', function () {
|
|
|
492
492
|
describe(JSON.stringify(configMode, undefined, 2), () => {
|
|
493
493
|
const configPaths = Array.isArray(configMode) ? configMode : [configMode];
|
|
494
494
|
|
|
495
|
-
/** @typedef {monaco
|
|
495
|
+
/** @typedef {import('@theia/monaco-editor-core/esm/vs/base/common/lifecycle').IReference<import('@theia/monaco/lib/browser/monaco-editor-model').MonacoEditorModel>} ConfigModelReference */
|
|
496
496
|
/** @type {ConfigModelReference[]} */
|
|
497
497
|
beforeEach(async () => {
|
|
498
498
|
/** @type {Promise<void>[]} */
|
package/src/monaco-api.spec.js
CHANGED
|
@@ -26,6 +26,12 @@ describe('Monaco API', async function () {
|
|
|
26
26
|
const { MonacoResolvedKeybinding } = require('@theia/monaco/lib/browser/monaco-resolved-keybinding');
|
|
27
27
|
const { MonacoTextmateService } = require('@theia/monaco/lib/browser/textmate/monaco-textmate-service');
|
|
28
28
|
const { CommandRegistry } = require('@theia/core/lib/common/command');
|
|
29
|
+
const { SimpleKeybinding } = require('@theia/monaco-editor-core/esm/vs/base/common/keybindings');
|
|
30
|
+
const { IKeybindingService } = require('@theia/monaco-editor-core/esm/vs/platform/keybinding/common/keybinding');
|
|
31
|
+
const { StandaloneServices } = require('@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices');
|
|
32
|
+
const { KeyCode } = require('@theia/monaco-editor-core/esm/vs/base/common/keyCodes');
|
|
33
|
+
const { TokenizationRegistry } = require('@theia/monaco-editor-core/esm/vs/editor/common/languages');
|
|
34
|
+
const { Uri } = require('@theia/monaco-editor-core');
|
|
29
35
|
|
|
30
36
|
const container = window.theia.container;
|
|
31
37
|
const editorManager = container.get(EditorManager);
|
|
@@ -49,12 +55,12 @@ describe('Monaco API', async function () {
|
|
|
49
55
|
});
|
|
50
56
|
|
|
51
57
|
it('KeybindingService.resolveKeybinding', () => {
|
|
52
|
-
const simpleKeybinding = new
|
|
58
|
+
const simpleKeybinding = new SimpleKeybinding(true, true, true, true, KeyCode.KeyK);
|
|
53
59
|
const chordKeybinding = simpleKeybinding.toChord();
|
|
54
60
|
assert.equal(chordKeybinding.parts.length, 1);
|
|
55
61
|
assert.equal(chordKeybinding.parts[0], simpleKeybinding);
|
|
56
62
|
|
|
57
|
-
const resolvedKeybindings =
|
|
63
|
+
const resolvedKeybindings = StandaloneServices.get(IKeybindingService).resolveKeybinding(chordKeybinding);
|
|
58
64
|
assert.equal(resolvedKeybindings.length, 1);
|
|
59
65
|
|
|
60
66
|
const resolvedKeybinding = resolvedKeybindings[0];
|
|
@@ -124,7 +130,7 @@ describe('Monaco API', async function () {
|
|
|
124
130
|
it('TokenizationRegistry.getColorMap', async () => {
|
|
125
131
|
if (textmateService['monacoThemeRegistry'].getThemeData().base !== 'vs') {
|
|
126
132
|
const didChangeColorMap = new Promise(resolve => {
|
|
127
|
-
const toDispose =
|
|
133
|
+
const toDispose = TokenizationRegistry.onDidChange(() => {
|
|
128
134
|
toDispose.dispose();
|
|
129
135
|
resolve();
|
|
130
136
|
});
|
|
@@ -136,7 +142,7 @@ describe('Monaco API', async function () {
|
|
|
136
142
|
const textMateColorMap = textmateService['grammarRegistry'].getColorMap();
|
|
137
143
|
assert.notEqual(textMateColorMap.indexOf('#795E26'), -1, 'Expected custom toke colors for the light theme to be enabled.');
|
|
138
144
|
|
|
139
|
-
const monacoColorMap = (
|
|
145
|
+
const monacoColorMap = (TokenizationRegistry.getColorMap() || []).
|
|
140
146
|
splice(0, textMateColorMap.length).map(c => c.toString().toUpperCase());
|
|
141
147
|
assert.deepStrictEqual(monacoColorMap, textMateColorMap, 'Expected textmate colors to have the same index in the monaco color map.');
|
|
142
148
|
});
|
|
@@ -148,7 +154,7 @@ describe('Monaco API', async function () {
|
|
|
148
154
|
assert.fail('hoverContribution does not have OpenerService');
|
|
149
155
|
return;
|
|
150
156
|
}
|
|
151
|
-
/** @type {monaco
|
|
157
|
+
/** @type {import('@theia/monaco-editor-core/esm/vs/editor/browser/services/openerService').OpenerService} */
|
|
152
158
|
const openerService = hoverContribution['_openerService'];
|
|
153
159
|
|
|
154
160
|
let opened = false;
|
|
@@ -157,7 +163,7 @@ describe('Monaco API', async function () {
|
|
|
157
163
|
execute: arg => (console.log(arg), opened = arg === 'foo')
|
|
158
164
|
});
|
|
159
165
|
try {
|
|
160
|
-
await openerService.open(
|
|
166
|
+
await openerService.open(Uri.parse('command:' + id + '?"foo"'));
|
|
161
167
|
assert.isTrue(opened);
|
|
162
168
|
} finally {
|
|
163
169
|
unregisterCommand.dispose();
|
package/src/preferences.spec.js
CHANGED
|
@@ -24,23 +24,27 @@ describe('Preferences', function () {
|
|
|
24
24
|
const { FileService } = require('@theia/filesystem/lib/browser/file-service');
|
|
25
25
|
const { PreferenceLanguageOverrideService } = require('@theia/core/lib/browser/preferences/preference-language-override-service');
|
|
26
26
|
const { MonacoTextModelService } = require('@theia/monaco/lib/browser/monaco-text-model-service');
|
|
27
|
+
const { PreferenceSchemaProvider } = require('@theia/core/lib/browser/preferences/preference-contribution')
|
|
27
28
|
const { container } = window.theia;
|
|
28
29
|
/** @type {import ('@theia/core/lib/browser/preferences/preference-service').PreferenceService} */
|
|
29
30
|
const preferenceService = container.get(PreferenceService);
|
|
31
|
+
/** @type {import ('@theia/core/lib/browser/preferences/preference-language-override-service').PreferenceLanguageOverrideService} */
|
|
30
32
|
const overrideService = container.get(PreferenceLanguageOverrideService);
|
|
31
33
|
const fileService = container.get(FileService);
|
|
32
34
|
/** @type {import ('@theia/core/lib/common/uri').default} */
|
|
33
35
|
const uri = preferenceService.getConfigUri(PreferenceScope.Workspace);
|
|
34
36
|
/** @type {import('@theia/preferences/lib/browser/folders-preferences-provider').FoldersPreferencesProvider} */
|
|
35
37
|
const folderPreferences = container.getNamed(PreferenceProvider, PreferenceScope.Folder);
|
|
38
|
+
/** @type PreferenceSchemaProvider */
|
|
39
|
+
const schemaProvider = container.get(PreferenceSchemaProvider);
|
|
36
40
|
const modelService = container.get(MonacoTextModelService);
|
|
37
41
|
|
|
38
|
-
const
|
|
42
|
+
const overrideIdentifier = 'bargle-noddle-zaus'; // Probably not in our preference files...
|
|
39
43
|
const tabSize = 'editor.tabSize';
|
|
40
44
|
const fontSize = 'editor.fontSize';
|
|
41
|
-
const override = overrideService.markLanguageOverride(
|
|
42
|
-
const overriddenTabSize = overrideService.overridePreferenceName({ overrideIdentifier
|
|
43
|
-
const overriddenFontSize = overrideService.overridePreferenceName({ overrideIdentifier
|
|
45
|
+
const override = overrideService.markLanguageOverride(overrideIdentifier);
|
|
46
|
+
const overriddenTabSize = overrideService.overridePreferenceName({ overrideIdentifier, preferenceName: tabSize });
|
|
47
|
+
const overriddenFontSize = overrideService.overridePreferenceName({ overrideIdentifier, preferenceName: fontSize });
|
|
44
48
|
/**
|
|
45
49
|
* @returns {Promise<Record<string, any>>}
|
|
46
50
|
*/
|
|
@@ -80,6 +84,7 @@ describe('Preferences', function () {
|
|
|
80
84
|
assert.isDefined(uri, 'The workspace config URI should be defined!');
|
|
81
85
|
fileExistsBeforehand = await fileService.exists(uri);
|
|
82
86
|
contentBeforehand = await fileService.read(uri).then(({ value }) => value).catch(() => '');
|
|
87
|
+
schemaProvider.registerOverrideIdentifier(overrideIdentifier);
|
|
83
88
|
await deleteAllValues();
|
|
84
89
|
});
|
|
85
90
|
|
|
@@ -157,4 +162,36 @@ describe('Preferences', function () {
|
|
|
157
162
|
const prefs = await getPreferences();
|
|
158
163
|
shouldBeUndefined(prefs[override], override);
|
|
159
164
|
});
|
|
165
|
+
|
|
166
|
+
it('Handles many synchronous settings of preferences gracefully', async function () {
|
|
167
|
+
let settings = 0;
|
|
168
|
+
const promises = [];
|
|
169
|
+
const searchPref = 'search.searchOnTypeDebouncePeriod'
|
|
170
|
+
const channelPref = 'output.maxChannelHistory'
|
|
171
|
+
const hoverPref = 'workbench.hover.delay';
|
|
172
|
+
let searchDebounce;
|
|
173
|
+
let channelHistory;
|
|
174
|
+
let hoverDelay;
|
|
175
|
+
/** @type import ('@theia/core/src/browser/preferences/preference-service').PreferenceChanges | undefined */
|
|
176
|
+
let event;
|
|
177
|
+
const toDispose = preferenceService.onPreferencesChanged(e => event = e);
|
|
178
|
+
while (settings++ < 50) {
|
|
179
|
+
searchDebounce = 100 + Math.floor(Math.random() * 500);
|
|
180
|
+
channelHistory = 200 + Math.floor(Math.random() * 800);
|
|
181
|
+
hoverDelay = 250 + Math.floor(Math.random() * 2_500);
|
|
182
|
+
promises.push(
|
|
183
|
+
preferenceService.set(searchPref, searchDebounce),
|
|
184
|
+
preferenceService.set(channelPref, channelHistory),
|
|
185
|
+
preferenceService.set(hoverPref, hoverDelay)
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
const results = await Promise.allSettled(promises);
|
|
189
|
+
const expectedValues = { [searchPref]: searchDebounce, [channelPref]: channelHistory, [hoverPref]: hoverDelay };
|
|
190
|
+
const actualValues = { [searchPref]: preferenceService.get(searchPref), [channelPref]: preferenceService.get(channelPref), [hoverPref]: preferenceService.get(hoverPref), }
|
|
191
|
+
const eventValues = event && Object.keys(event).reduce((accu, key) => { accu[key] = event[key].newValue; return accu; }, {});
|
|
192
|
+
toDispose.dispose();
|
|
193
|
+
assert(results.every(setting => setting.status === 'fulfilled'), 'All promises should have resolved rather than rejected.');
|
|
194
|
+
assert.deepEqual(actualValues, eventValues, 'The event should reflect the current state of the service.');
|
|
195
|
+
assert.deepEqual(expectedValues, actualValues, 'The service state should reflect the most recent setting');
|
|
196
|
+
});
|
|
160
197
|
});
|
package/src/saveable.spec.js
CHANGED
|
@@ -31,6 +31,7 @@ describe('Saveable', function () {
|
|
|
31
31
|
const { MonacoEditor } = require('@theia/monaco/lib/browser/monaco-editor');
|
|
32
32
|
const { Deferred } = require('@theia/core/lib/common/promise-util');
|
|
33
33
|
const { Disposable, DisposableCollection } = require('@theia/core/lib/common/disposable');
|
|
34
|
+
const { Range } = require('@theia/monaco-editor-core');
|
|
34
35
|
|
|
35
36
|
const container = window.theia.container;
|
|
36
37
|
/** @type {EditorManager} */
|
|
@@ -66,10 +67,10 @@ describe('Saveable', function () {
|
|
|
66
67
|
const toTearDown = new DisposableCollection();
|
|
67
68
|
|
|
68
69
|
/** @type {string | undefined} */
|
|
69
|
-
const autoSave = preferences.get('
|
|
70
|
+
const autoSave = preferences.get('files.autoSave', undefined, rootUri.toString());
|
|
70
71
|
|
|
71
72
|
beforeEach(async () => {
|
|
72
|
-
await preferences.set('
|
|
73
|
+
await preferences.set('files.autoSave', 'off', undefined, rootUri.toString());
|
|
73
74
|
await preferences.set(closeOnFileDelete, true);
|
|
74
75
|
await editorManager.closeAll({ save: false });
|
|
75
76
|
await fileService.create(fileUri, 'foo', { fromUserGesture: false, overwrite: true });
|
|
@@ -80,7 +81,7 @@ describe('Saveable', function () {
|
|
|
80
81
|
|
|
81
82
|
afterEach(async () => {
|
|
82
83
|
toTearDown.dispose();
|
|
83
|
-
await preferences.set('
|
|
84
|
+
await preferences.set('files.autoSave', autoSave, undefined, rootUri.toString());
|
|
84
85
|
// @ts-ignore
|
|
85
86
|
editor = undefined;
|
|
86
87
|
// @ts-ignore
|
|
@@ -112,7 +113,7 @@ describe('Saveable', function () {
|
|
|
112
113
|
|
|
113
114
|
// @ts-ignore
|
|
114
115
|
editor.getControl().getModel().applyEdits([{
|
|
115
|
-
range:
|
|
116
|
+
range: Range.fromPositions({ lineNumber: 1, column: 1 }, { lineNumber: 1, column: 4 }),
|
|
116
117
|
forceMoveMarkers: false,
|
|
117
118
|
text: ''
|
|
118
119
|
}]);
|
package/src/typescript.spec.js
CHANGED
|
@@ -39,6 +39,7 @@ describe('TypeScript', function () {
|
|
|
39
39
|
const { FileService } = require('@theia/filesystem/lib/browser/file-service');
|
|
40
40
|
const { PluginViewRegistry } = require('@theia/plugin-ext/lib/main/browser/view/plugin-view-registry');
|
|
41
41
|
const { Deferred } = require('@theia/core/lib/common/promise-util');
|
|
42
|
+
const { Range } = require('@theia/monaco-editor-core');
|
|
42
43
|
|
|
43
44
|
const container = window.theia.container;
|
|
44
45
|
const editorManager = container.get(EditorManager);
|
|
@@ -215,7 +216,8 @@ module.exports = (port, host, argv) => Promise.resolve()
|
|
|
215
216
|
* @param {MonacoEditor} editor
|
|
216
217
|
*/
|
|
217
218
|
async function assertPeekOpened(editor) {
|
|
218
|
-
|
|
219
|
+
/** @type any */
|
|
220
|
+
const referencesController = editor.getControl().getContribution('editor.contrib.referencesController');
|
|
219
221
|
await waitForAnimation(() => referencesController._widget && referencesController._widget._tree.getFocus().length);
|
|
220
222
|
|
|
221
223
|
assert.isFalse(contextKeyService.match('editorTextFocus'));
|
|
@@ -459,7 +461,8 @@ module.exports = (port, host, argv) => Promise.resolve()
|
|
|
459
461
|
// @ts-ignore
|
|
460
462
|
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'Container');
|
|
461
463
|
|
|
462
|
-
|
|
464
|
+
/** @type any */
|
|
465
|
+
const suggest = editor.getControl().getContribution('editor.contrib.suggestController');
|
|
463
466
|
const getFocusedLabel = () => {
|
|
464
467
|
const focusedItem = suggest.widget.value.getFocusedItem();
|
|
465
468
|
return focusedItem && focusedItem.item.completion.label;
|
|
@@ -521,7 +524,7 @@ module.exports = (port, host, argv) => Promise.resolve()
|
|
|
521
524
|
|
|
522
525
|
// all rename edits should be grouped in one edit operation and applied in the same tick
|
|
523
526
|
const waitForApplyRenameEdits = new Deferred();
|
|
524
|
-
editor.getControl().onDidChangeModelContent(waitForApplyRenameEdits.resolve);
|
|
527
|
+
editor.getControl().onDidChangeModelContent(() => waitForApplyRenameEdits.resolve());
|
|
525
528
|
await waitForApplyRenameEdits.promise;
|
|
526
529
|
|
|
527
530
|
assert.isTrue(contextKeyService.match('editorTextFocus'));
|
|
@@ -567,7 +570,8 @@ module.exports = (port, host, argv) => Promise.resolve()
|
|
|
567
570
|
// @ts-ignore
|
|
568
571
|
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'backendApplicationModule');
|
|
569
572
|
|
|
570
|
-
|
|
573
|
+
/** @type any */
|
|
574
|
+
const hover = editor.getControl().getContribution('editor.contrib.hover');
|
|
571
575
|
|
|
572
576
|
assert.isTrue(contextKeyService.match('editorTextFocus'));
|
|
573
577
|
assert.isFalse(!!hover._contentWidget && hover._contentWidget._isVisible);
|
|
@@ -692,7 +696,8 @@ DIV {
|
|
|
692
696
|
|
|
693
697
|
const editor = await openEditor(serverUri);
|
|
694
698
|
|
|
695
|
-
|
|
699
|
+
/** @type any */
|
|
700
|
+
const codeLens = editor.getControl().getContribution('css.editor.codeLens');
|
|
696
701
|
const codeLensNode = () => codeLens._lenses[0] && codeLens._lenses[0]._contentWidget && codeLens._lenses[0]._contentWidget._domNode;
|
|
697
702
|
const codeLensNodeVisible = () => {
|
|
698
703
|
const n = codeLensNode();
|
|
@@ -705,7 +710,7 @@ DIV {
|
|
|
705
710
|
const position = { lineNumber: 16, column: 1 };
|
|
706
711
|
// @ts-ignore
|
|
707
712
|
editor.getControl().getModel().applyEdits([{
|
|
708
|
-
range:
|
|
713
|
+
range: Range.fromPositions(position, position),
|
|
709
714
|
forceMoveMarkers: false,
|
|
710
715
|
text: 'export '
|
|
711
716
|
}]);
|
|
@@ -714,7 +719,7 @@ DIV {
|
|
|
714
719
|
// Recall `applyEdits` to workaround `vscode` bug, See: https://github.com/eclipse-theia/theia/issues/9714#issuecomment-876582947.
|
|
715
720
|
// @ts-ignore
|
|
716
721
|
editor.getControl().getModel().applyEdits([{
|
|
717
|
-
range:
|
|
722
|
+
range: Range.fromPositions(position, position),
|
|
718
723
|
forceMoveMarkers: false,
|
|
719
724
|
text: ' '
|
|
720
725
|
}]);
|
|
@@ -766,7 +771,8 @@ SPAN {
|
|
|
766
771
|
editor.getControl().revealPosition({ lineNumber, column });
|
|
767
772
|
assert.equal(currentChar(), ')');
|
|
768
773
|
|
|
769
|
-
|
|
774
|
+
/** @type any */
|
|
775
|
+
const quickFixController = editor.getControl().getContribution('editor.contrib.quickFixController');
|
|
770
776
|
const lightBulbNode = () => {
|
|
771
777
|
const ui = quickFixController._ui.rawValue;
|
|
772
778
|
const lightBulb = ui && ui._lightBulbWidget.rawValue;
|
|
@@ -803,7 +809,7 @@ SPAN {
|
|
|
803
809
|
// const { Container[ ] } = require('inversify');
|
|
804
810
|
// @ts-ignore
|
|
805
811
|
editor.getControl().getModel().applyEdits([{
|
|
806
|
-
range:
|
|
812
|
+
range: Range.fromPositions({ lineNumber, column: 18 }, { lineNumber, column: 18 }),
|
|
807
813
|
forceMoveMarkers: false,
|
|
808
814
|
text: ' '
|
|
809
815
|
}]);
|
|
@@ -826,7 +832,7 @@ SPAN {
|
|
|
826
832
|
// const { Container[ } ]= require('inversify');
|
|
827
833
|
// @ts-ignore
|
|
828
834
|
editor.getControl().getModel().applyEdits([{
|
|
829
|
-
range:
|
|
835
|
+
range: Range.fromPositions({ lineNumber, column: 18 }, { lineNumber, column: 21 }),
|
|
830
836
|
forceMoveMarkers: false,
|
|
831
837
|
text: ' } '
|
|
832
838
|
}]);
|
|
@@ -31,6 +31,7 @@ describe('Undo, Redo and Select All', function () {
|
|
|
31
31
|
const { ApplicationShell } = require('@theia/core/lib/browser/shell/application-shell');
|
|
32
32
|
const { MonacoEditor } = require('@theia/monaco/lib/browser/monaco-editor');
|
|
33
33
|
const { ScmContribution } = require('@theia/scm/lib/browser/scm-contribution');
|
|
34
|
+
const { Range } = require('@theia/monaco-editor-core');
|
|
34
35
|
|
|
35
36
|
const container = window.theia.container;
|
|
36
37
|
const editorManager = container.get(EditorManager);
|
|
@@ -48,7 +49,7 @@ describe('Undo, Redo and Select All', function () {
|
|
|
48
49
|
|
|
49
50
|
/**
|
|
50
51
|
* @template T
|
|
51
|
-
* @param {() => Promise<T> |
|
|
52
|
+
* @param {() => Promise<T> | T} condition
|
|
52
53
|
* @returns {Promise<T>}
|
|
53
54
|
*/
|
|
54
55
|
function waitForAnimation(condition) {
|
|
@@ -57,7 +58,7 @@ describe('Undo, Redo and Select All', function () {
|
|
|
57
58
|
do {
|
|
58
59
|
await animationFrame();
|
|
59
60
|
} while (!condition());
|
|
60
|
-
resolve();
|
|
61
|
+
resolve(undefined);
|
|
61
62
|
});
|
|
62
63
|
}
|
|
63
64
|
|
|
@@ -90,7 +91,7 @@ describe('Undo, Redo and Select All', function () {
|
|
|
90
91
|
const editor = /** @type {MonacoEditor} */ (MonacoEditor.get(widget));
|
|
91
92
|
editor.getControl().pushUndoStop();
|
|
92
93
|
editor.getControl().executeEdits('test', [{
|
|
93
|
-
range: new
|
|
94
|
+
range: new Range(1, 1, 1, 1),
|
|
94
95
|
text: 'A'
|
|
95
96
|
}]);
|
|
96
97
|
editor.getControl().pushUndoStop();
|