@theia/workspace 1.77.0-next.1 → 1.77.0-next.101
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/lib/browser/canonical-uri-service.js +12 -16
- package/lib/browser/canonical-uri-service.js.map +1 -1
- package/lib/browser/diff-service.js +23 -29
- package/lib/browser/diff-service.js.map +1 -1
- package/lib/browser/index.d.ts +8 -8
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +8 -11
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/metadata-storage/index.d.ts +2 -2
- package/lib/browser/metadata-storage/index.d.ts.map +1 -1
- package/lib/browser/metadata-storage/index.js +2 -9
- package/lib/browser/metadata-storage/index.js.map +1 -1
- package/lib/browser/metadata-storage/workspace-metadata-storage-service.d.ts +6 -2
- package/lib/browser/metadata-storage/workspace-metadata-storage-service.d.ts.map +1 -1
- package/lib/browser/metadata-storage/workspace-metadata-storage-service.js +34 -36
- package/lib/browser/metadata-storage/workspace-metadata-storage-service.js.map +1 -1
- package/lib/browser/metadata-storage/workspace-metadata-storage-service.spec.js +70 -73
- package/lib/browser/metadata-storage/workspace-metadata-storage-service.spec.js.map +1 -1
- package/lib/browser/metadata-storage/workspace-metadata-store.d.ts +1 -1
- package/lib/browser/metadata-storage/workspace-metadata-store.d.ts.map +1 -1
- package/lib/browser/metadata-storage/workspace-metadata-store.js +19 -28
- package/lib/browser/metadata-storage/workspace-metadata-store.js.map +1 -1
- package/lib/browser/quick-open-workspace.d.ts +2 -2
- package/lib/browser/quick-open-workspace.d.ts.map +1 -1
- package/lib/browser/quick-open-workspace.js +31 -40
- package/lib/browser/quick-open-workspace.js.map +1 -1
- package/lib/browser/test/with-workspace-service-defaults.d.ts +8 -0
- package/lib/browser/test/with-workspace-service-defaults.d.ts.map +1 -0
- package/lib/browser/test/with-workspace-service-defaults.js +25 -0
- package/lib/browser/test/with-workspace-service-defaults.js.map +1 -0
- package/lib/browser/untitled-workspace-exit-dialog.js +13 -17
- package/lib/browser/untitled-workspace-exit-dialog.js.map +1 -1
- package/lib/browser/workspace-breadcrumbs-contribution.d.ts +3 -1
- package/lib/browser/workspace-breadcrumbs-contribution.d.ts.map +1 -1
- package/lib/browser/workspace-breadcrumbs-contribution.js +23 -14
- package/lib/browser/workspace-breadcrumbs-contribution.js.map +1 -1
- package/lib/browser/workspace-commands.d.ts +5 -5
- package/lib/browser/workspace-commands.d.ts.map +1 -1
- package/lib/browser/workspace-commands.js +129 -146
- package/lib/browser/workspace-commands.js.map +1 -1
- package/lib/browser/workspace-commands.spec.js +50 -52
- package/lib/browser/workspace-commands.spec.js.map +1 -1
- package/lib/browser/workspace-compare-handler.d.ts +1 -1
- package/lib/browser/workspace-compare-handler.d.ts.map +1 -1
- package/lib/browser/workspace-compare-handler.js +8 -12
- package/lib/browser/workspace-compare-handler.js.map +1 -1
- package/lib/browser/workspace-delete-handler.d.ts +2 -2
- package/lib/browser/workspace-delete-handler.d.ts.map +1 -1
- package/lib/browser/workspace-delete-handler.js +42 -51
- package/lib/browser/workspace-delete-handler.js.map +1 -1
- package/lib/browser/workspace-duplicate-handler.d.ts +2 -2
- package/lib/browser/workspace-duplicate-handler.d.ts.map +1 -1
- package/lib/browser/workspace-duplicate-handler.js +20 -27
- package/lib/browser/workspace-duplicate-handler.js.map +1 -1
- package/lib/browser/workspace-files-exclude-filter-provider.d.ts +1 -1
- package/lib/browser/workspace-files-exclude-filter-provider.d.ts.map +1 -1
- package/lib/browser/workspace-files-exclude-filter-provider.js +12 -19
- package/lib/browser/workspace-files-exclude-filter-provider.js.map +1 -1
- package/lib/browser/workspace-frontend-contribution.d.ts +4 -4
- package/lib/browser/workspace-frontend-contribution.d.ts.map +1 -1
- package/lib/browser/workspace-frontend-contribution.js +129 -143
- package/lib/browser/workspace-frontend-contribution.js.map +1 -1
- package/lib/browser/workspace-frontend-module.js +85 -87
- package/lib/browser/workspace-frontend-module.js.map +1 -1
- package/lib/browser/workspace-input-dialog.js +13 -18
- package/lib/browser/workspace-input-dialog.js.map +1 -1
- package/lib/browser/workspace-schema-updater.d.ts +1 -1
- package/lib/browser/workspace-schema-updater.d.ts.map +1 -1
- package/lib/browser/workspace-schema-updater.js +36 -40
- package/lib/browser/workspace-schema-updater.js.map +1 -1
- package/lib/browser/workspace-search-filter-service.js +13 -20
- package/lib/browser/workspace-search-filter-service.js.map +1 -1
- package/lib/browser/workspace-search-filter-service.spec.js +18 -20
- package/lib/browser/workspace-search-filter-service.spec.js.map +1 -1
- package/lib/browser/workspace-service.d.ts +134 -5
- package/lib/browser/workspace-service.d.ts.map +1 -1
- package/lib/browser/workspace-service.js +409 -157
- package/lib/browser/workspace-service.js.map +1 -1
- package/lib/browser/workspace-service.spec.d.ts +2 -0
- package/lib/browser/workspace-service.spec.d.ts.map +1 -0
- package/lib/browser/workspace-service.spec.js +425 -0
- package/lib/browser/workspace-service.spec.js.map +1 -0
- package/lib/browser/workspace-storage-service.d.ts +1 -1
- package/lib/browser/workspace-storage-service.d.ts.map +1 -1
- package/lib/browser/workspace-storage-service.js +13 -21
- package/lib/browser/workspace-storage-service.js.map +1 -1
- package/lib/browser/workspace-trust-dialog.js +9 -13
- package/lib/browser/workspace-trust-dialog.js.map +1 -1
- package/lib/browser/workspace-trust-service.d.ts +3 -3
- package/lib/browser/workspace-trust-service.d.ts.map +1 -1
- package/lib/browser/workspace-trust-service.js +106 -127
- package/lib/browser/workspace-trust-service.js.map +1 -1
- package/lib/browser/workspace-trust-service.spec.js +146 -148
- package/lib/browser/workspace-trust-service.spec.js.map +1 -1
- package/lib/browser/workspace-uri-contribution.d.ts +27 -2
- package/lib/browser/workspace-uri-contribution.d.ts.map +1 -1
- package/lib/browser/workspace-uri-contribution.js +79 -32
- package/lib/browser/workspace-uri-contribution.js.map +1 -1
- package/lib/browser/workspace-uri-contribution.spec.js +130 -70
- package/lib/browser/workspace-uri-contribution.spec.js.map +1 -1
- package/lib/browser/workspace-user-working-directory-provider.d.ts +1 -1
- package/lib/browser/workspace-user-working-directory-provider.d.ts.map +1 -1
- package/lib/browser/workspace-user-working-directory-provider.js +13 -18
- package/lib/browser/workspace-user-working-directory-provider.js.map +1 -1
- package/lib/browser/workspace-utils.d.ts +1 -1
- package/lib/browser/workspace-utils.d.ts.map +1 -1
- package/lib/browser/workspace-utils.js +8 -12
- package/lib/browser/workspace-utils.js.map +1 -1
- package/lib/browser/workspace-variable-contribution.d.ts +1 -1
- package/lib/browser/workspace-variable-contribution.d.ts.map +1 -1
- package/lib/browser/workspace-variable-contribution.js +37 -47
- package/lib/browser/workspace-variable-contribution.js.map +1 -1
- package/lib/browser/workspace-window-title-updater.d.ts +1 -1
- package/lib/browser/workspace-window-title-updater.d.ts.map +1 -1
- package/lib/browser/workspace-window-title-updater.js +12 -16
- package/lib/browser/workspace-window-title-updater.js.map +1 -1
- package/lib/browser-only/browser-only-workspace-server.d.ts +1 -1
- package/lib/browser-only/browser-only-workspace-server.d.ts.map +1 -1
- package/lib/browser-only/browser-only-workspace-server.js +17 -22
- package/lib/browser-only/browser-only-workspace-server.js.map +1 -1
- package/lib/browser-only/workspace-frontend-only-module.js +8 -10
- package/lib/browser-only/workspace-frontend-only-module.js.map +1 -1
- package/lib/common/index.d.ts +4 -4
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +4 -7
- package/lib/common/index.js.map +1 -1
- package/lib/common/test/mock-workspace-server.d.ts +1 -1
- package/lib/common/test/mock-workspace-server.d.ts.map +1 -1
- package/lib/common/test/mock-workspace-server.js +5 -8
- package/lib/common/test/mock-workspace-server.js.map +1 -1
- package/lib/common/untitled-workspace-service.d.ts +1 -1
- package/lib/common/untitled-workspace-service.d.ts.map +1 -1
- package/lib/common/untitled-workspace-service.js +8 -12
- package/lib/common/untitled-workspace-service.js.map +1 -1
- package/lib/common/workspace-file-service.js +11 -14
- package/lib/common/workspace-file-service.js.map +1 -1
- package/lib/common/workspace-preferences.js +14 -19
- package/lib/common/workspace-preferences.js.map +1 -1
- package/lib/common/workspace-protocol.js +2 -5
- package/lib/common/workspace-protocol.js.map +1 -1
- package/lib/common/workspace-trust-preferences.js +29 -34
- package/lib/common/workspace-trust-preferences.js.map +1 -1
- package/lib/electron-browser/electron-workspace-contribution.d.ts +1 -1
- package/lib/electron-browser/electron-workspace-contribution.d.ts.map +1 -1
- package/lib/electron-browser/electron-workspace-contribution.js +11 -15
- package/lib/electron-browser/electron-workspace-contribution.js.map +1 -1
- package/lib/electron-browser/electron-workspace-module.js +6 -8
- package/lib/electron-browser/electron-workspace-module.js.map +1 -1
- package/lib/node/default-workspace-server.d.ts +1 -1
- package/lib/node/default-workspace-server.d.ts.map +1 -1
- package/lib/node/default-workspace-server.js +51 -63
- package/lib/node/default-workspace-server.js.map +1 -1
- package/lib/node/default-workspace-server.spec.js +29 -31
- package/lib/node/default-workspace-server.spec.js.map +1 -1
- package/lib/node/index.d.ts +2 -2
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +2 -5
- package/lib/node/index.js.map +1 -1
- package/lib/node/workspace-backend-module.js +21 -23
- package/lib/node/workspace-backend-module.js.map +1 -1
- package/package.json +17 -5
- package/src/browser/index.ts +8 -8
- package/src/browser/metadata-storage/index.ts +2 -2
- package/src/browser/metadata-storage/workspace-metadata-storage-service.spec.ts +4 -5
- package/src/browser/metadata-storage/workspace-metadata-storage-service.ts +10 -3
- package/src/browser/metadata-storage/workspace-metadata-store.ts +1 -1
- package/src/browser/quick-open-workspace.ts +2 -2
- package/src/browser/test/with-workspace-service-defaults.ts +26 -0
- package/src/browser/workspace-breadcrumbs-contribution.ts +16 -1
- package/src/browser/workspace-commands.spec.ts +6 -6
- package/src/browser/workspace-commands.ts +7 -8
- package/src/browser/workspace-compare-handler.ts +1 -1
- package/src/browser/workspace-delete-handler.ts +2 -2
- package/src/browser/workspace-duplicate-handler.ts +2 -2
- package/src/browser/workspace-files-exclude-filter-provider.ts +1 -1
- package/src/browser/workspace-frontend-contribution.ts +10 -8
- package/src/browser/workspace-frontend-module.ts +25 -25
- package/src/browser/workspace-schema-updater.ts +5 -1
- package/src/browser/workspace-search-filter-service.spec.ts +1 -1
- package/src/browser/workspace-service.spec.ts +508 -0
- package/src/browser/workspace-service.ts +353 -44
- package/src/browser/workspace-storage-service.ts +1 -1
- package/src/browser/workspace-trust-service.spec.ts +2 -2
- package/src/browser/workspace-trust-service.ts +5 -5
- package/src/browser/workspace-uri-contribution.spec.ts +76 -6
- package/src/browser/workspace-uri-contribution.ts +61 -4
- package/src/browser/workspace-user-working-directory-provider.ts +1 -1
- package/src/browser/workspace-utils.ts +1 -1
- package/src/browser/workspace-variable-contribution.ts +1 -1
- package/src/browser/workspace-window-title-updater.ts +1 -1
- package/src/browser-only/browser-only-workspace-server.ts +1 -1
- package/src/browser-only/workspace-frontend-only-module.ts +2 -2
- package/src/common/index.ts +4 -4
- package/src/common/test/mock-workspace-server.ts +1 -1
- package/src/common/untitled-workspace-service.ts +1 -1
- package/src/electron-browser/electron-workspace-contribution.ts +1 -1
- package/src/electron-browser/electron-workspace-module.ts +1 -1
- package/src/node/default-workspace-server.spec.ts +2 -2
- package/src/node/default-workspace-server.ts +1 -1
- package/src/node/index.ts +2 -2
- package/src/node/workspace-backend-module.ts +3 -3
- package/src/typings/valid-filename.d.ts +20 -0
|
@@ -22,11 +22,11 @@ import * as sinon from 'sinon';
|
|
|
22
22
|
import { Container } from '@theia/core/shared/inversify';
|
|
23
23
|
import { Event } from '@theia/core/lib/common/event';
|
|
24
24
|
import { ApplicationShell, WidgetManager } from '@theia/core/lib/browser';
|
|
25
|
-
import { DefaultUriLabelProviderContribution } from '@theia/core/lib/browser/label-provider';
|
|
26
|
-
import { WorkspaceUriLabelProviderContribution } from './workspace-uri-contribution';
|
|
25
|
+
import { DefaultUriLabelProviderContribution, DidChangeLabelEvent } from '@theia/core/lib/browser/label-provider';
|
|
26
|
+
import { WorkspaceUriLabelProviderContribution } from './workspace-uri-contribution.js';
|
|
27
27
|
import URI from '@theia/core/lib/common/uri';
|
|
28
|
-
import { WorkspaceVariableContribution } from './workspace-variable-contribution';
|
|
29
|
-
import { WorkspaceService } from './workspace-service';
|
|
28
|
+
import { WorkspaceVariableContribution } from './workspace-variable-contribution.js';
|
|
29
|
+
import { WorkspaceService } from './workspace-service.js';
|
|
30
30
|
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
31
31
|
import { FileStat } from '@theia/filesystem/lib/common/files';
|
|
32
32
|
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
|
|
@@ -40,6 +40,12 @@ after(() => disableJSDOM());
|
|
|
40
40
|
let container: Container;
|
|
41
41
|
let labelProvider: WorkspaceUriLabelProviderContribution;
|
|
42
42
|
let roots: FileStat[];
|
|
43
|
+
let workspaceService: WorkspaceService;
|
|
44
|
+
/** Changes the roots, as `WorkspaceService.updateRoots` does, which resets their names. */
|
|
45
|
+
const setRoots = (newRoots: FileStat[]): void => {
|
|
46
|
+
roots = newRoots;
|
|
47
|
+
workspaceService['rootNamesCache'] = undefined;
|
|
48
|
+
};
|
|
43
49
|
beforeEach(() => {
|
|
44
50
|
roots = [FileStat.dir('file:///workspace')];
|
|
45
51
|
|
|
@@ -53,7 +59,7 @@ beforeEach(() => {
|
|
|
53
59
|
onDidCreateWidget: Event.None
|
|
54
60
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
61
|
} as any);
|
|
56
|
-
|
|
62
|
+
workspaceService = new WorkspaceService();
|
|
57
63
|
workspaceService.tryGetRoots = () => roots;
|
|
58
64
|
container.bind(WorkspaceService).toConstantValue(workspaceService);
|
|
59
65
|
container.bind(WorkspaceVariableContribution).toSelf().inSingletonScope();
|
|
@@ -138,6 +144,70 @@ describe('WorkspaceUriLabelProviderContribution class', () => {
|
|
|
138
144
|
const name = labelProvider.getName(file);
|
|
139
145
|
expect(name).eq('jacques.doc');
|
|
140
146
|
});
|
|
147
|
+
|
|
148
|
+
it('should return the folder name of a workspace root', () => {
|
|
149
|
+
setRoots([FileStat.dir('file:///home/alice/app'), FileStat.dir('file:///home/bob/lib')]);
|
|
150
|
+
expect(labelProvider.getName(FileStat.dir('file:///home/alice/app'))).eq('app');
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('should return the unique names of workspace roots sharing a folder name', () => {
|
|
154
|
+
setRoots([FileStat.dir('file:///home/alice/app'), FileStat.dir('file:///home/bob/app')]);
|
|
155
|
+
expect(labelProvider.getName(FileStat.dir('file:///home/alice/app'))).eq('alice/app');
|
|
156
|
+
expect(labelProvider.getName(new URI('file:///home/bob/app'))).eq('bob/app');
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('should return the folder name of a folder that shares its name with a workspace root', () => {
|
|
160
|
+
setRoots([FileStat.dir('file:///home/alice/app'), FileStat.dir('file:///home/bob/app')]);
|
|
161
|
+
expect(labelProvider.getName(FileStat.dir('file:///home/alice/app/app'))).eq('app');
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it('should notify a change of the name of a workspace root when a root sharing its folder name is added', () => {
|
|
165
|
+
setRoots([FileStat.dir('file:///home/alice/app'), FileStat.dir('file:///home/other')]);
|
|
166
|
+
workspaceService['onWorkspaceChangeEmitter'].fire(roots);
|
|
167
|
+
const events: DidChangeLabelEvent[] = [];
|
|
168
|
+
labelProvider.onDidChange(event => events.push(event));
|
|
169
|
+
setRoots([...roots, FileStat.dir('file:///home/bob/app')]);
|
|
170
|
+
workspaceService['onWorkspaceChangeEmitter'].fire(roots);
|
|
171
|
+
expect(events.some(event => event.affects(new URI('file:///home/alice/app')))).to.be.true;
|
|
172
|
+
expect(events.some(event => event.affects(FileStat.dir('file:///home/alice/app')))).to.be.true;
|
|
173
|
+
expect(events.some(event => event.affects(new URI('file:///home/other')))).to.be.false;
|
|
174
|
+
expect(labelProvider.getName(new URI('file:///home/alice/app'))).eq('alice/app');
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('should not return the name given to a workspace root in the workspace file', () => {
|
|
178
|
+
// The name is only shown where the folder is referred to as a root, e.g. not when browsing its parent in a file dialog.
|
|
179
|
+
setRoots([FileStat.dir('file:///home/alice/app'), FileStat.dir('file:///home/bob/lib')]);
|
|
180
|
+
sinon.stub(workspaceService, 'getConfiguredRootName').callsFake(uri => uri.isEqual(new URI('file:///home/alice/app')) ? 'My App' : undefined);
|
|
181
|
+
expect(labelProvider.getName(new URI('file:///home/alice/app'))).eq('app');
|
|
182
|
+
expect(labelProvider.getName(FileStat.dir('file:///home/alice/app'))).eq('app');
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('should notify a change of the labels of a workspace root and its files when the root is given a name in the workspace file', () => {
|
|
186
|
+
setRoots([FileStat.dir('file:///home/alice/app'), FileStat.dir('file:///home/bob/lib')]);
|
|
187
|
+
workspaceService['onWorkspaceChangeEmitter'].fire(roots);
|
|
188
|
+
const events: DidChangeLabelEvent[] = [];
|
|
189
|
+
labelProvider.onDidChange(event => events.push(event));
|
|
190
|
+
sinon.stub(workspaceService, 'getConfiguredRootName').callsFake(uri => uri.isEqual(new URI('file:///home/alice/app')) ? 'My App' : undefined);
|
|
191
|
+
workspaceService['onWorkspaceChangeEmitter'].fire(roots);
|
|
192
|
+
expect(events.some(event => event.affects(new URI('file:///home/alice/app')))).to.be.true;
|
|
193
|
+
expect(events.some(event => event.affects(new URI('file:///home/alice/app/src/index.ts')))).to.be.true;
|
|
194
|
+
expect(events.some(event => event.affects(new URI('file:///home/bob/lib')))).to.be.false;
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
describe('getDetails()', () => {
|
|
199
|
+
it('should prefix the path of a file with the unique name of its workspace root', () => {
|
|
200
|
+
setRoots([FileStat.dir('file:///home/alice/app'), FileStat.dir('file:///home/bob/app')]);
|
|
201
|
+
expect(labelProvider.getDetails(new URI('file:///home/bob/app/src/index.ts'))).eq('bob/app • src');
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it('should prefix the path of a file with the name given to its workspace root in the workspace file', () => {
|
|
205
|
+
setRoots([FileStat.dir('file:///home/alice/app'), FileStat.dir('file:///home/bob/app')]);
|
|
206
|
+
sinon.stub(workspaceService, 'getConfiguredRootName').callsFake(uri => uri.isEqual(new URI('file:///home/alice/app')) ? 'My App' : undefined);
|
|
207
|
+
expect(labelProvider.getDetails(new URI('file:///home/alice/app/src/index.ts'))).eq('My App • src');
|
|
208
|
+
// A root without a name keeps its unique name
|
|
209
|
+
expect(labelProvider.getDetails(new URI('file:///home/bob/app/src/index.ts'))).eq('bob/app • src');
|
|
210
|
+
});
|
|
141
211
|
});
|
|
142
212
|
|
|
143
213
|
describe('getLongName()', () => {
|
|
@@ -176,7 +246,7 @@ describe('WorkspaceUriLabelProviderContribution class', () => {
|
|
|
176
246
|
});
|
|
177
247
|
|
|
178
248
|
it('should return the path of a file if WorkspaceService returns no roots', () => {
|
|
179
|
-
|
|
249
|
+
setRoots([]);
|
|
180
250
|
const file = new URI('file:///tmp/prout.txt');
|
|
181
251
|
const longName = labelProvider.getLongName(file);
|
|
182
252
|
|
|
@@ -18,8 +18,8 @@ import { DefaultUriLabelProviderContribution, URIIconReference } from '@theia/co
|
|
|
18
18
|
import URI from '@theia/core/lib/common/uri';
|
|
19
19
|
import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
|
|
20
20
|
import { FileStat } from '@theia/filesystem/lib/common/files';
|
|
21
|
-
import { WorkspaceService } from './workspace-service';
|
|
22
|
-
import { WorkspaceVariableContribution } from './workspace-variable-contribution';
|
|
21
|
+
import { WorkspaceService } from './workspace-service.js';
|
|
22
|
+
import { WorkspaceVariableContribution } from './workspace-variable-contribution.js';
|
|
23
23
|
|
|
24
24
|
@injectable()
|
|
25
25
|
export class WorkspaceUriLabelProviderContribution extends DefaultUriLabelProviderContribution {
|
|
@@ -27,9 +27,48 @@ export class WorkspaceUriLabelProviderContribution extends DefaultUriLabelProvid
|
|
|
27
27
|
@inject(WorkspaceVariableContribution) protected readonly workspaceVariable: WorkspaceVariableContribution;
|
|
28
28
|
@inject(WorkspaceService) protected readonly workspaceService: WorkspaceService;
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* The names of the workspace roots by root URI, as last labeled.
|
|
32
|
+
*/
|
|
33
|
+
protected rootNames = new Map<string, string>();
|
|
34
|
+
|
|
30
35
|
@postConstruct()
|
|
31
36
|
override init(): void {
|
|
32
|
-
|
|
37
|
+
this.rootNames = this.getRootNamesByUri();
|
|
38
|
+
this.workspaceService.onWorkspaceChanged(() => this.updateRootNames());
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Returns the names shown for the workspace roots by root URI: the name given to a root in the workspace file,
|
|
43
|
+
* or else its unique name.
|
|
44
|
+
*/
|
|
45
|
+
protected getRootNamesByUri(): Map<string, string> {
|
|
46
|
+
return new Map(Array.from(this.workspaceService.getRootNames(),
|
|
47
|
+
([name, uri]) => [uri.toString(), this.workspaceService.getConfiguredRootName(uri) ?? name]));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Notifies a change of the labels of the roots whose names changed, such as a root named `app` that
|
|
52
|
+
* is named `alice/app` once a root `bob/app` is added, or a root that is given a name in the workspace file.
|
|
53
|
+
* The labels of the files in such a root change as well, as their details and breadcrumbs show the name of the root.
|
|
54
|
+
*/
|
|
55
|
+
protected updateRootNames(): void {
|
|
56
|
+
const rootNames = this.getRootNamesByUri();
|
|
57
|
+
const changed: URI[] = [];
|
|
58
|
+
for (const [uri, name] of rootNames) {
|
|
59
|
+
if (this.rootNames.get(uri) !== name) {
|
|
60
|
+
changed.push(new URI(uri));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
this.rootNames = rootNames;
|
|
64
|
+
if (changed.length > 0) {
|
|
65
|
+
this.onDidChangeEmitter.fire({
|
|
66
|
+
affects: element => {
|
|
67
|
+
const uri = this.canHandle(element) > 0 ? this.getUri(element as URI | URIIconReference | FileStat) : undefined;
|
|
68
|
+
return !!uri && changed.some(root => root.isEqualOrParent(uri));
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
33
72
|
}
|
|
34
73
|
|
|
35
74
|
override canHandle(element: object): number {
|
|
@@ -43,7 +82,16 @@ export class WorkspaceUriLabelProviderContribution extends DefaultUriLabelProvid
|
|
|
43
82
|
return super.getIcon(this.asURIIconReference(element));
|
|
44
83
|
}
|
|
45
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Names a workspace root by its unique name (see {@link WorkspaceService.getRootNames}), so that
|
|
87
|
+
* roots sharing a folder name can be told apart, e.g. `alice/app` and `bob/app`.
|
|
88
|
+
*/
|
|
46
89
|
override getName(element: URI | URIIconReference | FileStat): string | undefined {
|
|
90
|
+
const uri = this.getUri(element);
|
|
91
|
+
const rootName = uri && this.workspaceService.getRootName(uri);
|
|
92
|
+
if (rootName) {
|
|
93
|
+
return rootName;
|
|
94
|
+
}
|
|
47
95
|
return super.getName(this.asURIIconReference(element));
|
|
48
96
|
}
|
|
49
97
|
|
|
@@ -70,13 +118,22 @@ export class WorkspaceUriLabelProviderContribution extends DefaultUriLabelProvid
|
|
|
70
118
|
// Parent in order to omit the name - that's what comes out of `getName`, and `getDetails` should supplement, not duplicate.
|
|
71
119
|
const relativePath = uri && this.workspaceVariable.getWorkspaceRelativePath(uri.parent);
|
|
72
120
|
if (relativePath !== undefined) {
|
|
73
|
-
const prefix = this.workspaceService.tryGetRoots().length > 1 ? this.
|
|
121
|
+
const prefix = this.workspaceService.tryGetRoots().length > 1 ? this.getRootDisplayName(this.workspaceVariable.getWorkspaceRootUri(uri)!) : '';
|
|
74
122
|
const separator = prefix && relativePath ? ' • ' : '';
|
|
75
123
|
return prefix + separator + relativePath;
|
|
76
124
|
}
|
|
77
125
|
return this.getLongName(uri.parent);
|
|
78
126
|
}
|
|
79
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Returns the name given to the workspace root in the workspace file, or else its name from `getName`.
|
|
130
|
+
* Only used where the root is referred to as a root: elsewhere, e.g. in a file dialog, the name from the workspace file
|
|
131
|
+
* is not shown, as in VS Code.
|
|
132
|
+
*/
|
|
133
|
+
protected getRootDisplayName(rootUri: URI): string | undefined {
|
|
134
|
+
return this.workspaceService.getConfiguredRootName(rootUri) ?? this.getName(rootUri);
|
|
135
|
+
}
|
|
136
|
+
|
|
80
137
|
protected asURIIconReference(element: URI | URIIconReference | FileStat): URI | URIIconReference {
|
|
81
138
|
if (FileStat.is(element)) {
|
|
82
139
|
return URIIconReference.create(element.isDirectory ? 'folder' : 'file', element.resource);
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
18
18
|
import { UserWorkingDirectoryProvider } from '@theia/core/lib/browser/user-working-directory-provider';
|
|
19
19
|
import URI from '@theia/core/lib/common/uri';
|
|
20
|
-
import { WorkspaceService } from './workspace-service';
|
|
20
|
+
import { WorkspaceService } from './workspace-service.js';
|
|
21
21
|
import { MaybePromise } from '@theia/core';
|
|
22
22
|
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
23
23
|
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
import URI from '@theia/core/lib/common/uri';
|
|
21
21
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
22
|
-
import { WorkspaceService } from './workspace-service';
|
|
22
|
+
import { WorkspaceService } from './workspace-service.js';
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Collection of workspace utility functions
|
|
@@ -19,7 +19,7 @@ import URI from '@theia/core/lib/common/uri';
|
|
|
19
19
|
import { Path } from '@theia/core/lib/common/path';
|
|
20
20
|
import { ApplicationShell, NavigatableWidget, WidgetManager } from '@theia/core/lib/browser';
|
|
21
21
|
import { VariableContribution, VariableRegistry, Variable } from '@theia/variable-resolver/lib/browser';
|
|
22
|
-
import { WorkspaceService } from './workspace-service';
|
|
22
|
+
import { WorkspaceService } from './workspace-service.js';
|
|
23
23
|
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
24
24
|
import { nls } from '@theia/core';
|
|
25
25
|
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import { WindowTitleUpdater } from '@theia/core/lib/browser/window/window-title-updater';
|
|
18
18
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
19
19
|
import { Widget } from '@theia/core/lib/browser/widgets/widget';
|
|
20
|
-
import { WorkspaceService } from './workspace-service';
|
|
20
|
+
import { WorkspaceService } from './workspace-service.js';
|
|
21
21
|
import { Navigatable } from '@theia/core/lib/browser/navigatable';
|
|
22
22
|
|
|
23
23
|
@injectable()
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
import { inject, injectable, named } from '@theia/core/shared/inversify';
|
|
17
|
-
import { WorkspaceServer } from '../common/workspace-protocol';
|
|
17
|
+
import { WorkspaceServer } from '../common/workspace-protocol.js';
|
|
18
18
|
import { ILogger, isStringArray } from '@theia/core';
|
|
19
19
|
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
20
20
|
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { ContainerModule, interfaces } from '@theia/core/shared/inversify';
|
|
18
|
-
import { BrowserOnlyWorkspaceServer } from './browser-only-workspace-server';
|
|
19
|
-
import { WorkspaceServer } from '../common';
|
|
18
|
+
import { BrowserOnlyWorkspaceServer } from './browser-only-workspace-server.js';
|
|
19
|
+
import { WorkspaceServer } from '../common/index.js';
|
|
20
20
|
|
|
21
21
|
export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Unbind, isBound: interfaces.IsBound, rebind: interfaces.Rebind) => {
|
|
22
22
|
bind(BrowserOnlyWorkspaceServer).toSelf().inSingletonScope();
|
package/src/common/index.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
export * from './workspace-protocol';
|
|
18
|
-
export * from './workspace-file-service';
|
|
19
|
-
export * from './untitled-workspace-service';
|
|
20
|
-
export * from './workspace-preferences';
|
|
17
|
+
export * from './workspace-protocol.js';
|
|
18
|
+
export * from './workspace-file-service.js';
|
|
19
|
+
export * from './untitled-workspace-service.js';
|
|
20
|
+
export * from './workspace-preferences.js';
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
import { injectable } from '@theia/core/shared/inversify';
|
|
17
|
-
import { WorkspaceServer } from '../workspace-protocol';
|
|
17
|
+
import { WorkspaceServer } from '../workspace-protocol.js';
|
|
18
18
|
|
|
19
19
|
@injectable()
|
|
20
20
|
export class MockWorkspaceServer implements WorkspaceServer {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import URI from '@theia/core/lib/common/uri';
|
|
18
18
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
19
19
|
import { MaybePromise } from '@theia/core';
|
|
20
|
-
import { WorkspaceFileService } from './workspace-file-service';
|
|
20
|
+
import { WorkspaceFileService } from './workspace-file-service.js';
|
|
21
21
|
|
|
22
22
|
@injectable()
|
|
23
23
|
export class UntitledWorkspaceService {
|
|
@@ -18,7 +18,7 @@ import { nls } from '@theia/core';
|
|
|
18
18
|
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
|
|
19
19
|
import '@theia/core/lib/electron-common/electron-api';
|
|
20
20
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
21
|
-
import { WorkspaceService } from '../browser/workspace-service';
|
|
21
|
+
import { WorkspaceService } from '../browser/workspace-service.js';
|
|
22
22
|
|
|
23
23
|
@injectable()
|
|
24
24
|
export class ElectronWorkspaceContribution implements FrontendApplicationContribution {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
18
18
|
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
|
|
19
|
-
import { ElectronWorkspaceContribution } from './electron-workspace-contribution';
|
|
19
|
+
import { ElectronWorkspaceContribution } from './electron-workspace-contribution.js';
|
|
20
20
|
|
|
21
21
|
export default new ContainerModule(bind => {
|
|
22
22
|
bind(ElectronWorkspaceContribution).toSelf().inSingletonScope();
|
|
@@ -19,8 +19,8 @@ import { MockEnvVariablesServerImpl } from '@theia/core/lib/browser/test/mock-en
|
|
|
19
19
|
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
|
|
20
20
|
import URI from '@theia/core/lib/common/uri';
|
|
21
21
|
import { FileUri } from '@theia/core/lib/node';
|
|
22
|
-
import { WorkspaceFileService, UntitledWorkspaceService } from '../common';
|
|
23
|
-
import { DefaultWorkspaceServer, FileWorkspaceHandlerContribution, WorkspaceCliContribution, WorkspaceHandlerContribution } from './default-workspace-server';
|
|
22
|
+
import { WorkspaceFileService, UntitledWorkspaceService } from '../common/index.js';
|
|
23
|
+
import { DefaultWorkspaceServer, FileWorkspaceHandlerContribution, WorkspaceCliContribution, WorkspaceHandlerContribution } from './default-workspace-server.js';
|
|
24
24
|
import { expect } from 'chai';
|
|
25
25
|
import * as temp from 'temp';
|
|
26
26
|
import * as fs from 'fs';
|
|
@@ -22,7 +22,7 @@ import { injectable, inject, postConstruct, named } from '@theia/core/shared/inv
|
|
|
22
22
|
import { FileUri, BackendApplicationContribution } from '@theia/core/lib/node';
|
|
23
23
|
import { CliContribution } from '@theia/core/lib/node/cli';
|
|
24
24
|
import { Deferred } from '@theia/core/lib/common/promise-util';
|
|
25
|
-
import { WorkspaceServer, UntitledWorkspaceService } from '../common';
|
|
25
|
+
import { WorkspaceServer, UntitledWorkspaceService } from '../common/index.js';
|
|
26
26
|
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
|
|
27
27
|
import URI from '@theia/core/lib/common/uri';
|
|
28
28
|
import { ContributionProvider, notEmpty } from '@theia/core';
|
package/src/node/index.ts
CHANGED
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
export * from './default-workspace-server';
|
|
18
|
-
export * from './workspace-backend-module';
|
|
17
|
+
export * from './default-workspace-server.js';
|
|
18
|
+
export * from './workspace-backend-module.js';
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
|
|
17
17
|
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
18
18
|
import { ConnectionHandler, RpcConnectionHandler, bindRootContributionProvider } from '@theia/core/lib/common';
|
|
19
|
-
import { WorkspaceServer, workspacePath, UntitledWorkspaceService, WorkspaceFileService, bindWorkspacePreferences } from '../common';
|
|
20
|
-
import { DefaultWorkspaceServer, FileWorkspaceHandlerContribution, WorkspaceCliContribution, WorkspaceHandlerContribution } from './default-workspace-server';
|
|
19
|
+
import { WorkspaceServer, workspacePath, UntitledWorkspaceService, WorkspaceFileService, bindWorkspacePreferences } from '../common/index.js';
|
|
20
|
+
import { DefaultWorkspaceServer, FileWorkspaceHandlerContribution, WorkspaceCliContribution, WorkspaceHandlerContribution } from './default-workspace-server.js';
|
|
21
21
|
import { CliContribution } from '@theia/core/lib/node/cli';
|
|
22
22
|
import { BackendApplicationContribution } from '@theia/core/lib/node';
|
|
23
|
-
import { bindWorkspaceTrustPreferences } from '../common/workspace-trust-preferences';
|
|
23
|
+
import { bindWorkspaceTrustPreferences } from '../common/workspace-trust-preferences.js';
|
|
24
24
|
|
|
25
25
|
export default new ContainerModule(bind => {
|
|
26
26
|
bind(WorkspaceCliContribution).toSelf().inSingletonScope();
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2026 EclipseSource 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
|
+
declare module 'valid-filename' {
|
|
18
|
+
function validFilename(fileName: string): boolean;
|
|
19
|
+
export = validFilename;
|
|
20
|
+
}
|