@theia/core 1.40.1 → 1.42.0
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 +7 -7
- package/i18n/nls.cs.json +6 -1
- package/i18n/nls.de.json +6 -1
- package/i18n/nls.es.json +6 -1
- package/i18n/nls.fr.json +6 -1
- package/i18n/nls.hu.json +6 -1
- package/i18n/nls.it.json +6 -1
- package/i18n/nls.ja.json +6 -1
- package/i18n/nls.json +6 -1
- package/i18n/nls.pl.json +6 -1
- package/i18n/nls.pt-br.json +6 -1
- package/i18n/nls.pt-pt.json +6 -1
- package/i18n/nls.ru.json +6 -1
- package/i18n/nls.zh-cn.json +6 -1
- package/lib/browser/common-frontend-contribution.d.ts +11 -0
- package/lib/browser/common-frontend-contribution.d.ts.map +1 -1
- package/lib/browser/common-frontend-contribution.js +98 -14
- package/lib/browser/common-frontend-contribution.js.map +1 -1
- package/lib/browser/context-menu-renderer.d.ts +5 -0
- package/lib/browser/context-menu-renderer.d.ts.map +1 -1
- package/lib/browser/label-parser.d.ts +8 -0
- package/lib/browser/label-parser.d.ts.map +1 -1
- package/lib/browser/label-parser.js +14 -0
- package/lib/browser/label-parser.js.map +1 -1
- package/lib/browser/label-parser.spec.js +33 -0
- package/lib/browser/label-parser.spec.js.map +1 -1
- package/lib/browser/menu/browser-context-menu-renderer.d.ts +1 -1
- package/lib/browser/menu/browser-context-menu-renderer.d.ts.map +1 -1
- package/lib/browser/menu/browser-context-menu-renderer.js +2 -2
- package/lib/browser/menu/browser-context-menu-renderer.js.map +1 -1
- package/lib/browser/menu/browser-menu-plugin.d.ts +1 -1
- package/lib/browser/menu/browser-menu-plugin.d.ts.map +1 -1
- package/lib/browser/menu/browser-menu-plugin.js +2 -2
- package/lib/browser/menu/browser-menu-plugin.js.map +1 -1
- package/lib/browser/performance/frontend-stopwatch.d.ts.map +1 -1
- package/lib/browser/performance/frontend-stopwatch.js +6 -2
- package/lib/browser/performance/frontend-stopwatch.js.map +1 -1
- package/lib/browser/preferences/preference-contribution.d.ts +2 -0
- package/lib/browser/preferences/preference-contribution.d.ts.map +1 -1
- package/lib/browser/preferences/preference-contribution.js +48 -24
- package/lib/browser/preferences/preference-contribution.js.map +1 -1
- package/lib/browser/preload/i18n-preload-contribution.d.ts +7 -0
- package/lib/browser/preload/i18n-preload-contribution.d.ts.map +1 -0
- package/lib/browser/preload/i18n-preload-contribution.js +63 -0
- package/lib/browser/preload/i18n-preload-contribution.js.map +1 -0
- package/lib/browser/preload/os-preload-contribution.d.ts +7 -0
- package/lib/browser/preload/os-preload-contribution.d.ts.map +1 -0
- package/lib/browser/preload/os-preload-contribution.js +49 -0
- package/lib/browser/preload/os-preload-contribution.js.map +1 -0
- package/lib/browser/preload/preload-module.d.ts +4 -0
- package/lib/browser/preload/preload-module.d.ts.map +1 -0
- package/lib/browser/preload/preload-module.js +39 -0
- package/lib/browser/preload/preload-module.js.map +1 -0
- package/lib/browser/preload/preloader.d.ts +12 -0
- package/lib/browser/preload/preloader.d.ts.map +1 -0
- package/lib/browser/preload/preloader.js +45 -0
- package/lib/browser/preload/preloader.js.map +1 -0
- package/lib/browser/preload/theme-preload-contribution.d.ts +5 -0
- package/lib/browser/preload/theme-preload-contribution.d.ts.map +1 -0
- package/lib/browser/preload/theme-preload-contribution.js +40 -0
- package/lib/browser/preload/theme-preload-contribution.js.map +1 -0
- package/lib/browser/saveable.d.ts +15 -1
- package/lib/browser/saveable.d.ts.map +1 -1
- package/lib/browser/saveable.js +34 -1
- package/lib/browser/saveable.js.map +1 -1
- package/lib/browser/shell/application-shell.d.ts +2 -0
- package/lib/browser/shell/application-shell.d.ts.map +1 -1
- package/lib/browser/shell/application-shell.js +8 -0
- package/lib/browser/shell/application-shell.js.map +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.d.ts +46 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.d.ts.map +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.js +87 -6
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.js.map +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-types.d.ts +20 -2
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-types.d.ts.map +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-types.js +28 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-types.js.map +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.d.ts +25 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.d.ts.map +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.js +79 -7
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.js.map +1 -1
- package/lib/browser/shell/tab-bars.d.ts.map +1 -1
- package/lib/browser/shell/tab-bars.js +9 -1
- package/lib/browser/shell/tab-bars.js.map +1 -1
- package/lib/browser/tree/tree-model.d.ts +2 -0
- package/lib/browser/tree/tree-model.d.ts.map +1 -1
- package/lib/browser/tree/tree-model.js +6 -0
- package/lib/browser/tree/tree-model.js.map +1 -1
- package/lib/browser/tree/tree-widget.d.ts +18 -0
- package/lib/browser/tree/tree-widget.d.ts.map +1 -1
- package/lib/browser/tree/tree-widget.js +57 -0
- package/lib/browser/tree/tree-widget.js.map +1 -1
- package/lib/browser/tree/tree.d.ts +18 -0
- package/lib/browser/tree/tree.d.ts.map +1 -1
- package/lib/browser/tree/tree.js +6 -0
- package/lib/browser/tree/tree.js.map +1 -1
- package/lib/browser/widgets/enhanced-preview-widget.d.ts +7 -0
- package/lib/browser/widgets/enhanced-preview-widget.d.ts.map +1 -0
- package/lib/browser/widgets/enhanced-preview-widget.js +27 -0
- package/lib/browser/widgets/enhanced-preview-widget.js.map +1 -0
- package/lib/browser/window-contribution.js +1 -1
- package/lib/browser/window-contribution.js.map +1 -1
- package/lib/common/array-utils.d.ts +7 -0
- package/lib/common/array-utils.d.ts.map +1 -1
- package/lib/common/array-utils.js +21 -0
- package/lib/common/array-utils.js.map +1 -1
- package/lib/common/event.d.ts +5 -0
- package/lib/common/event.d.ts.map +1 -1
- package/lib/common/event.js +5 -1
- package/lib/common/event.js.map +1 -1
- package/lib/common/i18n/localization-server.d.ts +7 -0
- package/lib/common/i18n/localization-server.d.ts.map +1 -0
- package/lib/common/i18n/localization-server.js +21 -0
- package/lib/common/i18n/localization-server.js.map +1 -0
- package/lib/common/keys.d.ts.map +1 -1
- package/lib/common/keys.js +4 -3
- package/lib/common/keys.js.map +1 -1
- package/lib/common/logger-protocol.d.ts +2 -0
- package/lib/common/logger-protocol.d.ts.map +1 -1
- package/lib/common/logger-protocol.js +3 -0
- package/lib/common/logger-protocol.js.map +1 -1
- package/lib/common/logger-watcher.d.ts +4 -3
- package/lib/common/logger-watcher.d.ts.map +1 -1
- package/lib/common/logger-watcher.js +10 -6
- package/lib/common/logger-watcher.js.map +1 -1
- package/lib/common/logger.d.ts.map +1 -1
- package/lib/common/logger.js +4 -0
- package/lib/common/logger.js.map +1 -1
- package/lib/common/menu/menu-model-registry.d.ts +12 -1
- package/lib/common/menu/menu-model-registry.d.ts.map +1 -1
- package/lib/common/menu/menu-model-registry.js +46 -0
- package/lib/common/menu/menu-model-registry.js.map +1 -1
- package/lib/common/os.d.ts +5 -0
- package/lib/common/os.d.ts.map +1 -1
- package/lib/common/os.js +3 -1
- package/lib/common/os.js.map +1 -1
- package/lib/common/performance/measurement.d.ts +21 -0
- package/lib/common/performance/measurement.d.ts.map +1 -1
- package/lib/common/performance/stopwatch.d.ts +10 -2
- package/lib/common/performance/stopwatch.d.ts.map +1 -1
- package/lib/common/performance/stopwatch.js +34 -11
- package/lib/common/performance/stopwatch.js.map +1 -1
- package/lib/common/promise-util.d.ts +4 -0
- package/lib/common/promise-util.d.ts.map +1 -1
- package/lib/common/promise-util.js +11 -1
- package/lib/common/promise-util.js.map +1 -1
- package/lib/common/promise-util.spec.js +26 -12
- package/lib/common/promise-util.spec.js.map +1 -1
- package/lib/common/quick-pick-service.d.ts +6 -0
- package/lib/common/quick-pick-service.d.ts.map +1 -1
- package/lib/common/quick-pick-service.js.map +1 -1
- package/lib/common/types.d.ts +4 -0
- package/lib/common/types.d.ts.map +1 -1
- package/lib/common/types.js +16 -1
- package/lib/common/types.js.map +1 -1
- package/lib/common/uri.d.ts +1 -0
- package/lib/common/uri.d.ts.map +1 -1
- package/lib/common/uri.js +3 -0
- package/lib/common/uri.js.map +1 -1
- package/lib/electron-browser/menu/electron-context-menu-renderer.js +2 -2
- package/lib/electron-browser/menu/electron-context-menu-renderer.js.map +1 -1
- package/lib/electron-browser/menu/electron-main-menu-factory.d.ts +1 -1
- package/lib/electron-browser/menu/electron-main-menu-factory.d.ts.map +1 -1
- package/lib/electron-browser/menu/electron-main-menu-factory.js +2 -2
- package/lib/electron-browser/menu/electron-main-menu-factory.js.map +1 -1
- package/lib/electron-browser/menu/electron-menu-contribution.d.ts +4 -0
- package/lib/electron-browser/menu/electron-menu-contribution.d.ts.map +1 -1
- package/lib/electron-browser/menu/electron-menu-contribution.js +12 -0
- package/lib/electron-browser/menu/electron-menu-contribution.js.map +1 -1
- package/lib/electron-browser/preload.d.ts.map +1 -1
- package/lib/electron-browser/preload.js +3 -0
- package/lib/electron-browser/preload.js.map +1 -1
- package/lib/electron-common/electron-api.d.ts +2 -0
- package/lib/electron-common/electron-api.d.ts.map +1 -1
- package/lib/electron-common/electron-api.js +2 -1
- package/lib/electron-common/electron-api.js.map +1 -1
- package/lib/electron-main/electron-api-main.d.ts.map +1 -1
- package/lib/electron-main/electron-api-main.js +1 -0
- package/lib/electron-main/electron-api-main.js.map +1 -1
- package/lib/electron-main/electron-main-application.d.ts +6 -0
- package/lib/electron-main/electron-main-application.d.ts.map +1 -1
- package/lib/electron-main/electron-main-application.js +37 -4
- package/lib/electron-main/electron-main-application.js.map +1 -1
- package/lib/node/backend-application-module.d.ts.map +1 -1
- package/lib/node/backend-application-module.js +4 -3
- package/lib/node/backend-application-module.js.map +1 -1
- package/lib/node/backend-application.d.ts +5 -1
- package/lib/node/backend-application.d.ts.map +1 -1
- package/lib/node/backend-application.js +28 -5
- package/lib/node/backend-application.js.map +1 -1
- package/lib/node/console-logger-server.d.ts.map +1 -1
- package/lib/node/console-logger-server.js +5 -1
- package/lib/node/console-logger-server.js.map +1 -1
- package/lib/node/i18n/i18n-backend-module.d.ts.map +1 -1
- package/lib/node/i18n/i18n-backend-module.js +7 -4
- package/lib/node/i18n/i18n-backend-module.js.map +1 -1
- package/lib/node/i18n/{localization-backend-contribution.d.ts → localization-server.d.ts} +5 -4
- package/lib/node/i18n/localization-server.d.ts.map +1 -0
- package/lib/node/i18n/{localization-backend-contribution.js → localization-server.js} +13 -16
- package/lib/node/i18n/localization-server.js.map +1 -0
- package/lib/node/logger-backend-module.d.ts.map +1 -1
- package/lib/node/logger-backend-module.js +6 -1
- package/lib/node/logger-backend-module.js.map +1 -1
- package/lib/node/logger-cli-contribution.spec.js +1 -1
- package/lib/node/logger-cli-contribution.spec.js.map +1 -1
- package/lib/node/main.d.ts +2 -5
- package/lib/node/main.d.ts.map +1 -1
- package/lib/node/main.js.map +1 -1
- package/lib/node/os-backend-provider.d.ts +5 -0
- package/lib/node/os-backend-provider.d.ts.map +1 -0
- package/lib/node/{os-backend-application-contribution.js → os-backend-provider.js} +8 -10
- package/lib/node/os-backend-provider.js.map +1 -0
- package/lib/node/performance/node-stopwatch.js +1 -1
- package/lib/node/performance/node-stopwatch.js.map +1 -1
- package/package.json +10 -9
- package/src/browser/common-frontend-contribution.ts +108 -17
- package/src/browser/context-menu-renderer.ts +5 -0
- package/src/browser/label-parser.spec.ts +38 -0
- package/src/browser/label-parser.ts +15 -0
- package/src/browser/menu/browser-context-menu-renderer.ts +2 -2
- package/src/browser/menu/browser-menu-plugin.ts +2 -2
- package/src/browser/performance/frontend-stopwatch.ts +5 -2
- package/src/browser/preferences/preference-contribution.ts +49 -24
- package/src/browser/preload/i18n-preload-contribution.ts +50 -0
- package/src/browser/preload/os-preload-contribution.ts +37 -0
- package/src/browser/preload/preload-module.ts +45 -0
- package/src/browser/preload/preloader.ts +37 -0
- package/src/browser/preload/theme-preload-contribution.ts +31 -0
- package/src/browser/saveable.ts +41 -2
- package/src/browser/shell/application-shell.ts +11 -0
- package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.ts +94 -8
- package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar-types.ts +28 -1
- package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar.tsx +87 -8
- package/src/browser/shell/tab-bars.ts +8 -1
- package/src/browser/style/tabs.css +32 -2
- package/src/browser/tree/tree-model.ts +8 -0
- package/src/browser/tree/tree-widget.tsx +66 -0
- package/src/browser/tree/tree.ts +27 -0
- package/src/browser/widgets/enhanced-preview-widget.ts +27 -0
- package/src/browser/window-contribution.ts +1 -1
- package/src/common/array-utils.ts +20 -0
- package/src/common/event.ts +12 -2
- package/src/common/i18n/localization-server.ts +25 -0
- package/src/common/i18n/nls.metadata.json +6767 -6260
- package/src/common/keys.ts +4 -3
- package/src/common/logger-protocol.ts +4 -0
- package/src/common/logger-watcher.ts +12 -7
- package/src/common/logger.ts +5 -0
- package/src/common/menu/menu-model-registry.ts +50 -0
- package/src/common/os.ts +8 -0
- package/src/common/performance/measurement.ts +26 -0
- package/src/common/performance/stopwatch.ts +38 -12
- package/src/common/promise-util.spec.ts +43 -12
- package/src/common/promise-util.ts +12 -0
- package/src/common/quick-pick-service.ts +1 -0
- package/src/common/types.ts +17 -0
- package/src/common/uri.ts +4 -0
- package/src/electron-browser/menu/electron-context-menu-renderer.ts +2 -2
- package/src/electron-browser/menu/electron-main-menu-factory.ts +2 -2
- package/src/electron-browser/menu/electron-menu-contribution.ts +13 -0
- package/src/electron-browser/preload.ts +4 -1
- package/src/electron-common/electron-api.ts +2 -0
- package/src/electron-main/electron-api-main.ts +4 -1
- package/src/electron-main/electron-main-application.ts +43 -4
- package/src/node/backend-application-module.ts +7 -4
- package/src/node/backend-application.ts +30 -5
- package/src/node/console-logger-server.ts +5 -2
- package/src/node/i18n/i18n-backend-module.ts +9 -4
- package/src/node/i18n/{localization-backend-contribution.ts → localization-server.ts} +9 -10
- package/src/node/logger-backend-module.ts +8 -1
- package/src/node/logger-cli-contribution.spec.ts +1 -1
- package/src/node/main.ts +1 -6
- package/src/node/{os-backend-application-contribution.ts → os-backend-provider.ts} +4 -9
- package/src/node/performance/node-stopwatch.ts +1 -1
- package/lib/browser/preloader.d.ts +0 -2
- package/lib/browser/preloader.d.ts.map +0 -1
- package/lib/browser/preloader.js +0 -75
- package/lib/browser/preloader.js.map +0 -1
- package/lib/node/i18n/localization-backend-contribution.d.ts.map +0 -1
- package/lib/node/i18n/localization-backend-contribution.js.map +0 -1
- package/lib/node/os-backend-application-contribution.d.ts +0 -6
- package/lib/node/os-backend-application-contribution.d.ts.map +0 -1
- package/lib/node/os-backend-application-contribution.js.map +0 -1
- package/src/browser/preloader.ts +0 -76
|
@@ -34,6 +34,8 @@ import { JSONValue } from '@phosphor/coreutils';
|
|
|
34
34
|
|
|
35
35
|
export const PreferenceContribution = Symbol('PreferenceContribution');
|
|
36
36
|
|
|
37
|
+
export const DefaultOverridesPreferenceSchemaId = 'defaultOverrides';
|
|
38
|
+
|
|
37
39
|
/**
|
|
38
40
|
* A {@link PreferenceContribution} allows adding additional custom preferences.
|
|
39
41
|
* For this, the {@link PreferenceContribution} has to provide a valid JSON Schema specifying which preferences
|
|
@@ -202,34 +204,44 @@ export class PreferenceSchemaProvider extends PreferenceProvider {
|
|
|
202
204
|
const defaultScope = PreferenceSchema.getDefaultScope(schema);
|
|
203
205
|
const overridable = schema.overridable || false;
|
|
204
206
|
for (const [preferenceName, rawSchemaProps] of Object.entries(schema.properties)) {
|
|
205
|
-
if (this.combinedSchema.properties[preferenceName]) {
|
|
207
|
+
if (this.combinedSchema.properties[preferenceName] && DefaultOverridesPreferenceSchemaId !== schema.id) {
|
|
206
208
|
console.error('Preference name collision detected in the schema for property: ' + preferenceName);
|
|
207
|
-
} else
|
|
208
|
-
|
|
209
|
-
if (
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
209
|
+
} else {
|
|
210
|
+
let schemaProps;
|
|
211
|
+
if (this.combinedSchema.properties[preferenceName] && DefaultOverridesPreferenceSchemaId === schema.id) {
|
|
212
|
+
// update existing default value in schema
|
|
213
|
+
schemaProps = PreferenceDataProperty.fromPreferenceSchemaProperty(rawSchemaProps, defaultScope);
|
|
214
|
+
this.updateSchemaPropsDefault(preferenceName, schemaProps);
|
|
215
|
+
} else if (!rawSchemaProps.hasOwnProperty('included') || rawSchemaProps.included) {
|
|
216
|
+
// add overrides for languages
|
|
217
|
+
schemaProps = PreferenceDataProperty.fromPreferenceSchemaProperty(rawSchemaProps, defaultScope);
|
|
218
|
+
if (typeof schemaProps.overridable !== 'boolean' && overridable) {
|
|
219
|
+
schemaProps.overridable = true;
|
|
220
|
+
}
|
|
221
|
+
if (schemaProps.overridable) {
|
|
222
|
+
this.overridePatternProperties.properties[preferenceName] = schemaProps;
|
|
223
|
+
}
|
|
224
|
+
this.updateSchemaProps(preferenceName, schemaProps);
|
|
214
225
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
226
|
+
|
|
227
|
+
if (schemaProps !== undefined) {
|
|
228
|
+
const schemaDefault = this.getDefaultValue(schemaProps);
|
|
229
|
+
const configuredDefault = this.getConfiguredDefault(preferenceName);
|
|
230
|
+
if (this.preferenceOverrideService.testOverrideValue(preferenceName, schemaDefault)) {
|
|
231
|
+
schemaProps.defaultValue = PreferenceSchemaProperties.is(configuredDefault)
|
|
232
|
+
? PreferenceProvider.merge(schemaDefault, configuredDefault)
|
|
233
|
+
: schemaDefault;
|
|
234
|
+
if (schemaProps.defaultValue && PreferenceSchemaProperties.is(schemaProps.defaultValue)) {
|
|
235
|
+
for (const overriddenPreferenceName in schemaProps.defaultValue) {
|
|
236
|
+
const overrideValue = schemaDefault[overriddenPreferenceName];
|
|
237
|
+
const overridePreferenceName = `${preferenceName}.${overriddenPreferenceName}`;
|
|
238
|
+
changes.push(this.doSetPreferenceValue(overridePreferenceName, overrideValue, { scope, domain }));
|
|
239
|
+
}
|
|
228
240
|
}
|
|
241
|
+
} else {
|
|
242
|
+
schemaProps.defaultValue = configuredDefault === undefined ? schemaDefault : configuredDefault;
|
|
243
|
+
changes.push(this.doSetPreferenceValue(preferenceName, schemaProps.defaultValue, { scope, domain }));
|
|
229
244
|
}
|
|
230
|
-
} else {
|
|
231
|
-
schemaProps.defaultValue = configuredDefault === undefined ? schemaDefault : configuredDefault;
|
|
232
|
-
changes.push(this.doSetPreferenceValue(preferenceName, schemaProps.defaultValue, { scope, domain }));
|
|
233
245
|
}
|
|
234
246
|
}
|
|
235
247
|
}
|
|
@@ -383,6 +395,19 @@ export class PreferenceSchemaProvider extends PreferenceProvider {
|
|
|
383
395
|
}
|
|
384
396
|
}
|
|
385
397
|
|
|
398
|
+
protected updateSchemaPropsDefault(key: string, property: PreferenceDataProperty): void {
|
|
399
|
+
this.combinedSchema.properties[key].default = property.default;
|
|
400
|
+
this.combinedSchema.properties[key].defaultValue = property.defaultValue;
|
|
401
|
+
if (this.workspaceSchema.properties[key]) {
|
|
402
|
+
this.workspaceSchema.properties[key].default = property.default;
|
|
403
|
+
this.workspaceSchema.properties[key].defaultValue = property.defaultValue;
|
|
404
|
+
}
|
|
405
|
+
if (this.folderSchema.properties[key]) {
|
|
406
|
+
this.folderSchema.properties[key].default = property.default;
|
|
407
|
+
this.folderSchema.properties[key].defaultValue = property.defaultValue;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
386
411
|
protected removePropFromSchemas(key: string): void {
|
|
387
412
|
// If we remove a key from combined, it should also be removed from all narrower scopes.
|
|
388
413
|
delete this.combinedSchema.properties[key];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 TypeFox 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
|
+
import { PreloadContribution } from './preloader';
|
|
18
|
+
import { FrontendApplicationConfigProvider } from '../frontend-application-config-provider';
|
|
19
|
+
import { nls } from '../../common/nls';
|
|
20
|
+
import { inject, injectable } from 'inversify';
|
|
21
|
+
import { LocalizationServer } from '../../common/i18n/localization-server';
|
|
22
|
+
|
|
23
|
+
@injectable()
|
|
24
|
+
export class I18nPreloadContribution implements PreloadContribution {
|
|
25
|
+
|
|
26
|
+
@inject(LocalizationServer)
|
|
27
|
+
protected readonly localizationServer: LocalizationServer;
|
|
28
|
+
|
|
29
|
+
async initialize(): Promise<void> {
|
|
30
|
+
const defaultLocale = FrontendApplicationConfigProvider.get().defaultLocale;
|
|
31
|
+
if (defaultLocale && !nls.locale) {
|
|
32
|
+
Object.assign(nls, {
|
|
33
|
+
locale: defaultLocale
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (nls.locale) {
|
|
37
|
+
const localization = await this.localizationServer.loadLocalization(nls.locale);
|
|
38
|
+
if (localization.languagePack) {
|
|
39
|
+
nls.localization = localization;
|
|
40
|
+
} else {
|
|
41
|
+
// In case the localization that we've loaded doesn't localize Theia completely (languagePack is false)
|
|
42
|
+
// We simply reset the locale to the default again
|
|
43
|
+
Object.assign(nls, {
|
|
44
|
+
locale: defaultLocale || undefined
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 TypeFox 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
|
+
import { inject, injectable } from 'inversify';
|
|
18
|
+
import { OS, OSBackendProvider } from '../../common';
|
|
19
|
+
import { PreloadContribution } from './preloader';
|
|
20
|
+
|
|
21
|
+
@injectable()
|
|
22
|
+
export class OSPreloadContribution implements PreloadContribution {
|
|
23
|
+
|
|
24
|
+
@inject(OSBackendProvider)
|
|
25
|
+
protected readonly osBackendProvider: OSBackendProvider;
|
|
26
|
+
|
|
27
|
+
async initialize(): Promise<void> {
|
|
28
|
+
const osType = await this.osBackendProvider.getBackendOS();
|
|
29
|
+
const isWindows = osType === 'Windows';
|
|
30
|
+
const isOSX = osType === 'OSX';
|
|
31
|
+
OS.backend.isOSX = isOSX;
|
|
32
|
+
OS.backend.isWindows = isWindows;
|
|
33
|
+
OS.backend.type = () => osType;
|
|
34
|
+
OS.backend.EOL = isWindows ? '\r\n' : '\n';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 TypeFox 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
|
+
import { ContainerModule } from 'inversify';
|
|
18
|
+
import { PreloadContribution, Preloader } from './preloader';
|
|
19
|
+
import { bindContributionProvider } from '../../common/contribution-provider';
|
|
20
|
+
import { I18nPreloadContribution } from './i18n-preload-contribution';
|
|
21
|
+
import { OSPreloadContribution } from './os-preload-contribution';
|
|
22
|
+
import { ThemePreloadContribution } from './theme-preload-contribution';
|
|
23
|
+
import { LocalizationServer, LocalizationServerPath } from '../../common/i18n/localization-server';
|
|
24
|
+
import { WebSocketConnectionProvider } from '../messaging/ws-connection-provider';
|
|
25
|
+
import { OSBackendProvider, OSBackendProviderPath } from '../../common/os';
|
|
26
|
+
|
|
27
|
+
export default new ContainerModule(bind => {
|
|
28
|
+
bind(Preloader).toSelf().inSingletonScope();
|
|
29
|
+
bindContributionProvider(bind, PreloadContribution);
|
|
30
|
+
|
|
31
|
+
bind(LocalizationServer).toDynamicValue(ctx =>
|
|
32
|
+
WebSocketConnectionProvider.createProxy<LocalizationServer>(ctx.container, LocalizationServerPath)
|
|
33
|
+
).inSingletonScope();
|
|
34
|
+
|
|
35
|
+
bind(OSBackendProvider).toDynamicValue(ctx =>
|
|
36
|
+
WebSocketConnectionProvider.createProxy<OSBackendProvider>(ctx.container, OSBackendProviderPath)
|
|
37
|
+
).inSingletonScope();
|
|
38
|
+
|
|
39
|
+
bind(I18nPreloadContribution).toSelf().inSingletonScope();
|
|
40
|
+
bind(PreloadContribution).toService(I18nPreloadContribution);
|
|
41
|
+
bind(OSPreloadContribution).toSelf().inSingletonScope();
|
|
42
|
+
bind(PreloadContribution).toService(OSPreloadContribution);
|
|
43
|
+
bind(ThemePreloadContribution).toSelf().inSingletonScope();
|
|
44
|
+
bind(PreloadContribution).toService(ThemePreloadContribution);
|
|
45
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 TypeFox 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
|
+
import { MaybePromise } from '../../common/types';
|
|
18
|
+
import { inject, injectable, interfaces, named } from 'inversify';
|
|
19
|
+
import { ContributionProvider } from '../../common/contribution-provider';
|
|
20
|
+
|
|
21
|
+
export const PreloadContribution = Symbol('PreloadContribution') as symbol & interfaces.Abstract<PreloadContribution>;
|
|
22
|
+
|
|
23
|
+
export interface PreloadContribution {
|
|
24
|
+
initialize(): MaybePromise<void>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@injectable()
|
|
28
|
+
export class Preloader {
|
|
29
|
+
|
|
30
|
+
@inject(ContributionProvider) @named(PreloadContribution)
|
|
31
|
+
protected readonly contributions: ContributionProvider<PreloadContribution>;
|
|
32
|
+
|
|
33
|
+
async initialize(): Promise<void> {
|
|
34
|
+
await Promise.allSettled(this.contributions.getContributions().map(contrib => contrib.initialize()));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 TypeFox 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
|
+
import { PreloadContribution } from './preloader';
|
|
18
|
+
import { DEFAULT_BACKGROUND_COLOR_STORAGE_KEY } from '../frontend-application-config-provider';
|
|
19
|
+
import { injectable } from 'inversify';
|
|
20
|
+
import { DefaultTheme } from '@theia/application-package';
|
|
21
|
+
|
|
22
|
+
@injectable()
|
|
23
|
+
export class ThemePreloadContribution implements PreloadContribution {
|
|
24
|
+
|
|
25
|
+
initialize(): void {
|
|
26
|
+
const dark = window.matchMedia?.('(prefers-color-scheme: dark)').matches;
|
|
27
|
+
const value = window.localStorage.getItem(DEFAULT_BACKGROUND_COLOR_STORAGE_KEY) || DefaultTheme.defaultBackgroundColor(dark);
|
|
28
|
+
document.documentElement.style.setProperty('--theia-editor-background', value);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
package/src/browser/saveable.ts
CHANGED
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
|
|
17
17
|
import { Widget } from '@phosphor/widgets';
|
|
18
18
|
import { Message } from '@phosphor/messaging';
|
|
19
|
-
import { Event } from '../common/event';
|
|
19
|
+
import { Emitter, Event } from '../common/event';
|
|
20
20
|
import { MaybePromise } from '../common/types';
|
|
21
21
|
import { Key } from './keyboard/keys';
|
|
22
22
|
import { AbstractDialog } from './dialogs';
|
|
23
23
|
import { waitForClosed } from './widgets';
|
|
24
24
|
import { nls } from '../common/nls';
|
|
25
|
-
import { isObject } from '../common';
|
|
25
|
+
import { Disposable, isObject } from '../common';
|
|
26
26
|
|
|
27
27
|
export interface Saveable {
|
|
28
28
|
readonly dirty: boolean;
|
|
@@ -50,6 +50,45 @@ export interface SaveableSource {
|
|
|
50
50
|
readonly saveable: Saveable;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
export class SaveableDelegate implements Saveable {
|
|
54
|
+
dirty = false;
|
|
55
|
+
protected readonly onDirtyChangedEmitter = new Emitter<void>();
|
|
56
|
+
|
|
57
|
+
get onDirtyChanged(): Event<void> {
|
|
58
|
+
return this.onDirtyChangedEmitter.event;
|
|
59
|
+
}
|
|
60
|
+
autoSave: 'off' | 'afterDelay' | 'onFocusChange' | 'onWindowChange' = 'off';
|
|
61
|
+
|
|
62
|
+
async save(options?: SaveOptions): Promise<void> {
|
|
63
|
+
await this.delegate?.save(options);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
revert?(options?: Saveable.RevertOptions): Promise<void>;
|
|
67
|
+
createSnapshot?(): Saveable.Snapshot;
|
|
68
|
+
applySnapshot?(snapshot: object): void;
|
|
69
|
+
|
|
70
|
+
protected delegate?: Saveable;
|
|
71
|
+
protected toDispose?: Disposable;
|
|
72
|
+
|
|
73
|
+
set(delegate: Saveable): void {
|
|
74
|
+
this.toDispose?.dispose();
|
|
75
|
+
this.delegate = delegate;
|
|
76
|
+
this.toDispose = this.delegate.onDirtyChanged(() => {
|
|
77
|
+
this.dirty = delegate.dirty;
|
|
78
|
+
this.onDirtyChangedEmitter.fire();
|
|
79
|
+
});
|
|
80
|
+
this.autoSave = delegate.autoSave;
|
|
81
|
+
if (this.dirty !== delegate.dirty) {
|
|
82
|
+
this.dirty = delegate.dirty;
|
|
83
|
+
this.onDirtyChangedEmitter.fire();
|
|
84
|
+
}
|
|
85
|
+
this.revert = delegate.revert?.bind(delegate);
|
|
86
|
+
this.createSnapshot = delegate.createSnapshot?.bind(delegate);
|
|
87
|
+
this.applySnapshot = delegate.applySnapshot?.bind(delegate);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
53
92
|
export namespace Saveable {
|
|
54
93
|
export interface RevertOptions {
|
|
55
94
|
/**
|
|
@@ -246,6 +246,9 @@ export class ApplicationShell extends Widget {
|
|
|
246
246
|
protected readonly onDidChangeCurrentWidgetEmitter = new Emitter<FocusTracker.IChangedArgs<Widget>>();
|
|
247
247
|
readonly onDidChangeCurrentWidget = this.onDidChangeCurrentWidgetEmitter.event;
|
|
248
248
|
|
|
249
|
+
protected readonly onDidDoubleClickMainAreaEmitter = new Emitter<void>();
|
|
250
|
+
readonly onDidDoubleClickMainArea = this.onDidDoubleClickMainAreaEmitter.event;
|
|
251
|
+
|
|
249
252
|
@inject(TheiaDockPanel.Factory)
|
|
250
253
|
protected readonly dockPanelFactory: TheiaDockPanel.Factory;
|
|
251
254
|
|
|
@@ -578,6 +581,14 @@ export class ApplicationShell extends Widget {
|
|
|
578
581
|
}
|
|
579
582
|
}
|
|
580
583
|
});
|
|
584
|
+
|
|
585
|
+
dockPanel.node.addEventListener('dblclick', event => {
|
|
586
|
+
const el = event.target as Element;
|
|
587
|
+
if (el.id === MAIN_AREA_ID || el.classList.contains('p-TabBar-content')) {
|
|
588
|
+
this.onDidDoubleClickMainAreaEmitter.fire();
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
|
|
581
592
|
const handler = (e: DragEvent) => {
|
|
582
593
|
if (e.dataTransfer) {
|
|
583
594
|
e.dataTransfer.dropEffect = 'link';
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
import debounce = require('lodash.debounce');
|
|
18
18
|
import { inject, injectable, named } from 'inversify';
|
|
19
19
|
// eslint-disable-next-line max-len
|
|
20
|
-
import { CommandMenuNode, CommandRegistry, CompoundMenuNode, ContributionProvider, Disposable, DisposableCollection, Emitter, Event, MenuModelRegistry, MenuPath } from '../../../common';
|
|
20
|
+
import { CommandMenuNode, CommandRegistry, CompoundMenuNode, ContributionProvider, Disposable, DisposableCollection, Emitter, Event, MenuModelRegistry, MenuNode, MenuPath } from '../../../common';
|
|
21
21
|
import { ContextKeyService } from '../../context-key-service';
|
|
22
22
|
import { FrontendApplicationContribution } from '../../frontend-application';
|
|
23
23
|
import { Widget } from '../../widgets';
|
|
24
|
-
import { MenuDelegate, ReactTabBarToolbarItem, TabBarToolbarItem } from './tab-bar-toolbar-types';
|
|
24
|
+
import { AnyToolbarItem, ConditionalToolbarItem, MenuDelegate, MenuToolbarItem, ReactTabBarToolbarItem, TabBarToolbarItem } from './tab-bar-toolbar-types';
|
|
25
25
|
import { ToolbarMenuNodeWrapper } from './tab-bar-toolbar-menu-adapters';
|
|
26
26
|
|
|
27
27
|
/**
|
|
@@ -103,10 +103,7 @@ export class TabBarToolbarRegistry implements FrontendApplicationContribution {
|
|
|
103
103
|
}
|
|
104
104
|
const result: Array<TabBarToolbarItem | ReactTabBarToolbarItem> = [];
|
|
105
105
|
for (const item of this.items.values()) {
|
|
106
|
-
|
|
107
|
-
? this.commandRegistry.isVisible(item.command, widget)
|
|
108
|
-
: (!item.isVisible || item.isVisible(widget));
|
|
109
|
-
if (visible && (!item.when || this.contextKeyService.match(item.when, widget.node))) {
|
|
106
|
+
if (this.isItemVisible(item, widget)) {
|
|
110
107
|
result.push(item);
|
|
111
108
|
}
|
|
112
109
|
}
|
|
@@ -139,6 +136,83 @@ export class TabBarToolbarRegistry implements FrontendApplicationContribution {
|
|
|
139
136
|
return result;
|
|
140
137
|
}
|
|
141
138
|
|
|
139
|
+
/**
|
|
140
|
+
* Query whether a toolbar `item` should be shown in the toolbar.
|
|
141
|
+
* This implementation delegates to item-specific checks according to their type.
|
|
142
|
+
*
|
|
143
|
+
* @param item a menu toolbar item
|
|
144
|
+
* @param widget the widget that is updating the toolbar
|
|
145
|
+
* @returns `false` if the `item` should be suppressed, otherwise `true`
|
|
146
|
+
*/
|
|
147
|
+
protected isItemVisible(item: TabBarToolbarItem | ReactTabBarToolbarItem, widget: Widget): boolean {
|
|
148
|
+
if (TabBarToolbarItem.is(item) && item.command && !this.isTabBarToolbarItemVisible(item, widget)) {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
if (MenuToolbarItem.is(item) && !this.isMenuToolbarItemVisible(item, widget)) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
if (AnyToolbarItem.isConditional(item) && !this.isConditionalItemVisible(item, widget)) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
// The item is not vetoed. Accept it
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Query whether a conditional toolbar `item` should be shown in the toolbar.
|
|
163
|
+
* This implementation delegates to the `item`'s own intrinsic conditionality.
|
|
164
|
+
*
|
|
165
|
+
* @param item a menu toolbar item
|
|
166
|
+
* @param widget the widget that is updating the toolbar
|
|
167
|
+
* @returns `false` if the `item` should be suppressed, otherwise `true`
|
|
168
|
+
*/
|
|
169
|
+
protected isConditionalItemVisible(item: ConditionalToolbarItem, widget: Widget): boolean {
|
|
170
|
+
if (item.isVisible && !item.isVisible(widget)) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
if (item.when && !this.contextKeyService.match(item.when, widget.node)) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Query whether a tab-bar toolbar `item` that has a command should be shown in the toolbar.
|
|
181
|
+
* This implementation returns `false` if the `item`'s command is not visible in the
|
|
182
|
+
* `widget` according to the command registry.
|
|
183
|
+
*
|
|
184
|
+
* @param item a tab-bar toolbar item that has a non-empty `command`
|
|
185
|
+
* @param widget the widget that is updating the toolbar
|
|
186
|
+
* @returns `false` if the `item` should be suppressed, otherwise `true`
|
|
187
|
+
*/
|
|
188
|
+
protected isTabBarToolbarItemVisible(item: TabBarToolbarItem, widget: Widget): boolean {
|
|
189
|
+
return this.commandRegistry.isVisible(item.command, widget);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Query whether a menu toolbar `item` should be shown in the toolbar.
|
|
194
|
+
* This implementation returns `false` if the `item` does not have any actual menu to show.
|
|
195
|
+
*
|
|
196
|
+
* @param item a menu toolbar item
|
|
197
|
+
* @param widget the widget that is updating the toolbar
|
|
198
|
+
* @returns `false` if the `item` should be suppressed, otherwise `true`
|
|
199
|
+
*/
|
|
200
|
+
protected isMenuToolbarItemVisible(item: MenuToolbarItem, widget: Widget): boolean {
|
|
201
|
+
const menu = this.menuRegistry.getMenu(item.menuPath);
|
|
202
|
+
const isVisible: (node: MenuNode) => boolean = node =>
|
|
203
|
+
node.children?.length
|
|
204
|
+
// Either the node is a sub-menu that has some visible child ...
|
|
205
|
+
? node.children?.some(isVisible)
|
|
206
|
+
// ... or there is a command ...
|
|
207
|
+
: !!node.command
|
|
208
|
+
// ... that is visible ...
|
|
209
|
+
&& this.commandRegistry.isVisible(node.command, widget)
|
|
210
|
+
// ... and a "when" clause does not suppress the menu node.
|
|
211
|
+
&& (!node.when || this.contextKeyService.match(node.when, widget?.node));
|
|
212
|
+
|
|
213
|
+
return isVisible(menu);
|
|
214
|
+
}
|
|
215
|
+
|
|
142
216
|
unregisterItem(itemOrId: TabBarToolbarItem | ReactTabBarToolbarItem | string): void {
|
|
143
217
|
const id = typeof itemOrId === 'string' ? itemOrId : itemOrId.id;
|
|
144
218
|
if (this.items.delete(id)) {
|
|
@@ -147,7 +221,7 @@ export class TabBarToolbarRegistry implements FrontendApplicationContribution {
|
|
|
147
221
|
}
|
|
148
222
|
|
|
149
223
|
registerMenuDelegate(menuPath: MenuPath, when?: string | ((widget: Widget) => boolean)): Disposable {
|
|
150
|
-
const id =
|
|
224
|
+
const id = this.toElementId(menuPath);
|
|
151
225
|
if (!this.menuDelegates.has(id)) {
|
|
152
226
|
const isVisible: MenuDelegate['isVisible'] = !when
|
|
153
227
|
? yes
|
|
@@ -163,8 +237,20 @@ export class TabBarToolbarRegistry implements FrontendApplicationContribution {
|
|
|
163
237
|
}
|
|
164
238
|
|
|
165
239
|
unregisterMenuDelegate(menuPath: MenuPath): void {
|
|
166
|
-
if (this.menuDelegates.delete(
|
|
240
|
+
if (this.menuDelegates.delete(this.toElementId(menuPath))) {
|
|
167
241
|
this.fireOnDidChange();
|
|
168
242
|
}
|
|
169
243
|
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Generate a single ID string from a menu path that
|
|
247
|
+
* is likely to be unique amongst the items in the toolbar.
|
|
248
|
+
*
|
|
249
|
+
* @param menuPath a menubar path
|
|
250
|
+
* @returns a likely unique ID based on the path
|
|
251
|
+
*/
|
|
252
|
+
toElementId(menuPath: MenuPath): string {
|
|
253
|
+
return menuPath.join(menuDelegateSeparator);
|
|
254
|
+
}
|
|
255
|
+
|
|
170
256
|
}
|
|
@@ -83,7 +83,7 @@ export interface MenuToolbarItem {
|
|
|
83
83
|
menuPath: MenuPath;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
interface ConditionalToolbarItem {
|
|
86
|
+
export interface ConditionalToolbarItem {
|
|
87
87
|
/**
|
|
88
88
|
* https://code.visualstudio.com/docs/getstarted/keybindings#_when-clause-contexts
|
|
89
89
|
*/
|
|
@@ -130,6 +130,7 @@ export interface TabBarToolbarItem extends RegisteredToolbarItem,
|
|
|
130
130
|
RenderedToolbarItem,
|
|
131
131
|
Omit<ConditionalToolbarItem, 'isVisible'>,
|
|
132
132
|
Pick<InlineToolbarItemMetadata, 'priority'>,
|
|
133
|
+
Partial<MenuToolbarItem>,
|
|
133
134
|
Partial<MenuToolbarItemMetadata> { }
|
|
134
135
|
|
|
135
136
|
/**
|
|
@@ -174,7 +175,33 @@ export namespace TabBarToolbarItem {
|
|
|
174
175
|
}
|
|
175
176
|
|
|
176
177
|
export namespace MenuToolbarItem {
|
|
178
|
+
/**
|
|
179
|
+
* Type guard for a toolbar item that actually is a menu item, amongst
|
|
180
|
+
* the other kinds of item that it may also be.
|
|
181
|
+
*
|
|
182
|
+
* @param item a toolbar item
|
|
183
|
+
* @returns whether the `item` is a menu item
|
|
184
|
+
*/
|
|
185
|
+
export function is<T extends AnyToolbarItem>(item: T): item is T & MenuToolbarItem {
|
|
186
|
+
return Array.isArray(item.menuPath);
|
|
187
|
+
}
|
|
188
|
+
|
|
177
189
|
export function getMenuPath(item: AnyToolbarItem): MenuPath | undefined {
|
|
178
190
|
return Array.isArray(item.menuPath) ? item.menuPath : undefined;
|
|
179
191
|
}
|
|
180
192
|
}
|
|
193
|
+
|
|
194
|
+
export namespace AnyToolbarItem {
|
|
195
|
+
/**
|
|
196
|
+
* Type guard for a toolbar item that actually manifests any of the
|
|
197
|
+
* features of a conditional toolbar item.
|
|
198
|
+
*
|
|
199
|
+
* @param item a toolbar item
|
|
200
|
+
* @returns whether the `item` is a conditional item
|
|
201
|
+
*/
|
|
202
|
+
export function isConditional<T extends AnyToolbarItem>(item: T): item is T & ConditionalToolbarItem {
|
|
203
|
+
return 'isVisible' in item && typeof item.isVisible === 'function'
|
|
204
|
+
|| 'onDidChange' in item && typeof item.onDidChange === 'function'
|
|
205
|
+
|| 'when' in item && typeof item.when === 'string';
|
|
206
|
+
}
|
|
207
|
+
}
|