@theia/workspace 1.77.0-next.95 → 1.77.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/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 -74
- 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 +1 -1
- package/lib/browser/test/with-workspace-service-defaults.d.ts.map +1 -1
- package/lib/browser/test/with-workspace-service-defaults.js +3 -6
- package/lib/browser/test/with-workspace-service-defaults.js.map +1 -1
- package/lib/browser/untitled-workspace-exit-dialog.js +14 -18
- package/lib/browser/untitled-workspace-exit-dialog.js.map +1 -1
- package/lib/browser/workspace-breadcrumbs-contribution.d.ts +1 -1
- package/lib/browser/workspace-breadcrumbs-contribution.d.ts.map +1 -1
- package/lib/browser/workspace-breadcrumbs-contribution.js +13 -17
- 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 -53
- 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 +125 -141
- 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 +33 -41
- 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 -21
- package/lib/browser/workspace-search-filter-service.spec.js.map +1 -1
- package/lib/browser/workspace-service.d.ts +3 -3
- package/lib/browser/workspace-service.d.ts.map +1 -1
- package/lib/browser/workspace-service.js +107 -130
- package/lib/browser/workspace-service.js.map +1 -1
- package/lib/browser/workspace-service.spec.js +106 -109
- package/lib/browser/workspace-service.spec.js.map +1 -1
- 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 +159 -150
- package/lib/browser/workspace-trust-service.spec.js.map +1 -1
- package/lib/browser/workspace-uri-contribution.d.ts +2 -2
- package/lib/browser/workspace-uri-contribution.d.ts.map +1 -1
- package/lib/browser/workspace-uri-contribution.js +23 -31
- package/lib/browser/workspace-uri-contribution.js.map +1 -1
- package/lib/browser/workspace-uri-contribution.spec.js +95 -98
- 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 -32
- 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 +18 -6
- 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 +1 -1
- package/src/browser/untitled-workspace-exit-dialog.ts +1 -1
- package/src/browser/workspace-breadcrumbs-contribution.ts +1 -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 +6 -6
- package/src/browser/workspace-frontend-module.ts +25 -25
- package/src/browser/workspace-schema-updater.ts +1 -1
- package/src/browser/workspace-search-filter-service.spec.ts +1 -1
- package/src/browser/workspace-service.spec.ts +1 -1
- package/src/browser/workspace-service.ts +3 -3
- package/src/browser/workspace-storage-service.ts +1 -1
- package/src/browser/workspace-trust-service.spec.ts +15 -3
- package/src/browser/workspace-trust-service.ts +5 -5
- package/src/browser/workspace-uri-contribution.spec.ts +3 -3
- package/src/browser/workspace-uri-contribution.ts +2 -2
- 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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// *****************************************************************************
|
|
3
2
|
// Copyright (C) 2017 TypeFox and others.
|
|
4
3
|
//
|
|
@@ -14,31 +13,29 @@
|
|
|
14
13
|
//
|
|
15
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
15
|
// *****************************************************************************
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
exports.WorkspaceOpenHandlerContribution = Symbol('WorkspaceOpenHandlerContribution');
|
|
41
|
-
exports.WorkspaceHandlingContribution = Symbol('WorkspaceHandlingContribution');
|
|
16
|
+
import { __decorate } from "tslib";
|
|
17
|
+
import { injectable, inject, postConstruct, named } from '@theia/core/shared/inversify';
|
|
18
|
+
import URI from '@theia/core/lib/common/uri';
|
|
19
|
+
import { Path } from '@theia/core/lib/common/path';
|
|
20
|
+
import { WorkspaceServer, UntitledWorkspaceService, WorkspaceFileService } from '../common/index.js';
|
|
21
|
+
import { WindowService } from '@theia/core/lib/browser/window/window-service';
|
|
22
|
+
import { DEFAULT_WINDOW_HASH } from '@theia/core/lib/common/window';
|
|
23
|
+
import { LabelProvider } from '@theia/core/lib/browser';
|
|
24
|
+
import { Deferred } from '@theia/core/lib/common/promise-util';
|
|
25
|
+
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
|
|
26
|
+
import { ILogger, Disposable, DisposableCollection, Emitter, environment, MessageService, nls, ContributionProvider } from '@theia/core';
|
|
27
|
+
import { WorkspacePreferences } from '../common/workspace-preferences.js';
|
|
28
|
+
import * as jsoncparser from 'jsonc-parser';
|
|
29
|
+
import Ajv from '@theia/core/shared/ajv';
|
|
30
|
+
import { FileStat } from '@theia/filesystem/lib/common/files';
|
|
31
|
+
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
32
|
+
import { WindowTitleService } from '@theia/core/lib/browser/window/window-title-service';
|
|
33
|
+
import { FileSystemPreferences } from '@theia/filesystem/lib/common';
|
|
34
|
+
import { workspaceSchema, WorkspaceSchemaUpdater } from './workspace-schema-updater.js';
|
|
35
|
+
import { StopReason } from '@theia/core/lib/common/frontend-application-state';
|
|
36
|
+
import { PreferenceSchemaService, PreferenceScope, PreferenceService } from '@theia/core/lib/common/preferences';
|
|
37
|
+
export const WorkspaceOpenHandlerContribution = Symbol('WorkspaceOpenHandlerContribution');
|
|
38
|
+
export const WorkspaceHandlingContribution = Symbol('WorkspaceHandlingContribution');
|
|
42
39
|
/**
|
|
43
40
|
* The workspace service.
|
|
44
41
|
*/
|
|
@@ -49,11 +46,11 @@ let WorkspaceService = class WorkspaceService {
|
|
|
49
46
|
this.configuredRootNames = new Map();
|
|
50
47
|
/** The names of the roots read by the last `computeRoots`, not yet published. */
|
|
51
48
|
this.computedRootNames = new Map();
|
|
52
|
-
this.deferredRoots = new
|
|
53
|
-
this._ready = new
|
|
54
|
-
this.onWorkspaceChangeEmitter = new
|
|
55
|
-
this.onWorkspaceLocationChangedEmitter = new
|
|
56
|
-
this.toDisposeOnWorkspace = new
|
|
49
|
+
this.deferredRoots = new Deferred();
|
|
50
|
+
this._ready = new Deferred();
|
|
51
|
+
this.onWorkspaceChangeEmitter = new Emitter();
|
|
52
|
+
this.onWorkspaceLocationChangedEmitter = new Emitter();
|
|
53
|
+
this.toDisposeOnWorkspace = new DisposableCollection();
|
|
57
54
|
this.rootWatchers = new Map();
|
|
58
55
|
}
|
|
59
56
|
get ready() {
|
|
@@ -65,7 +62,7 @@ let WorkspaceService = class WorkspaceService {
|
|
|
65
62
|
async doInit() {
|
|
66
63
|
let wsUriString = await this.getDefaultWorkspaceUri();
|
|
67
64
|
if (wsUriString) {
|
|
68
|
-
const wsUri = new
|
|
65
|
+
const wsUri = new URI(wsUriString);
|
|
69
66
|
if (wsUri.scheme !== 'file') {
|
|
70
67
|
let handled = false;
|
|
71
68
|
for (const handler of this.openHandlerContribution.getContributions()) {
|
|
@@ -92,7 +89,7 @@ let WorkspaceService = class WorkspaceService {
|
|
|
92
89
|
// No handler could open this non-file URI, or it failed/timed out.
|
|
93
90
|
// Fall back to the most recent local workspace.
|
|
94
91
|
const recents = await this.server.getRecentWorkspaces();
|
|
95
|
-
wsUriString = recents.find(r => new
|
|
92
|
+
wsUriString = recents.find(r => new URI(r).scheme === 'file');
|
|
96
93
|
}
|
|
97
94
|
}
|
|
98
95
|
let wsStat = await this.toFileStat(wsUriString);
|
|
@@ -101,7 +98,7 @@ let WorkspaceService = class WorkspaceService {
|
|
|
101
98
|
// to a path that doesn't exist locally. Fall back to the most recent
|
|
102
99
|
// local workspace.
|
|
103
100
|
const recents = await this.server.getRecentWorkspaces();
|
|
104
|
-
const fallback = recents.find(r => new
|
|
101
|
+
const fallback = recents.find(r => new URI(r).scheme === 'file');
|
|
105
102
|
if (fallback) {
|
|
106
103
|
wsStat = await this.toFileStat(fallback);
|
|
107
104
|
}
|
|
@@ -135,7 +132,7 @@ let WorkspaceService = class WorkspaceService {
|
|
|
135
132
|
async doGetDefaultWorkspaceUri() {
|
|
136
133
|
// If an empty window is explicitly requested do not restore a previous workspace.
|
|
137
134
|
// Note: `window.location.hash` includes leading "#" if non-empty.
|
|
138
|
-
if (window.location.hash === `#${
|
|
135
|
+
if (window.location.hash === `#${DEFAULT_WINDOW_HASH}`) {
|
|
139
136
|
window.location.hash = '';
|
|
140
137
|
return undefined;
|
|
141
138
|
}
|
|
@@ -149,10 +146,10 @@ let WorkspaceService = class WorkspaceService {
|
|
|
149
146
|
const firstSlash = unc.indexOf('/');
|
|
150
147
|
const authority = firstSlash >= 0 ? unc.slice(0, firstSlash) : unc;
|
|
151
148
|
const path = firstSlash >= 0 ? unc.slice(firstSlash) : '/';
|
|
152
|
-
workspaceUri = new
|
|
149
|
+
workspaceUri = new URI().withPath(path).withAuthority(authority).withScheme('file');
|
|
153
150
|
}
|
|
154
151
|
else {
|
|
155
|
-
workspaceUri = new
|
|
152
|
+
workspaceUri = new URI().withPath(wpPath).withScheme('file');
|
|
156
153
|
}
|
|
157
154
|
let workspaceStat;
|
|
158
155
|
try {
|
|
@@ -160,7 +157,7 @@ let WorkspaceService = class WorkspaceService {
|
|
|
160
157
|
}
|
|
161
158
|
catch { }
|
|
162
159
|
if (workspaceStat && !workspaceStat.isDirectory && !this.isWorkspaceFile(workspaceStat)) {
|
|
163
|
-
this.messageService.error(
|
|
160
|
+
this.messageService.error(nls.localize('theia/workspace/notWorkspaceFile', 'Not a valid workspace file: {0}', this.labelProvider.getLongName(workspaceUri)));
|
|
164
161
|
return undefined;
|
|
165
162
|
}
|
|
166
163
|
return workspaceUri.toString();
|
|
@@ -249,7 +246,7 @@ let WorkspaceService = class WorkspaceService {
|
|
|
249
246
|
this.configuredRootNames = newRootNames;
|
|
250
247
|
this.rootNamesCache = undefined;
|
|
251
248
|
this.deferredRoots.resolve(this._roots); // in order to resolve first
|
|
252
|
-
this.deferredRoots = new
|
|
249
|
+
this.deferredRoots = new Deferred();
|
|
253
250
|
this.deferredRoots.resolve(this._roots);
|
|
254
251
|
this.onWorkspaceChangeEmitter.fire(this._roots);
|
|
255
252
|
}
|
|
@@ -275,7 +272,7 @@ let WorkspaceService = class WorkspaceService {
|
|
|
275
272
|
roots.push(valid);
|
|
276
273
|
}
|
|
277
274
|
else {
|
|
278
|
-
roots.push(
|
|
275
|
+
roots.push(FileStat.dir(path));
|
|
279
276
|
}
|
|
280
277
|
// `getWorkspaceDataFromFile` already drops invalid names, but an override of it may not
|
|
281
278
|
if (typeof name === 'string' && name) {
|
|
@@ -319,7 +316,7 @@ let WorkspaceService = class WorkspaceService {
|
|
|
319
316
|
const fullName = this._workspace.resource.path.toString();
|
|
320
317
|
if (this.isWorkspaceFile(this._workspace)) {
|
|
321
318
|
if (this.isUntitledWorkspace(this._workspace.resource)) {
|
|
322
|
-
const untitled =
|
|
319
|
+
const untitled = nls.localizeByDefault('Untitled (Workspace)');
|
|
323
320
|
rootName = untitled;
|
|
324
321
|
rootPath = untitled;
|
|
325
322
|
}
|
|
@@ -348,12 +345,12 @@ let WorkspaceService = class WorkspaceService {
|
|
|
348
345
|
* In Electron, we use `onWillStop` so the workspace is persisted before the window closes.
|
|
349
346
|
*/
|
|
350
347
|
onStop() {
|
|
351
|
-
if (!
|
|
348
|
+
if (!environment.electron.is()) {
|
|
352
349
|
this.setMostRecentlyUsedWorkspace();
|
|
353
350
|
}
|
|
354
351
|
}
|
|
355
352
|
onWillStop() {
|
|
356
|
-
if (
|
|
353
|
+
if (environment.electron.is() && this.workspace) {
|
|
357
354
|
return {
|
|
358
355
|
reason: 'Set workspace root as most recently used',
|
|
359
356
|
action: async () => {
|
|
@@ -428,7 +425,7 @@ let WorkspaceService = class WorkspaceService {
|
|
|
428
425
|
const stat = await this.toFileStat(uri);
|
|
429
426
|
if (stat) {
|
|
430
427
|
if (!stat.isDirectory && !this.isWorkspaceFile(stat)) {
|
|
431
|
-
const message =
|
|
428
|
+
const message = nls.localize('theia/workspace/notWorkspaceFile', 'Not a valid workspace file: {0}', this.labelProvider.getLongName(uri));
|
|
432
429
|
this.messageService.error(message);
|
|
433
430
|
throw new Error(message);
|
|
434
431
|
}
|
|
@@ -485,7 +482,7 @@ let WorkspaceService = class WorkspaceService {
|
|
|
485
482
|
const toAdd = [];
|
|
486
483
|
const namesToAdd = new Map();
|
|
487
484
|
for (const root of rootsToAdd) {
|
|
488
|
-
const { uri, name } = root instanceof
|
|
485
|
+
const { uri, name } = root instanceof URI ? { uri: root, name: undefined } : root;
|
|
489
486
|
const uriString = uri.toString();
|
|
490
487
|
if (!dedup.has(uriString)) {
|
|
491
488
|
dedup.add(uriString);
|
|
@@ -508,11 +505,11 @@ let WorkspaceService = class WorkspaceService {
|
|
|
508
505
|
const newData = WorkspaceData.buildWorkspaceData(roots.map(path => ({ path, name: namesToAdd.get(path) })), currentData);
|
|
509
506
|
await this.writeWorkspaceFile(this._workspace, newData);
|
|
510
507
|
await this.updateWorkspace();
|
|
511
|
-
return toRemove.map(root => new
|
|
508
|
+
return toRemove.map(root => new URI(root));
|
|
512
509
|
}
|
|
513
510
|
async getUntitledWorkspace() {
|
|
514
|
-
const configDirURI = new
|
|
515
|
-
return this.untitledWorkspaceService.getUntitledWorkspaceUri(configDirURI, uri => this.fileService.exists(uri).then(exists => !exists), () => this.messageService.warn(
|
|
511
|
+
const configDirURI = new URI(await this.envVariableServer.getConfigDirUri());
|
|
512
|
+
return this.untitledWorkspaceService.getUntitledWorkspaceUri(configDirURI, uri => this.fileService.exists(uri).then(exists => !exists), () => this.messageService.warn(nls.localize('theia/workspace/untitled-cleanup', 'There appear to be many untitled workspace files. Please check {0} and remove any unused files.', configDirURI.resolve('workspaces').path.fsPath())));
|
|
516
513
|
}
|
|
517
514
|
async writeWorkspaceFile(workspaceFile, workspaceData) {
|
|
518
515
|
if (workspaceFile) {
|
|
@@ -527,7 +524,7 @@ let WorkspaceService = class WorkspaceService {
|
|
|
527
524
|
* Clears current workspace root.
|
|
528
525
|
*/
|
|
529
526
|
async close() {
|
|
530
|
-
if (await this.windowService.isSafeToShutDown(
|
|
527
|
+
if (await this.windowService.isSafeToShutDown(StopReason.Reload)) {
|
|
531
528
|
this.windowService.setSafeToShutDown();
|
|
532
529
|
this._workspace = undefined;
|
|
533
530
|
this._roots.length = 0;
|
|
@@ -556,7 +553,7 @@ let WorkspaceService = class WorkspaceService {
|
|
|
556
553
|
return undefined;
|
|
557
554
|
}
|
|
558
555
|
try {
|
|
559
|
-
const normalizedUri = new
|
|
556
|
+
const normalizedUri = new URI(WorkspaceData.normalizeFolderUri(uri.toString()));
|
|
560
557
|
return await this.fileService.resolve(normalizedUri);
|
|
561
558
|
}
|
|
562
559
|
catch (error) {
|
|
@@ -624,16 +621,16 @@ let WorkspaceService = class WorkspaceService {
|
|
|
624
621
|
* @param uri URI or FileStat of the workspace file
|
|
625
622
|
*/
|
|
626
623
|
async save(uri) {
|
|
627
|
-
const resource = uri instanceof
|
|
624
|
+
const resource = uri instanceof URI ? uri : uri.resource;
|
|
628
625
|
if (!await this.fileService.exists(resource)) {
|
|
629
626
|
await this.fileService.create(resource);
|
|
630
627
|
}
|
|
631
628
|
const workspaceData = { folders: [], settings: {} };
|
|
632
629
|
if (!this.saved) {
|
|
633
|
-
for (const p of Object.keys(this.schemaService.getJSONSchema(
|
|
630
|
+
for (const p of Object.keys(this.schemaService.getJSONSchema(PreferenceScope.Workspace).properties)) {
|
|
634
631
|
// The goal is to ensure that workspace-scoped preferences are preserved in the new workspace.
|
|
635
632
|
// Preferences valid in folder scope will take effect in their folders without being copied.
|
|
636
|
-
if (this.schemaService.isValidInScope(p,
|
|
633
|
+
if (this.schemaService.isValidInScope(p, PreferenceScope.Folder)) {
|
|
637
634
|
continue;
|
|
638
635
|
}
|
|
639
636
|
const preferences = this.preferenceImpl.inspect(p);
|
|
@@ -679,11 +676,11 @@ let WorkspaceService = class WorkspaceService {
|
|
|
679
676
|
return;
|
|
680
677
|
}
|
|
681
678
|
const excludes = this.getExcludes(uriStr);
|
|
682
|
-
const watcher = this.fileService.watch(new
|
|
679
|
+
const watcher = this.fileService.watch(new URI(uriStr), {
|
|
683
680
|
recursive: true,
|
|
684
681
|
excludes
|
|
685
682
|
});
|
|
686
|
-
this.rootWatchers.set(uriStr, new
|
|
683
|
+
this.rootWatchers.set(uriStr, new DisposableCollection(watcher, Disposable.create(() => this.rootWatchers.delete(uriStr))));
|
|
687
684
|
}
|
|
688
685
|
getExcludes(uri) {
|
|
689
686
|
const patterns = this.fsPreferences.get('files.watcherExclude', undefined, uri);
|
|
@@ -831,8 +828,8 @@ let WorkspaceService = class WorkspaceService {
|
|
|
831
828
|
* @returns `undefined` if the path is absolute, does not start with a root name or leaves its root.
|
|
832
829
|
*/
|
|
833
830
|
resolveRootPrefixedPath(rootPrefixedPath) {
|
|
834
|
-
const path = new
|
|
835
|
-
if (path.isAbsolute ||
|
|
831
|
+
const path = new Path(Path.normalizePathSeparator(rootPrefixedPath)).normalize();
|
|
832
|
+
if (path.isAbsolute || Path.isDrive(path.toString().split('/')[0])) {
|
|
836
833
|
return undefined;
|
|
837
834
|
}
|
|
838
835
|
const segments = path.toString().split('/').filter(segment => segment.length > 0);
|
|
@@ -855,9 +852,9 @@ let WorkspaceService = class WorkspaceService {
|
|
|
855
852
|
* or none if the path is absolute, leaves its root or does not contain the basename of a root.
|
|
856
853
|
*/
|
|
857
854
|
resolveSupraRelativePath(supraRelativePath) {
|
|
858
|
-
const path = new
|
|
855
|
+
const path = new Path(Path.normalizePathSeparator(supraRelativePath)).normalize();
|
|
859
856
|
const segments = path.toString().split('/').filter(segment => segment.length > 0);
|
|
860
|
-
if (path.isAbsolute ||
|
|
857
|
+
if (path.isAbsolute || Path.isDrive(segments[0] ?? '') || segments.includes('..')) {
|
|
861
858
|
return [];
|
|
862
859
|
}
|
|
863
860
|
const candidates = [];
|
|
@@ -987,7 +984,7 @@ let WorkspaceService = class WorkspaceService {
|
|
|
987
984
|
return this.untitledWorkspaceService.isUntitledWorkspace(candidate);
|
|
988
985
|
}
|
|
989
986
|
async isSafeToReload(withURI) {
|
|
990
|
-
return !withURI || !this.untitledWorkspaceService.isUntitledWorkspace(withURI) || new
|
|
987
|
+
return !withURI || !this.untitledWorkspaceService.isUntitledWorkspace(withURI) || new URI(await this.getDefaultWorkspaceUri()).isEqual(withURI);
|
|
991
988
|
}
|
|
992
989
|
/**
|
|
993
990
|
*
|
|
@@ -998,92 +995,72 @@ let WorkspaceService = class WorkspaceService {
|
|
|
998
995
|
return this.schemaUpdater.updateSchema({ key, schema });
|
|
999
996
|
}
|
|
1000
997
|
};
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
(0, inversify_1.inject)(file_service_1.FileService),
|
|
1004
|
-
tslib_1.__metadata("design:type", file_service_1.FileService)
|
|
998
|
+
__decorate([
|
|
999
|
+
inject(FileService)
|
|
1005
1000
|
], WorkspaceService.prototype, "fileService", void 0);
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
tslib_1.__metadata("design:type", Object)
|
|
1001
|
+
__decorate([
|
|
1002
|
+
inject(WorkspaceServer)
|
|
1009
1003
|
], WorkspaceService.prototype, "server", void 0);
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
tslib_1.__metadata("design:type", Object)
|
|
1004
|
+
__decorate([
|
|
1005
|
+
inject(WindowService)
|
|
1013
1006
|
], WorkspaceService.prototype, "windowService", void 0);
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
tslib_1.__metadata("design:type", Object)
|
|
1007
|
+
__decorate([
|
|
1008
|
+
inject(ILogger),
|
|
1009
|
+
named('workspace:WorkspaceService')
|
|
1018
1010
|
], WorkspaceService.prototype, "logger", void 0);
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
tslib_1.__metadata("design:type", Object)
|
|
1011
|
+
__decorate([
|
|
1012
|
+
inject(WorkspacePreferences)
|
|
1022
1013
|
], WorkspaceService.prototype, "preferences", void 0);
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
tslib_1.__metadata("design:type", Object)
|
|
1014
|
+
__decorate([
|
|
1015
|
+
inject(PreferenceService)
|
|
1026
1016
|
], WorkspaceService.prototype, "preferenceImpl", void 0);
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
tslib_1.__metadata("design:type", Object)
|
|
1017
|
+
__decorate([
|
|
1018
|
+
inject(PreferenceSchemaService)
|
|
1030
1019
|
], WorkspaceService.prototype, "schemaService", void 0);
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
tslib_1.__metadata("design:type", Object)
|
|
1020
|
+
__decorate([
|
|
1021
|
+
inject(EnvVariablesServer)
|
|
1034
1022
|
], WorkspaceService.prototype, "envVariableServer", void 0);
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
tslib_1.__metadata("design:type", core_1.MessageService)
|
|
1023
|
+
__decorate([
|
|
1024
|
+
inject(MessageService)
|
|
1038
1025
|
], WorkspaceService.prototype, "messageService", void 0);
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
tslib_1.__metadata("design:type", browser_1.LabelProvider)
|
|
1026
|
+
__decorate([
|
|
1027
|
+
inject(LabelProvider)
|
|
1042
1028
|
], WorkspaceService.prototype, "labelProvider", void 0);
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
tslib_1.__metadata("design:type", Object)
|
|
1029
|
+
__decorate([
|
|
1030
|
+
inject(FileSystemPreferences)
|
|
1046
1031
|
], WorkspaceService.prototype, "fsPreferences", void 0);
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
tslib_1.__metadata("design:type", workspace_schema_updater_1.WorkspaceSchemaUpdater)
|
|
1032
|
+
__decorate([
|
|
1033
|
+
inject(WorkspaceSchemaUpdater)
|
|
1050
1034
|
], WorkspaceService.prototype, "schemaUpdater", void 0);
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
tslib_1.__metadata("design:type", common_1.UntitledWorkspaceService)
|
|
1035
|
+
__decorate([
|
|
1036
|
+
inject(UntitledWorkspaceService)
|
|
1054
1037
|
], WorkspaceService.prototype, "untitledWorkspaceService", void 0);
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
tslib_1.__metadata("design:type", common_1.WorkspaceFileService)
|
|
1038
|
+
__decorate([
|
|
1039
|
+
inject(WorkspaceFileService)
|
|
1058
1040
|
], WorkspaceService.prototype, "workspaceFileService", void 0);
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
tslib_1.__metadata("design:type", window_title_service_1.WindowTitleService)
|
|
1041
|
+
__decorate([
|
|
1042
|
+
inject(WindowTitleService)
|
|
1062
1043
|
], WorkspaceService.prototype, "windowTitleService", void 0);
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
tslib_1.__metadata("design:type", Object)
|
|
1044
|
+
__decorate([
|
|
1045
|
+
inject(ContributionProvider),
|
|
1046
|
+
named(WorkspaceOpenHandlerContribution)
|
|
1067
1047
|
], WorkspaceService.prototype, "openHandlerContribution", void 0);
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
tslib_1.__metadata("design:type", Object)
|
|
1048
|
+
__decorate([
|
|
1049
|
+
inject(ContributionProvider),
|
|
1050
|
+
named(WorkspaceHandlingContribution)
|
|
1072
1051
|
], WorkspaceService.prototype, "workspaceHandlingContribution", void 0);
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
tslib_1.__metadata("design:type", Function),
|
|
1076
|
-
tslib_1.__metadata("design:paramtypes", []),
|
|
1077
|
-
tslib_1.__metadata("design:returntype", void 0)
|
|
1052
|
+
__decorate([
|
|
1053
|
+
postConstruct()
|
|
1078
1054
|
], WorkspaceService.prototype, "init", null);
|
|
1079
|
-
|
|
1080
|
-
|
|
1055
|
+
WorkspaceService = __decorate([
|
|
1056
|
+
injectable()
|
|
1081
1057
|
], WorkspaceService);
|
|
1082
|
-
|
|
1058
|
+
export { WorkspaceService };
|
|
1059
|
+
export var WorkspaceData;
|
|
1083
1060
|
(function (WorkspaceData) {
|
|
1084
1061
|
// The `name` of a folder is not validated when loading, so that a workspace file with an invalid name still loads,
|
|
1085
1062
|
// and the folder falls back to its folder name, as in VS Code. The editor still validates it against `workspaceSchema`.
|
|
1086
|
-
const validateSchema = new
|
|
1063
|
+
const validateSchema = new Ajv().compile(withoutFolderName(workspaceSchema));
|
|
1087
1064
|
function withoutFolderName(schema) {
|
|
1088
1065
|
const copy = structuredClone(schema);
|
|
1089
1066
|
delete copy.properties?.folders.items?.properties?.name;
|
|
@@ -1100,7 +1077,7 @@ var WorkspaceData;
|
|
|
1100
1077
|
* Normalizes the given folder URI the same way as the URIs of the workspace roots, so that they can be compared.
|
|
1101
1078
|
*/
|
|
1102
1079
|
function normalizeFolderUri(folderUri) {
|
|
1103
|
-
return new
|
|
1080
|
+
return new URI(folderUri.endsWith('/') ? folderUri.slice(0, -1) : folderUri).normalizePath().toString();
|
|
1104
1081
|
}
|
|
1105
1082
|
WorkspaceData.normalizeFolderUri = normalizeFolderUri;
|
|
1106
1083
|
/**
|
|
@@ -1116,9 +1093,9 @@ var WorkspaceData;
|
|
|
1116
1093
|
}
|
|
1117
1094
|
const roots = new Map();
|
|
1118
1095
|
for (const folder of folders) {
|
|
1119
|
-
const path = typeof folder === 'string' ? folder :
|
|
1096
|
+
const path = typeof folder === 'string' ? folder : FileStat.is(folder) ? folder.resource.toString() : folder.path;
|
|
1120
1097
|
if (!roots.has(path)) {
|
|
1121
|
-
const name = typeof folder === 'string' ||
|
|
1098
|
+
const name = typeof folder === 'string' || FileStat.is(folder) ? undefined : folder.name;
|
|
1122
1099
|
roots.set(path, isValidFolderName(name) ? name : currentNames.get(normalizeFolderUri(path)));
|
|
1123
1100
|
}
|
|
1124
1101
|
}
|
|
@@ -1134,9 +1111,9 @@ var WorkspaceData;
|
|
|
1134
1111
|
WorkspaceData.buildWorkspaceData = buildWorkspaceData;
|
|
1135
1112
|
function transformToRelative(data, workspaceFile) {
|
|
1136
1113
|
const folders = [];
|
|
1137
|
-
const workspaceFileUri = new
|
|
1114
|
+
const workspaceFileUri = new URI(workspaceFile ? workspaceFile.resource.toString() : '').withScheme('file');
|
|
1138
1115
|
for (const { path, name } of data.folders) {
|
|
1139
|
-
const folderUri = new
|
|
1116
|
+
const folderUri = new URI(path).withScheme('file');
|
|
1140
1117
|
const rel = workspaceFileUri.parent.relative(folderUri);
|
|
1141
1118
|
folders.push({ path: rel ? rel.toString() : folderUri.toString(), name });
|
|
1142
1119
|
}
|
|
@@ -1162,5 +1139,5 @@ var WorkspaceData;
|
|
|
1162
1139
|
return data;
|
|
1163
1140
|
}
|
|
1164
1141
|
WorkspaceData.transformToAbsolute = transformToAbsolute;
|
|
1165
|
-
})(WorkspaceData || (
|
|
1142
|
+
})(WorkspaceData || (WorkspaceData = {}));
|
|
1166
1143
|
//# sourceMappingURL=workspace-service.js.map
|