@theia/core 1.74.0-next.8 → 1.74.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 +10 -10
- package/i18n/nls.cs.json +143 -16
- package/i18n/nls.de.json +143 -16
- package/i18n/nls.es.json +143 -16
- package/i18n/nls.fr.json +143 -16
- package/i18n/nls.hu.json +143 -16
- package/i18n/nls.it.json +143 -16
- package/i18n/nls.ja.json +143 -16
- package/i18n/nls.json +143 -16
- package/i18n/nls.ko.json +143 -16
- package/i18n/nls.pl.json +143 -16
- package/i18n/nls.pt-br.json +143 -16
- package/i18n/nls.ru.json +143 -16
- package/i18n/nls.tr.json +143 -16
- package/i18n/nls.zh-cn.json +143 -16
- package/i18n/nls.zh-tw.json +143 -16
- package/lib/browser/browser-clipboard-service.d.ts +3 -0
- package/lib/browser/browser-clipboard-service.d.ts.map +1 -1
- package/lib/browser/browser-clipboard-service.js +8 -1
- package/lib/browser/browser-clipboard-service.js.map +1 -1
- package/lib/browser/catalog.json +419 -41
- package/lib/browser/clipboard-service.d.ts +11 -0
- package/lib/browser/clipboard-service.d.ts.map +1 -1
- package/lib/browser/clipboard-service.js.map +1 -1
- package/lib/browser/common-frontend-contribution.d.ts.map +1 -1
- package/lib/browser/common-frontend-contribution.js +7 -7
- package/lib/browser/common-frontend-contribution.js.map +1 -1
- package/lib/browser/frontend-application-module.d.ts.map +1 -1
- package/lib/browser/frontend-application-module.js +9 -0
- package/lib/browser/frontend-application-module.js.map +1 -1
- package/lib/browser/frontend-application.d.ts.map +1 -1
- package/lib/browser/frontend-application.js +12 -2
- package/lib/browser/frontend-application.js.map +1 -1
- package/lib/browser/index.d.ts +1 -0
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +1 -0
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/keybinding.d.ts.map +1 -1
- package/lib/browser/keybinding.js +12 -7
- package/lib/browser/keybinding.js.map +1 -1
- package/lib/browser/perspective-service.d.ts +173 -0
- package/lib/browser/perspective-service.d.ts.map +1 -0
- package/lib/browser/perspective-service.js +484 -0
- package/lib/browser/perspective-service.js.map +1 -0
- package/lib/browser/perspective-service.spec.d.ts +2 -0
- package/lib/browser/perspective-service.spec.d.ts.map +1 -0
- package/lib/browser/perspective-service.spec.js +1806 -0
- package/lib/browser/perspective-service.spec.js.map +1 -0
- package/lib/browser/preferences/preference-contribution.d.ts.map +1 -1
- package/lib/browser/preferences/preference-contribution.js +9 -1
- package/lib/browser/preferences/preference-contribution.js.map +1 -1
- package/lib/browser/preferences/preference-service.spec.js +63 -0
- package/lib/browser/preferences/preference-service.spec.js.map +1 -1
- package/lib/browser/shell/application-shell.d.ts +7 -0
- package/lib/browser/shell/application-shell.d.ts.map +1 -1
- package/lib/browser/shell/application-shell.js +38 -28
- package/lib/browser/shell/application-shell.js.map +1 -1
- package/lib/browser/shell/shell-layout-restorer.d.ts +9 -0
- package/lib/browser/shell/shell-layout-restorer.d.ts.map +1 -1
- package/lib/browser/shell/shell-layout-restorer.js +124 -14
- package/lib/browser/shell/shell-layout-restorer.js.map +1 -1
- package/lib/browser/shell/shell-layout-restorer.spec.d.ts +2 -0
- package/lib/browser/shell/shell-layout-restorer.spec.d.ts.map +1 -0
- package/lib/browser/shell/shell-layout-restorer.spec.js +539 -0
- package/lib/browser/shell/shell-layout-restorer.spec.js.map +1 -0
- package/lib/browser/shell/view-contribution.d.ts +2 -0
- package/lib/browser/shell/view-contribution.d.ts.map +1 -1
- package/lib/browser/shell/view-contribution.js +5 -1
- package/lib/browser/shell/view-contribution.js.map +1 -1
- package/lib/browser/status-bar/status-bar.d.ts +2 -0
- package/lib/browser/status-bar/status-bar.d.ts.map +1 -1
- package/lib/browser/status-bar/status-bar.js +11 -3
- package/lib/browser/status-bar/status-bar.js.map +1 -1
- package/lib/browser/tree/tree-widget.d.ts +7 -33
- package/lib/browser/tree/tree-widget.d.ts.map +1 -1
- package/lib/browser/tree/tree-widget.js +7 -54
- package/lib/browser/tree/tree-widget.js.map +1 -1
- package/lib/browser/widgets/index.d.ts +1 -0
- package/lib/browser/widgets/index.d.ts.map +1 -1
- package/lib/browser/widgets/index.js +1 -0
- package/lib/browser/widgets/index.js.map +1 -1
- package/lib/browser/widgets/select-component.d.ts +2 -2
- package/lib/browser/widgets/select-component.d.ts.map +1 -1
- package/lib/browser/widgets/select-component.js +42 -12
- package/lib/browser/widgets/select-component.js.map +1 -1
- package/lib/browser/widgets/tab-bar-tracker.d.ts +23 -0
- package/lib/browser/widgets/tab-bar-tracker.d.ts.map +1 -0
- package/lib/browser/widgets/tab-bar-tracker.js +65 -0
- package/lib/browser/widgets/tab-bar-tracker.js.map +1 -0
- package/lib/browser/widgets/tab-bar-tracker.spec.d.ts +2 -0
- package/lib/browser/widgets/tab-bar-tracker.spec.d.ts.map +1 -0
- package/lib/browser/widgets/tab-bar-tracker.spec.js +109 -0
- package/lib/browser/widgets/tab-bar-tracker.spec.js.map +1 -0
- package/lib/browser-only/messaging/frontend-only-service-connection-provider.d.ts +13 -2
- package/lib/browser-only/messaging/frontend-only-service-connection-provider.d.ts.map +1 -1
- package/lib/browser-only/messaging/frontend-only-service-connection-provider.js +31 -3
- package/lib/browser-only/messaging/frontend-only-service-connection-provider.js.map +1 -1
- package/lib/common/preferences/index.d.ts +1 -0
- package/lib/common/preferences/index.d.ts.map +1 -1
- package/lib/common/preferences/index.js +1 -0
- package/lib/common/preferences/index.js.map +1 -1
- package/lib/common/preferences/preference-provider.d.ts +15 -0
- package/lib/common/preferences/preference-provider.d.ts.map +1 -1
- package/lib/common/preferences/preference-provider.js +21 -1
- package/lib/common/preferences/preference-provider.js.map +1 -1
- package/lib/common/preferences/preference-provider.spec.js +17 -0
- package/lib/common/preferences/preference-provider.spec.js.map +1 -1
- package/lib/common/preferences/preference-scope.d.ts +6 -1
- package/lib/common/preferences/preference-scope.d.ts.map +1 -1
- package/lib/common/preferences/preference-scope.js +5 -0
- package/lib/common/preferences/preference-scope.js.map +1 -1
- package/lib/common/preferences/preference-scope.spec.js +5 -3
- package/lib/common/preferences/preference-scope.spec.js.map +1 -1
- package/lib/common/preferences/preference-service.d.ts +19 -0
- package/lib/common/preferences/preference-service.d.ts.map +1 -1
- package/lib/common/preferences/preference-service.js +34 -5
- package/lib/common/preferences/preference-service.js.map +1 -1
- package/lib/common/preferences/session-preference-provider.d.ts +17 -0
- package/lib/common/preferences/session-preference-provider.d.ts.map +1 -0
- package/lib/common/preferences/session-preference-provider.js +77 -0
- package/lib/common/preferences/session-preference-provider.js.map +1 -0
- package/lib/common/preferences/session-preference-provider.spec.d.ts +2 -0
- package/lib/common/preferences/session-preference-provider.spec.d.ts.map +1 -0
- package/lib/common/preferences/session-preference-provider.spec.js +71 -0
- package/lib/common/preferences/session-preference-provider.spec.js.map +1 -0
- package/lib/electron-browser/electron-clipboard-service.d.ts +3 -0
- package/lib/electron-browser/electron-clipboard-service.d.ts.map +1 -1
- package/lib/electron-browser/electron-clipboard-service.js +6 -0
- package/lib/electron-browser/electron-clipboard-service.js.map +1 -1
- package/lib/electron-browser/preload.d.ts.map +1 -1
- package/lib/electron-browser/preload.js +2 -1
- 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 +43 -0
- package/lib/electron-main/electron-api-main.js.map +1 -1
- package/lib/electron-main/electron-main-application.d.ts.map +1 -1
- package/lib/electron-main/electron-main-application.js +3 -0
- package/lib/electron-main/electron-main-application.js.map +1 -1
- package/lib/electron-node/hosting/electron-backend-hosting-module.d.ts.map +1 -1
- package/lib/electron-node/hosting/electron-backend-hosting-module.js +7 -0
- package/lib/electron-node/hosting/electron-backend-hosting-module.js.map +1 -1
- package/lib/electron-node/hosting/electron-backend-hosting-module.spec.d.ts +2 -0
- package/lib/electron-node/hosting/electron-backend-hosting-module.spec.d.ts.map +1 -0
- package/lib/electron-node/hosting/electron-backend-hosting-module.spec.js +39 -0
- package/lib/electron-node/hosting/electron-backend-hosting-module.spec.js.map +1 -0
- package/lib/node/hosting/backend-hosting-module.d.ts.map +1 -1
- package/lib/node/hosting/backend-hosting-module.js +4 -1
- package/lib/node/hosting/backend-hosting-module.js.map +1 -1
- package/lib/node/hosting/browser-connection-token.d.ts +29 -1
- package/lib/node/hosting/browser-connection-token.d.ts.map +1 -1
- package/lib/node/hosting/browser-connection-token.js +25 -1
- package/lib/node/hosting/browser-connection-token.js.map +1 -1
- package/lib/node/hosting/browser-connection-token.spec.js +70 -0
- package/lib/node/hosting/browser-connection-token.spec.js.map +1 -1
- package/lib/node/index.d.ts +1 -0
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +3 -1
- package/lib/node/index.js.map +1 -1
- package/package.json +11 -11
- package/src/browser/browser-clipboard-service.ts +7 -1
- package/src/browser/clipboard-service.ts +11 -0
- package/src/browser/common-frontend-contribution.ts +7 -7
- package/src/browser/frontend-application-module.ts +11 -1
- package/src/browser/frontend-application.ts +12 -4
- package/src/browser/index.ts +1 -0
- package/src/browser/keybinding.ts +12 -7
- package/src/browser/perspective-service.spec.ts +2270 -0
- package/src/browser/perspective-service.ts +625 -0
- package/src/browser/preferences/preference-contribution.ts +9 -1
- package/src/browser/preferences/preference-service.spec.ts +72 -0
- package/src/browser/shell/application-shell.ts +41 -26
- package/src/browser/shell/shell-layout-restorer.spec.ts +746 -0
- package/src/browser/shell/shell-layout-restorer.ts +134 -13
- package/src/browser/shell/view-contribution.ts +6 -1
- package/src/browser/status-bar/status-bar.tsx +13 -3
- package/src/browser/style/select-component.css +16 -0
- package/src/browser/style/sidepanel.css +5 -0
- package/src/browser/style/status-bar.css +1 -1
- package/src/browser/tree/tree-widget.tsx +12 -78
- package/src/browser/widgets/index.ts +1 -0
- package/src/browser/widgets/select-component.tsx +41 -12
- package/src/browser/widgets/tab-bar-tracker.spec.ts +121 -0
- package/src/browser/widgets/tab-bar-tracker.ts +68 -0
- package/src/browser-only/messaging/frontend-only-service-connection-provider.ts +32 -3
- package/src/common/i18n/nls.metadata.json +4149 -888
- package/src/common/preferences/index.ts +1 -0
- package/src/common/preferences/preference-provider.spec.ts +17 -0
- package/src/common/preferences/preference-provider.ts +22 -1
- package/src/common/preferences/preference-scope.spec.ts +5 -3
- package/src/common/preferences/preference-scope.ts +6 -1
- package/src/common/preferences/preference-service.ts +39 -5
- package/src/common/preferences/session-preference-provider.spec.ts +78 -0
- package/src/common/preferences/session-preference-provider.ts +69 -0
- package/src/electron-browser/electron-clipboard-service.ts +5 -0
- package/src/electron-browser/menu/electron-menu-style.css +3 -1
- package/src/electron-browser/preload.ts +5 -2
- package/src/electron-common/electron-api.ts +4 -0
- package/src/electron-main/electron-api-main.ts +56 -3
- package/src/electron-main/electron-main-application.ts +3 -0
- package/src/electron-node/hosting/electron-backend-hosting-module.spec.ts +42 -0
- package/src/electron-node/hosting/electron-backend-hosting-module.ts +8 -0
- package/src/node/hosting/backend-hosting-module.ts +5 -2
- package/src/node/hosting/browser-connection-token.spec.ts +92 -0
- package/src/node/hosting/browser-connection-token.ts +45 -1
- package/src/node/index.ts +1 -0
|
@@ -0,0 +1,625 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2026 EclipseSource GmbH.
|
|
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, named, optional } from 'inversify';
|
|
18
|
+
import { DockLayout } from '@lumino/widgets';
|
|
19
|
+
import { ApplicationShell, WidgetAreaResolver } from './shell/application-shell';
|
|
20
|
+
import { SidePanel } from './shell/side-panel-handler';
|
|
21
|
+
import { FrontendApplicationContribution } from './frontend-application-contribution';
|
|
22
|
+
import { AbstractViewContribution } from './shell/view-contribution';
|
|
23
|
+
import { WidgetManager } from './widget-manager';
|
|
24
|
+
import { ContributionProvider } from '../common/contribution-provider';
|
|
25
|
+
import { Command, CommandContribution, CommandRegistry } from '../common/command';
|
|
26
|
+
import { Emitter, Event } from '../common/event';
|
|
27
|
+
import { ILogger } from '../common/logger';
|
|
28
|
+
import { QuickInputService, QuickPickItem } from '../common/quick-pick-service';
|
|
29
|
+
import { nls } from '../common/nls';
|
|
30
|
+
import { CommonCommands } from './common-commands';
|
|
31
|
+
import { ContextKeyService } from './context-key-service';
|
|
32
|
+
|
|
33
|
+
export const ACTIVE_PERSPECTIVE_CONTEXT_KEY = 'activePerspectiveId';
|
|
34
|
+
|
|
35
|
+
export interface PerspectiveChromeOptions {
|
|
36
|
+
/** Areas to collapse on first activation. User can re-expand freely. */
|
|
37
|
+
collapseAreas?: ('left' | 'right' | 'bottom')[];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface PerspectiveDescriptor {
|
|
41
|
+
id: string;
|
|
42
|
+
label: string;
|
|
43
|
+
/** Widget/view-container ID → target shell area */
|
|
44
|
+
viewPlacements: Map<string, ApplicationShell.Area>;
|
|
45
|
+
/** Chrome control options for this perspective */
|
|
46
|
+
chromeOptions?: PerspectiveChromeOptions;
|
|
47
|
+
/** Per-area primary view: the widget to activate last in each shell area, so it gets focus. */
|
|
48
|
+
primaryViews?: Partial<Record<ApplicationShell.Area, string>>;
|
|
49
|
+
/** Called when perspective is activated */
|
|
50
|
+
onActivate?(shell: ApplicationShell): void;
|
|
51
|
+
/** Called when switching away */
|
|
52
|
+
onDeactivate?(shell: ApplicationShell): void;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const PerspectiveService = Symbol('PerspectiveService');
|
|
56
|
+
export interface PerspectiveService {
|
|
57
|
+
// --- High-level API (for general consumers) ---
|
|
58
|
+
|
|
59
|
+
/** Event fired whenever the active perspective changes. The payload is the new perspective ID. */
|
|
60
|
+
readonly onDidChangePerspective: Event<string>;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Registers a new perspective descriptor.
|
|
64
|
+
* Contributions should call this from their `PerspectiveContribution.registerPerspectives` callback.
|
|
65
|
+
*/
|
|
66
|
+
registerPerspective(descriptor: PerspectiveDescriptor): void;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Switches the workbench to the given perspective.
|
|
70
|
+
* Saves the current perspective's layout, then restores the target perspective's layout
|
|
71
|
+
* (or applies its `viewPlacements` on first activation). Concurrent calls are serialized.
|
|
72
|
+
*/
|
|
73
|
+
switchPerspective(id: string): Promise<void>;
|
|
74
|
+
|
|
75
|
+
/** Returns the descriptor of the currently active perspective, or `undefined` if none. */
|
|
76
|
+
getActivePerspective(): PerspectiveDescriptor | undefined;
|
|
77
|
+
|
|
78
|
+
/** Returns the target shell area for a widget in the active perspective, or `undefined` if unmapped. */
|
|
79
|
+
getAreaForView(viewId: string): ApplicationShell.Area | undefined;
|
|
80
|
+
|
|
81
|
+
/** Returns all registered perspective descriptors. */
|
|
82
|
+
getRegisteredPerspectives(): PerspectiveDescriptor[];
|
|
83
|
+
|
|
84
|
+
/** Returns the ID of the currently active perspective. A convenient alternative to `getActivePerspective()?.id` that always returns a string. */
|
|
85
|
+
getActivePerspectiveId(): string;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Resets the active perspective to its programmatic state (viewPlacements from its descriptor),
|
|
89
|
+
* discarding the saved layout. Does not affect other perspectives.
|
|
90
|
+
*/
|
|
91
|
+
resetCurrentPerspective(): Promise<void>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export const PerspectiveServiceInternal = Symbol('PerspectiveServiceInternal');
|
|
95
|
+
/**
|
|
96
|
+
* Internal plumbing API for layout persistence infrastructure.
|
|
97
|
+
* General consumers should use {@link PerspectiveService} instead.
|
|
98
|
+
*/
|
|
99
|
+
export interface PerspectiveServiceInternal {
|
|
100
|
+
/**
|
|
101
|
+
* Returns the ID of the currently active perspective.
|
|
102
|
+
* @internal Plumbing API, used by `ShellLayoutRestorer` for layout persistence.
|
|
103
|
+
*/
|
|
104
|
+
getActivePerspectiveId(): string;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Returns the IDs of all perspectives that have a saved (in-memory) layout snapshot.
|
|
108
|
+
* @internal Plumbing API, used by `ShellLayoutRestorer` for layout persistence.
|
|
109
|
+
*/
|
|
110
|
+
getSavedPerspectiveIds(): string[];
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Returns the saved in-memory layout for a perspective, or `undefined` if none exists.
|
|
114
|
+
* @internal Plumbing API, used by `ShellLayoutRestorer` for layout persistence.
|
|
115
|
+
*/
|
|
116
|
+
getSavedLayout(perspectiveId: string): ApplicationShell.LayoutData | undefined;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Stores an in-memory layout snapshot for a perspective.
|
|
120
|
+
* @internal Plumbing API, used by `ShellLayoutRestorer` for layout persistence.
|
|
121
|
+
*/
|
|
122
|
+
setSavedLayout(perspectiveId: string, layout: ApplicationShell.LayoutData): void;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Sets the active perspective ID (without triggering a switch).
|
|
126
|
+
* Returns `true` if the ID corresponds to a registered perspective, `false` otherwise.
|
|
127
|
+
* @internal Plumbing API, used by `ShellLayoutRestorer` during layout restore.
|
|
128
|
+
*/
|
|
129
|
+
setActivePerspectiveId(id: string): boolean;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The ID of the built-in default perspective.
|
|
133
|
+
* @internal Plumbing API, used by `ShellLayoutRestorer` for legacy migration.
|
|
134
|
+
*/
|
|
135
|
+
readonly defaultPerspectiveId: string;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Clears all saved in-memory layout snapshots.
|
|
139
|
+
* @internal Plumbing API, used by `ShellLayoutRestorer` during layout reset.
|
|
140
|
+
*/
|
|
141
|
+
clearSavedLayouts(): void;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Called by `ShellLayoutRestorer` after restoring a persisted layout to apply chrome options
|
|
145
|
+
* (e.g., status bar visibility) for the given perspective.
|
|
146
|
+
* @internal Plumbing API, used by `ShellLayoutRestorer` after layout restore.
|
|
147
|
+
*/
|
|
148
|
+
onLayoutRestored(activePerspectiveId: string): void;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export const PerspectiveContribution = Symbol('PerspectiveContribution');
|
|
152
|
+
export interface PerspectiveContribution {
|
|
153
|
+
registerPerspectives(service: PerspectiveService): void;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
@injectable()
|
|
157
|
+
export class WidgetAreaResolverImpl implements WidgetAreaResolver {
|
|
158
|
+
protected activePlacementMap = new Map<string, ApplicationShell.Area>();
|
|
159
|
+
|
|
160
|
+
setActivePlacementMap(map: Map<string, ApplicationShell.Area>): void {
|
|
161
|
+
this.activePlacementMap = map;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
resolveArea(widgetId: string, requestedArea: ApplicationShell.Area): ApplicationShell.Area | undefined {
|
|
165
|
+
return this.activePlacementMap.get(widgetId);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
@injectable()
|
|
170
|
+
export class PerspectiveServiceImpl implements FrontendApplicationContribution, CommandContribution, PerspectiveService, PerspectiveServiceInternal {
|
|
171
|
+
|
|
172
|
+
static readonly SWITCH_PERSPECTIVE_COMMAND = Command.toLocalizedCommand({
|
|
173
|
+
id: 'perspective.switch',
|
|
174
|
+
category: CommonCommands.VIEW_CATEGORY,
|
|
175
|
+
label: 'Switch Perspective (Experimental)'
|
|
176
|
+
}, 'theia/core/perspective/switchPerspective', CommonCommands.VIEW_CATEGORY_KEY);
|
|
177
|
+
|
|
178
|
+
static readonly RESET_PERSPECTIVE_COMMAND = Command.toLocalizedCommand({
|
|
179
|
+
id: 'perspective.reset',
|
|
180
|
+
category: CommonCommands.VIEW_CATEGORY,
|
|
181
|
+
label: 'Reset Perspective (Experimental)'
|
|
182
|
+
}, 'theia/core/perspective/resetPerspective', CommonCommands.VIEW_CATEGORY_KEY);
|
|
183
|
+
|
|
184
|
+
@inject(ApplicationShell)
|
|
185
|
+
protected readonly shell: ApplicationShell;
|
|
186
|
+
|
|
187
|
+
@inject(WidgetManager)
|
|
188
|
+
protected readonly widgetManager: WidgetManager;
|
|
189
|
+
|
|
190
|
+
@inject(ContributionProvider) @named(PerspectiveContribution) @optional()
|
|
191
|
+
protected readonly contributions: ContributionProvider<PerspectiveContribution> | undefined;
|
|
192
|
+
|
|
193
|
+
@inject(ContributionProvider) @named(FrontendApplicationContribution)
|
|
194
|
+
protected readonly appContributions: ContributionProvider<FrontendApplicationContribution>;
|
|
195
|
+
|
|
196
|
+
@inject(QuickInputService) @optional()
|
|
197
|
+
protected readonly quickInputService: QuickInputService | undefined;
|
|
198
|
+
|
|
199
|
+
@inject(ILogger) @named('core:PerspectiveService')
|
|
200
|
+
protected readonly logger: ILogger;
|
|
201
|
+
|
|
202
|
+
@inject(WidgetAreaResolver)
|
|
203
|
+
protected readonly widgetAreaResolver: WidgetAreaResolver;
|
|
204
|
+
|
|
205
|
+
@inject(ContextKeyService) @optional()
|
|
206
|
+
protected readonly contextKeyService: ContextKeyService | undefined;
|
|
207
|
+
|
|
208
|
+
static readonly DEFAULT_PERSPECTIVE_ID = 'default';
|
|
209
|
+
|
|
210
|
+
readonly defaultPerspectiveId = PerspectiveServiceImpl.DEFAULT_PERSPECTIVE_ID;
|
|
211
|
+
|
|
212
|
+
protected readonly perspectives = new Map<string, PerspectiveDescriptor>();
|
|
213
|
+
protected activePerspectiveId: string | undefined;
|
|
214
|
+
protected readonly savedLayouts = new Map<string, ApplicationShell.LayoutData>();
|
|
215
|
+
|
|
216
|
+
protected readonly onDidChangePerspectiveEmitter = new Emitter<string>();
|
|
217
|
+
readonly onDidChangePerspective: Event<string> = this.onDidChangePerspectiveEmitter.event;
|
|
218
|
+
|
|
219
|
+
protected switchInProgress: Promise<void> | undefined;
|
|
220
|
+
|
|
221
|
+
onLayoutRestored(activePerspectiveId: string): void {
|
|
222
|
+
this.updateActivePerspectiveContextKey(activePerspectiveId);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
initialize(): void {
|
|
226
|
+
this.registerPerspective({
|
|
227
|
+
id: PerspectiveServiceImpl.DEFAULT_PERSPECTIVE_ID,
|
|
228
|
+
label: nls.localizeByDefault('Default'),
|
|
229
|
+
viewPlacements: new Map()
|
|
230
|
+
});
|
|
231
|
+
this.activePerspectiveId = PerspectiveServiceImpl.DEFAULT_PERSPECTIVE_ID;
|
|
232
|
+
this.updateActivePerspectiveContextKey(PerspectiveServiceImpl.DEFAULT_PERSPECTIVE_ID);
|
|
233
|
+
|
|
234
|
+
if (this.contributions) {
|
|
235
|
+
for (const contribution of this.contributions.getContributions()) {
|
|
236
|
+
contribution.registerPerspectives(this);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
onStop(): void {
|
|
242
|
+
this.onDidChangePerspectiveEmitter.dispose();
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
protected updateActivePerspectiveContextKey(id: string): void {
|
|
246
|
+
this.contextKeyService?.createKey<string>(ACTIVE_PERSPECTIVE_CONTEXT_KEY, id).set(id);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
registerPerspective(descriptor: PerspectiveDescriptor): void {
|
|
250
|
+
this.perspectives.set(descriptor.id, descriptor);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
async switchPerspective(id: string): Promise<void> {
|
|
254
|
+
const pending = (this.switchInProgress ?? Promise.resolve())
|
|
255
|
+
.catch(() => { /* swallow previous rejection so next switch can proceed */ })
|
|
256
|
+
.then(() => this.doSwitchPerspective(id));
|
|
257
|
+
this.switchInProgress = pending;
|
|
258
|
+
try {
|
|
259
|
+
await pending;
|
|
260
|
+
} finally {
|
|
261
|
+
if (this.switchInProgress === pending) {
|
|
262
|
+
this.switchInProgress = undefined;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
protected async doSwitchPerspective(id: string): Promise<void> {
|
|
268
|
+
if (id === this.activePerspectiveId) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const descriptor = this.perspectives.get(id);
|
|
273
|
+
if (!descriptor) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const oldPerspective = this.getActivePerspective();
|
|
278
|
+
if (oldPerspective?.onDeactivate) {
|
|
279
|
+
oldPerspective.onDeactivate(this.shell);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (this.activePerspectiveId) {
|
|
283
|
+
this.savedLayouts.set(this.activePerspectiveId, this.shell.getLayoutData());
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
this.activePerspectiveId = id;
|
|
287
|
+
this.widgetAreaResolver.setActivePlacementMap(descriptor.viewPlacements);
|
|
288
|
+
|
|
289
|
+
try {
|
|
290
|
+
const savedLayout = this.savedLayouts.get(id);
|
|
291
|
+
if (savedLayout) {
|
|
292
|
+
const layoutWidgetIds = this.collectWidgetIds(savedLayout);
|
|
293
|
+
await this.healLayoutData(savedLayout);
|
|
294
|
+
await this.shell.setLayoutData(savedLayout);
|
|
295
|
+
this.detachStrayWidgets(layoutWidgetIds);
|
|
296
|
+
} else {
|
|
297
|
+
await this.applyViewPlacements(descriptor);
|
|
298
|
+
}
|
|
299
|
+
} catch (error) {
|
|
300
|
+
this.logger.warn('Failed to apply layout for perspective', error);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (descriptor.onActivate) {
|
|
304
|
+
descriptor.onActivate(this.shell);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
this.updateActivePerspectiveContextKey(id);
|
|
308
|
+
|
|
309
|
+
this.onDidChangePerspectiveEmitter.fire(id);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
protected async applyViewPlacements(descriptor: PerspectiveDescriptor): Promise<void> {
|
|
313
|
+
for (const [viewId, area] of descriptor.viewPlacements) {
|
|
314
|
+
try {
|
|
315
|
+
const widget = await this.widgetManager.getOrCreateWidget(viewId);
|
|
316
|
+
const currentTabBar = this.shell.getTabBarFor(widget);
|
|
317
|
+
if (currentTabBar) {
|
|
318
|
+
const currentArea = this.shell.getAreaFor(widget);
|
|
319
|
+
if (currentArea === area) {
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
await this.shell.addWidget(widget, { area });
|
|
324
|
+
} catch (error) {
|
|
325
|
+
this.logger.warn('Failed to create or place widget for perspective', error);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
for (const [viewId] of descriptor.viewPlacements) {
|
|
330
|
+
try {
|
|
331
|
+
await this.shell.activateWidget(viewId);
|
|
332
|
+
} catch (error) {
|
|
333
|
+
this.logger.warn('Failed to activate widget for perspective', error);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (descriptor.primaryViews) {
|
|
338
|
+
for (const viewId of Object.values(descriptor.primaryViews)) {
|
|
339
|
+
if (viewId) {
|
|
340
|
+
try {
|
|
341
|
+
await this.shell.activateWidget(viewId);
|
|
342
|
+
} catch (error) {
|
|
343
|
+
this.logger.warn('Failed to activate primary view for perspective', error);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if (descriptor.chromeOptions?.collapseAreas) {
|
|
350
|
+
for (const area of descriptor.chromeOptions.collapseAreas) {
|
|
351
|
+
await this.shell.collapsePanel(area);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
async resetCurrentPerspective(): Promise<void> {
|
|
357
|
+
const pending = (this.switchInProgress ?? Promise.resolve())
|
|
358
|
+
.catch(() => { /* swallow previous rejection so next reset can proceed */ })
|
|
359
|
+
.then(() => this.doResetCurrentPerspective());
|
|
360
|
+
this.switchInProgress = pending;
|
|
361
|
+
try {
|
|
362
|
+
await pending;
|
|
363
|
+
} finally {
|
|
364
|
+
if (this.switchInProgress === pending) {
|
|
365
|
+
this.switchInProgress = undefined;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
protected async doResetCurrentPerspective(): Promise<void> {
|
|
371
|
+
const descriptor = this.getActivePerspective();
|
|
372
|
+
if (!descriptor) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
this.savedLayouts.delete(descriptor.id);
|
|
377
|
+
|
|
378
|
+
try {
|
|
379
|
+
if (descriptor.id === PerspectiveServiceImpl.DEFAULT_PERSPECTIVE_ID) {
|
|
380
|
+
await this.resetDefaultPerspective();
|
|
381
|
+
} else {
|
|
382
|
+
await this.applyViewPlacements(descriptor);
|
|
383
|
+
}
|
|
384
|
+
} catch (error) {
|
|
385
|
+
this.logger.warn('Failed to apply layout for perspective', error);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if (descriptor.onActivate) {
|
|
389
|
+
descriptor.onActivate(this.shell);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
this.onDidChangePerspectiveEmitter.fire(descriptor.id);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
protected async resetDefaultPerspective(): Promise<void> {
|
|
396
|
+
// Phase 1: Relocate open views to their default areas
|
|
397
|
+
for (const contribution of this.appContributions.getContributions()) {
|
|
398
|
+
if (contribution instanceof AbstractViewContribution) {
|
|
399
|
+
const widgetId = contribution.effectiveWidgetId;
|
|
400
|
+
const targetArea = contribution.defaultViewOptions?.area;
|
|
401
|
+
if (!widgetId || !targetArea) {
|
|
402
|
+
continue;
|
|
403
|
+
}
|
|
404
|
+
const widget = this.widgetManager.tryGetWidget(widgetId);
|
|
405
|
+
if (widget && !widget.isDisposed && widget.isAttached) {
|
|
406
|
+
const currentArea = this.shell.getAreaFor(widget);
|
|
407
|
+
if (currentArea && currentArea !== targetArea) {
|
|
408
|
+
try {
|
|
409
|
+
await this.shell.addWidget(widget, { area: targetArea });
|
|
410
|
+
} catch (error) {
|
|
411
|
+
this.logger.warn('Failed to relocate widget during default perspective reset', widgetId, error);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
// Phase 2: Re-open closed views via openView({ activate: false }).
|
|
419
|
+
// Non-view contributions (e.g., Terminal) are skipped to avoid side effects
|
|
420
|
+
// like creating new terminal instances.
|
|
421
|
+
for (const contribution of this.appContributions.getContributions()) {
|
|
422
|
+
if (contribution instanceof AbstractViewContribution) {
|
|
423
|
+
try {
|
|
424
|
+
await contribution.openView({ activate: false });
|
|
425
|
+
} catch (error) {
|
|
426
|
+
this.logger.warn('Failed to open view during default perspective reset', error);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Views may be shared between multiple perspective. If a view exists in two or more perspectives
|
|
434
|
+
* and is closed in one of them, the shared widget is disposed. When switching back to the other
|
|
435
|
+
* perspective, we need to restore this widget (i.e. reopen the view).
|
|
436
|
+
* @param layout
|
|
437
|
+
*/
|
|
438
|
+
protected async healLayoutData(layout: ApplicationShell.LayoutData): Promise<void> {
|
|
439
|
+
if (layout.leftPanel) {
|
|
440
|
+
await this.healSidePanelLayout(layout.leftPanel);
|
|
441
|
+
}
|
|
442
|
+
if (layout.rightPanel) {
|
|
443
|
+
await this.healSidePanelLayout(layout.rightPanel);
|
|
444
|
+
}
|
|
445
|
+
if (layout.mainPanel?.main) {
|
|
446
|
+
await this.healDockAreaConfig(layout.mainPanel.main);
|
|
447
|
+
}
|
|
448
|
+
if (layout.bottomPanel?.config?.main) {
|
|
449
|
+
await this.healDockAreaConfig(layout.bottomPanel.config.main);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
protected async healSidePanelLayout(layout: SidePanel.LayoutData): Promise<void> {
|
|
454
|
+
if (!layout.items) {
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
for (const item of layout.items) {
|
|
458
|
+
if (item.widget?.isDisposed) {
|
|
459
|
+
try {
|
|
460
|
+
item.widget = await this.widgetManager.getOrCreateWidget(item.widget.id);
|
|
461
|
+
} catch (error) {
|
|
462
|
+
this.logger.warn('Failed to recreate disposed widget for perspective layout', item.widget.id, error);
|
|
463
|
+
item.widget = undefined;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
protected async healDockAreaConfig(config: DockLayout.ITabAreaConfig | DockLayout.ISplitAreaConfig): Promise<void> {
|
|
470
|
+
if (config.type === 'tab-area') {
|
|
471
|
+
for (let i = 0; i < config.widgets.length; i++) {
|
|
472
|
+
const widget = config.widgets[i];
|
|
473
|
+
if (widget.isDisposed) {
|
|
474
|
+
try {
|
|
475
|
+
config.widgets[i] = await this.widgetManager.getOrCreateWidget(widget.id);
|
|
476
|
+
} catch (error) {
|
|
477
|
+
this.logger.warn('Failed to recreate disposed widget for perspective layout', widget.id, error);
|
|
478
|
+
config.widgets.splice(i, 1);
|
|
479
|
+
i--;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
} else if (config.type === 'split-area') {
|
|
484
|
+
for (const child of config.children) {
|
|
485
|
+
await this.healDockAreaConfig(child);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
protected collectWidgetIds(layout: ApplicationShell.LayoutData): Set<string> {
|
|
491
|
+
const ids = new Set<string>();
|
|
492
|
+
if (layout.leftPanel) {
|
|
493
|
+
this.collectSidePanelWidgetIds(layout.leftPanel, ids);
|
|
494
|
+
}
|
|
495
|
+
if (layout.rightPanel) {
|
|
496
|
+
this.collectSidePanelWidgetIds(layout.rightPanel, ids);
|
|
497
|
+
}
|
|
498
|
+
if (layout.mainPanel?.main) {
|
|
499
|
+
this.collectDockWidgetIds(layout.mainPanel.main, ids);
|
|
500
|
+
}
|
|
501
|
+
if (layout.bottomPanel?.config?.main) {
|
|
502
|
+
this.collectDockWidgetIds(layout.bottomPanel.config.main, ids);
|
|
503
|
+
}
|
|
504
|
+
return ids;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
protected collectSidePanelWidgetIds(layout: SidePanel.LayoutData, ids: Set<string>): void {
|
|
508
|
+
if (layout.items) {
|
|
509
|
+
for (const item of layout.items) {
|
|
510
|
+
if (item.widget) {
|
|
511
|
+
ids.add(item.widget.id);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
protected collectDockWidgetIds(
|
|
518
|
+
config: DockLayout.ITabAreaConfig | DockLayout.ISplitAreaConfig,
|
|
519
|
+
ids: Set<string>
|
|
520
|
+
): void {
|
|
521
|
+
if (config.type === 'tab-area') {
|
|
522
|
+
for (const widget of config.widgets) {
|
|
523
|
+
if (widget) {
|
|
524
|
+
ids.add(widget.id);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
} else if (config.type === 'split-area') {
|
|
528
|
+
for (const child of config.children) {
|
|
529
|
+
this.collectDockWidgetIds(child, ids);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
protected detachStrayWidgets(layoutWidgetIds: Set<string>): void {
|
|
535
|
+
const sidePanelAreas: ApplicationShell.Area[] = ['left', 'right'];
|
|
536
|
+
for (const area of sidePanelAreas) {
|
|
537
|
+
for (const widget of this.shell.getWidgets(area)) {
|
|
538
|
+
if (!layoutWidgetIds.has(widget.id)) {
|
|
539
|
+
// Detach via parent = null rather than widget.close() to avoid
|
|
540
|
+
// disposing the widget — it may be needed by another perspective.
|
|
541
|
+
// eslint-disable-next-line no-null/no-null
|
|
542
|
+
widget.parent = null;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
getActivePerspective(): PerspectiveDescriptor | undefined {
|
|
549
|
+
if (this.activePerspectiveId) {
|
|
550
|
+
return this.perspectives.get(this.activePerspectiveId);
|
|
551
|
+
}
|
|
552
|
+
return undefined;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
getAreaForView(viewId: string): ApplicationShell.Area | undefined {
|
|
556
|
+
const active = this.getActivePerspective();
|
|
557
|
+
if (active) {
|
|
558
|
+
return active.viewPlacements.get(viewId);
|
|
559
|
+
}
|
|
560
|
+
return undefined;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
getRegisteredPerspectives(): PerspectiveDescriptor[] {
|
|
564
|
+
return Array.from(this.perspectives.values());
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
getActivePerspectiveId(): string {
|
|
568
|
+
return this.activePerspectiveId ?? PerspectiveServiceImpl.DEFAULT_PERSPECTIVE_ID;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
getSavedPerspectiveIds(): string[] {
|
|
572
|
+
return Array.from(this.savedLayouts.keys());
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
getSavedLayout(perspectiveId: string): ApplicationShell.LayoutData | undefined {
|
|
576
|
+
return this.savedLayouts.get(perspectiveId);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
setSavedLayout(perspectiveId: string, layout: ApplicationShell.LayoutData): void {
|
|
580
|
+
this.savedLayouts.set(perspectiveId, layout);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
setActivePerspectiveId(id: string): boolean {
|
|
584
|
+
if (this.perspectives.has(id)) {
|
|
585
|
+
this.activePerspectiveId = id;
|
|
586
|
+
return true;
|
|
587
|
+
}
|
|
588
|
+
return false;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
clearSavedLayouts(): void {
|
|
592
|
+
this.savedLayouts.clear();
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
registerCommands(commands: CommandRegistry): void {
|
|
596
|
+
commands.registerCommand(PerspectiveServiceImpl.SWITCH_PERSPECTIVE_COMMAND, {
|
|
597
|
+
execute: () => this.showPerspectivePicker(),
|
|
598
|
+
isVisible: () => this.perspectives.size > 1
|
|
599
|
+
});
|
|
600
|
+
commands.registerCommand(PerspectiveServiceImpl.RESET_PERSPECTIVE_COMMAND, {
|
|
601
|
+
execute: () => this.resetCurrentPerspective(),
|
|
602
|
+
isEnabled: () => this.activePerspectiveId !== undefined
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
protected async showPerspectivePicker(): Promise<void> {
|
|
607
|
+
if (!this.quickInputService) {
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
const items: QuickPickItem[] = this.getRegisteredPerspectives().map(p => ({
|
|
612
|
+
label: p.label,
|
|
613
|
+
id: p.id,
|
|
614
|
+
description: this.activePerspectiveId === p.id ? nls.localizeByDefault('Active') : undefined
|
|
615
|
+
}));
|
|
616
|
+
|
|
617
|
+
const selected = await this.quickInputService.showQuickPick(items, {
|
|
618
|
+
placeholder: nls.localize('theia/core/perspective/selectPerspective', 'Select a perspective')
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
if (selected?.id) {
|
|
622
|
+
await this.switchPerspective(selected.id);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
@@ -22,16 +22,24 @@ import { isObject } from '../../common/types';
|
|
|
22
22
|
import { PreferenceSchemaServiceImpl } from '../../common/preferences/preference-schema-service';
|
|
23
23
|
import { PreferenceContribution, PreferenceSchemaService } from '../../common/preferences/preference-schema';
|
|
24
24
|
import { DefaultsPreferenceProvider } from '../../common/preferences/defaults-preference-provider';
|
|
25
|
+
import { SessionPreferenceProvider } from '../../common/preferences/session-preference-provider';
|
|
25
26
|
import { PreferenceLanguageOverrideService } from '../../common/preferences/preference-language-override-service';
|
|
26
27
|
import { FrontendConfigPreferenceContribution } from './frontend-config-preference-contributions';
|
|
27
28
|
import { bindPreferenceConfigurations } from '../../common/preferences/preference-configurations';
|
|
28
29
|
|
|
29
30
|
export function bindPreferenceSchemaProvider(bind: interfaces.Bind): void {
|
|
30
31
|
bindPreferenceConfigurations(bind);
|
|
31
|
-
bind(ValidPreferenceScopes).toConstantValue([
|
|
32
|
+
bind(ValidPreferenceScopes).toConstantValue([
|
|
33
|
+
PreferenceScope.Default,
|
|
34
|
+
PreferenceScope.User,
|
|
35
|
+
PreferenceScope.Workspace,
|
|
36
|
+
PreferenceScope.Folder,
|
|
37
|
+
PreferenceScope.Session
|
|
38
|
+
]);
|
|
32
39
|
bind(PreferenceSchemaServiceImpl).toSelf().inSingletonScope();
|
|
33
40
|
bind(PreferenceSchemaService).toService(PreferenceSchemaServiceImpl);
|
|
34
41
|
bind(PreferenceProvider).to(DefaultsPreferenceProvider).inSingletonScope().whenTargetNamed(PreferenceScope.Default);
|
|
42
|
+
bind(PreferenceProvider).to(SessionPreferenceProvider).inSingletonScope().whenTargetNamed(PreferenceScope.Session);
|
|
35
43
|
bind(PreferenceLanguageOverrideService).toSelf().inSingletonScope();
|
|
36
44
|
bindRootContributionProvider(bind, PreferenceContribution);
|
|
37
45
|
bind(PreferenceContribution).to(FrontendConfigPreferenceContribution).inSingletonScope();
|