@codingame/monaco-vscode-base-service-override 7.0.3 → 7.0.7
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/base.js
CHANGED
|
@@ -26,6 +26,8 @@ import { UserActivityService } from './vscode/src/vs/workbench/services/userActi
|
|
|
26
26
|
import { WorkingCopyFileService } from './vscode/src/vs/workbench/services/workingCopy/common/workingCopyFileService.js';
|
|
27
27
|
import { ITrustedDomainService } from 'vscode/vscode/vs/workbench/contrib/url/browser/trustedDomainService.service';
|
|
28
28
|
import { TrustedDomainService } from 'vscode/vscode/vs/workbench/contrib/url/browser/trustedDomainService';
|
|
29
|
+
import { LabelService } from './vscode/src/vs/workbench/services/label/common/labelService.js';
|
|
30
|
+
import { ILabelService } from 'vscode/vscode/vs/platform/label/common/label.service';
|
|
29
31
|
import { getEnvironmentOverride } from 'vscode/workbench';
|
|
30
32
|
|
|
31
33
|
let BrowserPathServiceOverride = class BrowserPathServiceOverride extends AbstractPathService {
|
|
@@ -50,7 +52,8 @@ function getServiceOverride() {
|
|
|
50
52
|
[( IUserActivityService.toString())]: new SyncDescriptor(UserActivityService, [], true),
|
|
51
53
|
[( IWorkingCopyFileService.toString())]: new SyncDescriptor(WorkingCopyFileService, [], false),
|
|
52
54
|
[( IPathService.toString())]: new SyncDescriptor(BrowserPathServiceOverride, [], true),
|
|
53
|
-
[( ITrustedDomainService.toString())]: new SyncDescriptor(TrustedDomainService, [], true)
|
|
55
|
+
[( ITrustedDomainService.toString())]: new SyncDescriptor(TrustedDomainService, [], true),
|
|
56
|
+
[( ILabelService.toString())]: new SyncDescriptor(LabelService, [], true)
|
|
54
57
|
};
|
|
55
58
|
}
|
|
56
59
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-base-service-override",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.7",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "CodinGame",
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"vscode": "npm:@codingame/monaco-vscode-api@7.0.
|
|
29
|
+
"vscode": "npm:@codingame/monaco-vscode-api@7.0.7"
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
+
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
3
|
+
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
4
|
+
import { dispose, Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
5
|
+
import { sep, posix, win32 } from 'vscode/vscode/vs/base/common/path';
|
|
6
|
+
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
7
|
+
import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
8
|
+
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
9
|
+
import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService.service';
|
|
10
|
+
import { isWorkspace, toWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier, isUntitledWorkspace, isTemporaryWorkspace, WORKSPACE_EXTENSION } from 'vscode/vscode/vs/platform/workspace/common/workspace';
|
|
11
|
+
import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
|
|
12
|
+
import { basenameOrAuthority, basename, joinPath, dirname } from 'vscode/vscode/vs/base/common/resources';
|
|
13
|
+
import { getPathLabel, tildify } from 'vscode/vscode/vs/base/common/labels';
|
|
14
|
+
import { Verbosity } from 'vscode/vscode/vs/platform/label/common/label';
|
|
15
|
+
import { ILabelService } from 'vscode/vscode/vs/platform/label/common/label.service';
|
|
16
|
+
import { ExtensionsRegistry } from 'vscode/vscode/vs/workbench/services/extensions/common/extensionsRegistry';
|
|
17
|
+
import { match } from 'vscode/vscode/vs/base/common/glob';
|
|
18
|
+
import { LifecyclePhase } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
|
|
19
|
+
import { ILifecycleService } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle.service';
|
|
20
|
+
import 'vscode/vscode/vs/platform/instantiation/common/extensions';
|
|
21
|
+
import { IPathService } from 'vscode/vscode/vs/workbench/services/path/common/pathService.service';
|
|
22
|
+
import { isProposedApiEnabled } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions';
|
|
23
|
+
import { OS, OperatingSystem } from 'vscode/vscode/vs/base/common/platform';
|
|
24
|
+
import { IRemoteAgentService } from 'vscode/vscode/vs/workbench/services/remote/common/remoteAgentService.service';
|
|
25
|
+
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
26
|
+
import { StorageScope, StorageTarget } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
27
|
+
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
|
|
28
|
+
import { Memento } from 'vscode/vscode/vs/workbench/common/memento';
|
|
29
|
+
import { firstOrDefault } from 'vscode/vscode/vs/base/common/arrays';
|
|
30
|
+
|
|
31
|
+
const _moduleId = "vs/workbench/services/label/common/labelService";
|
|
32
|
+
const resourceLabelFormattersExtPoint = ExtensionsRegistry.registerExtensionPoint({
|
|
33
|
+
extensionPoint: 'resourceLabelFormatters',
|
|
34
|
+
jsonSchema: {
|
|
35
|
+
description: ( localizeWithPath(_moduleId, 0, 'Contributes resource label formatting rules.')),
|
|
36
|
+
type: 'array',
|
|
37
|
+
items: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
required: ['scheme', 'formatting'],
|
|
40
|
+
properties: {
|
|
41
|
+
scheme: {
|
|
42
|
+
type: 'string',
|
|
43
|
+
description: ( localizeWithPath(
|
|
44
|
+
_moduleId,
|
|
45
|
+
1,
|
|
46
|
+
'URI scheme on which to match the formatter on. For example "file". Simple glob patterns are supported.'
|
|
47
|
+
)),
|
|
48
|
+
},
|
|
49
|
+
authority: {
|
|
50
|
+
type: 'string',
|
|
51
|
+
description: ( localizeWithPath(
|
|
52
|
+
_moduleId,
|
|
53
|
+
2,
|
|
54
|
+
'URI authority on which to match the formatter on. Simple glob patterns are supported.'
|
|
55
|
+
)),
|
|
56
|
+
},
|
|
57
|
+
formatting: {
|
|
58
|
+
description: ( localizeWithPath(_moduleId, 3, "Rules for formatting uri resource labels.")),
|
|
59
|
+
type: 'object',
|
|
60
|
+
properties: {
|
|
61
|
+
label: {
|
|
62
|
+
type: 'string',
|
|
63
|
+
description: ( localizeWithPath(
|
|
64
|
+
_moduleId,
|
|
65
|
+
4,
|
|
66
|
+
"Label rules to display. For example: myLabel:/${path}. ${path}, ${scheme}, ${authority} and ${authoritySuffix} are supported as variables."
|
|
67
|
+
))
|
|
68
|
+
},
|
|
69
|
+
separator: {
|
|
70
|
+
type: 'string',
|
|
71
|
+
description: ( localizeWithPath(
|
|
72
|
+
_moduleId,
|
|
73
|
+
5,
|
|
74
|
+
"Separator to be used in the uri label display. '/' or '\' as an example."
|
|
75
|
+
))
|
|
76
|
+
},
|
|
77
|
+
stripPathStartingSeparator: {
|
|
78
|
+
type: 'boolean',
|
|
79
|
+
description: ( localizeWithPath(
|
|
80
|
+
_moduleId,
|
|
81
|
+
6,
|
|
82
|
+
"Controls whether `${path}` substitutions should have starting separator characters stripped."
|
|
83
|
+
))
|
|
84
|
+
},
|
|
85
|
+
tildify: {
|
|
86
|
+
type: 'boolean',
|
|
87
|
+
description: ( localizeWithPath(
|
|
88
|
+
_moduleId,
|
|
89
|
+
7,
|
|
90
|
+
"Controls if the start of the uri label should be tildified when possible."
|
|
91
|
+
))
|
|
92
|
+
},
|
|
93
|
+
workspaceSuffix: {
|
|
94
|
+
type: 'string',
|
|
95
|
+
description: ( localizeWithPath(_moduleId, 8, "Suffix appended to the workspace label."))
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
const sepRegexp = /\//g;
|
|
104
|
+
const labelMatchingRegexp = /\$\{(scheme|authoritySuffix|authority|path|(query)\.(.+?))\}/g;
|
|
105
|
+
function hasDriveLetterIgnorePlatform(path) {
|
|
106
|
+
return !!(path && path[2] === ':');
|
|
107
|
+
}
|
|
108
|
+
let ResourceLabelFormattersHandler = class ResourceLabelFormattersHandler {
|
|
109
|
+
constructor(labelService) {
|
|
110
|
+
this.formattersDisposables = ( (new Map()));
|
|
111
|
+
resourceLabelFormattersExtPoint.setHandler((extensions, delta) => {
|
|
112
|
+
for (const added of delta.added) {
|
|
113
|
+
for (const untrustedFormatter of added.value) {
|
|
114
|
+
const formatter = { ...untrustedFormatter };
|
|
115
|
+
if (typeof formatter.formatting.label !== 'string') {
|
|
116
|
+
formatter.formatting.label = '${authority}${path}';
|
|
117
|
+
}
|
|
118
|
+
if (typeof formatter.formatting.separator !== `string`) {
|
|
119
|
+
formatter.formatting.separator = sep;
|
|
120
|
+
}
|
|
121
|
+
if (!isProposedApiEnabled(added.description, 'contribLabelFormatterWorkspaceTooltip') && formatter.formatting.workspaceTooltip) {
|
|
122
|
+
formatter.formatting.workspaceTooltip = undefined;
|
|
123
|
+
}
|
|
124
|
+
this.formattersDisposables.set(formatter, labelService.registerFormatter(formatter));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
for (const removed of delta.removed) {
|
|
128
|
+
for (const formatter of removed.value) {
|
|
129
|
+
dispose(this.formattersDisposables.get(formatter));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
ResourceLabelFormattersHandler = ( (__decorate([
|
|
136
|
+
( (__param(0, ILabelService)))
|
|
137
|
+
], ResourceLabelFormattersHandler)));
|
|
138
|
+
( (Registry.as(Extensions.Workbench))).registerWorkbenchContribution(ResourceLabelFormattersHandler, LifecyclePhase.Restored);
|
|
139
|
+
const FORMATTER_CACHE_SIZE = 50;
|
|
140
|
+
let LabelService = class LabelService extends Disposable {
|
|
141
|
+
constructor(environmentService, contextService, pathService, remoteAgentService, storageService, lifecycleService) {
|
|
142
|
+
super();
|
|
143
|
+
this.environmentService = environmentService;
|
|
144
|
+
this.contextService = contextService;
|
|
145
|
+
this.pathService = pathService;
|
|
146
|
+
this.remoteAgentService = remoteAgentService;
|
|
147
|
+
this._onDidChangeFormatters = this._register(( (new Emitter({ leakWarningThreshold: 400 }))));
|
|
148
|
+
this.onDidChangeFormatters = this._onDidChangeFormatters.event;
|
|
149
|
+
this.os = OS;
|
|
150
|
+
this.userHome = pathService.defaultUriScheme === Schemas.file ? this.pathService.userHome({ preferLocal: true }) : undefined;
|
|
151
|
+
const memento = this.storedFormattersMemento = ( (new Memento('cachedResourceLabelFormatters2', storageService)));
|
|
152
|
+
this.storedFormatters = memento.getMemento(StorageScope.PROFILE, StorageTarget.MACHINE);
|
|
153
|
+
this.formatters = this.storedFormatters?.formatters?.slice() || [];
|
|
154
|
+
this.resolveRemoteEnvironment();
|
|
155
|
+
}
|
|
156
|
+
async resolveRemoteEnvironment() {
|
|
157
|
+
const env = await this.remoteAgentService.getEnvironment();
|
|
158
|
+
this.os = env?.os ?? OS;
|
|
159
|
+
this.userHome = await this.pathService.userHome();
|
|
160
|
+
}
|
|
161
|
+
findFormatting(resource) {
|
|
162
|
+
let bestResult;
|
|
163
|
+
for (const formatter of this.formatters) {
|
|
164
|
+
if (formatter.scheme === resource.scheme) {
|
|
165
|
+
if (!formatter.authority && (!bestResult || formatter.priority)) {
|
|
166
|
+
bestResult = formatter;
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (!formatter.authority) {
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (match(formatter.authority.toLowerCase(), resource.authority.toLowerCase()) &&
|
|
173
|
+
(!bestResult ||
|
|
174
|
+
!bestResult.authority ||
|
|
175
|
+
formatter.authority.length > bestResult.authority.length ||
|
|
176
|
+
((formatter.authority.length === bestResult.authority.length) && formatter.priority))) {
|
|
177
|
+
bestResult = formatter;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return bestResult ? bestResult.formatting : undefined;
|
|
182
|
+
}
|
|
183
|
+
getUriLabel(resource, options = {}) {
|
|
184
|
+
let formatting = this.findFormatting(resource);
|
|
185
|
+
if (formatting && options.separator) {
|
|
186
|
+
formatting = { ...formatting, separator: options.separator };
|
|
187
|
+
}
|
|
188
|
+
const label = this.doGetUriLabel(resource, formatting, options);
|
|
189
|
+
if (!formatting && options.separator) {
|
|
190
|
+
return label.replace(sepRegexp, options.separator);
|
|
191
|
+
}
|
|
192
|
+
return label;
|
|
193
|
+
}
|
|
194
|
+
doGetUriLabel(resource, formatting, options = {}) {
|
|
195
|
+
if (!formatting) {
|
|
196
|
+
return getPathLabel(resource, {
|
|
197
|
+
os: this.os,
|
|
198
|
+
tildify: this.userHome ? { userHome: this.userHome } : undefined,
|
|
199
|
+
relative: options.relative ? {
|
|
200
|
+
noPrefix: options.noPrefix,
|
|
201
|
+
getWorkspace: () => this.contextService.getWorkspace(),
|
|
202
|
+
getWorkspaceFolder: resource => this.contextService.getWorkspaceFolder(resource)
|
|
203
|
+
} : undefined
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
if (options.relative && this.contextService) {
|
|
207
|
+
let folder = this.contextService.getWorkspaceFolder(resource);
|
|
208
|
+
if (!folder) {
|
|
209
|
+
const workspace = this.contextService.getWorkspace();
|
|
210
|
+
const firstFolder = firstOrDefault(workspace.folders);
|
|
211
|
+
if (firstFolder && resource.scheme !== firstFolder.uri.scheme && resource.path.startsWith(posix.sep)) {
|
|
212
|
+
folder = this.contextService.getWorkspaceFolder(firstFolder.uri.with({ path: resource.path }));
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (folder) {
|
|
216
|
+
const folderLabel = this.formatUri(folder.uri, formatting, options.noPrefix);
|
|
217
|
+
let relativeLabel = this.formatUri(resource, formatting, options.noPrefix);
|
|
218
|
+
let overlap = 0;
|
|
219
|
+
while (relativeLabel[overlap] && relativeLabel[overlap] === folderLabel[overlap]) {
|
|
220
|
+
overlap++;
|
|
221
|
+
}
|
|
222
|
+
if (!relativeLabel[overlap] || relativeLabel[overlap] === formatting.separator) {
|
|
223
|
+
relativeLabel = relativeLabel.substring(1 + overlap);
|
|
224
|
+
}
|
|
225
|
+
else if (overlap === folderLabel.length && folder.uri.path === posix.sep) {
|
|
226
|
+
relativeLabel = relativeLabel.substring(overlap);
|
|
227
|
+
}
|
|
228
|
+
const hasMultipleRoots = this.contextService.getWorkspace().folders.length > 1;
|
|
229
|
+
if (hasMultipleRoots && !options.noPrefix) {
|
|
230
|
+
const rootName = folder?.name ?? basenameOrAuthority(folder.uri);
|
|
231
|
+
relativeLabel = relativeLabel ? `${rootName} • ${relativeLabel}` : rootName;
|
|
232
|
+
}
|
|
233
|
+
return relativeLabel;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return this.formatUri(resource, formatting, options.noPrefix);
|
|
237
|
+
}
|
|
238
|
+
getUriBasenameLabel(resource) {
|
|
239
|
+
const formatting = this.findFormatting(resource);
|
|
240
|
+
const label = this.doGetUriLabel(resource, formatting);
|
|
241
|
+
let pathLib;
|
|
242
|
+
if (formatting?.separator === win32.sep) {
|
|
243
|
+
pathLib = win32;
|
|
244
|
+
}
|
|
245
|
+
else if (formatting?.separator === posix.sep) {
|
|
246
|
+
pathLib = posix;
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
pathLib = (this.os === OperatingSystem.Windows) ? win32 : posix;
|
|
250
|
+
}
|
|
251
|
+
return pathLib.basename(label);
|
|
252
|
+
}
|
|
253
|
+
getWorkspaceLabel(workspace, options) {
|
|
254
|
+
if (isWorkspace(workspace)) {
|
|
255
|
+
const identifier = toWorkspaceIdentifier(workspace);
|
|
256
|
+
if (isSingleFolderWorkspaceIdentifier(identifier) || isWorkspaceIdentifier(identifier)) {
|
|
257
|
+
return this.getWorkspaceLabel(identifier, options);
|
|
258
|
+
}
|
|
259
|
+
return '';
|
|
260
|
+
}
|
|
261
|
+
if (URI.isUri(workspace)) {
|
|
262
|
+
return this.doGetSingleFolderWorkspaceLabel(workspace, options);
|
|
263
|
+
}
|
|
264
|
+
if (isSingleFolderWorkspaceIdentifier(workspace)) {
|
|
265
|
+
return this.doGetSingleFolderWorkspaceLabel(workspace.uri, options);
|
|
266
|
+
}
|
|
267
|
+
if (isWorkspaceIdentifier(workspace)) {
|
|
268
|
+
return this.doGetWorkspaceLabel(workspace.configPath, options);
|
|
269
|
+
}
|
|
270
|
+
return '';
|
|
271
|
+
}
|
|
272
|
+
doGetWorkspaceLabel(workspaceUri, options) {
|
|
273
|
+
if (isUntitledWorkspace(workspaceUri, this.environmentService)) {
|
|
274
|
+
return ( localizeWithPath(_moduleId, 9, "Untitled (Workspace)"));
|
|
275
|
+
}
|
|
276
|
+
if (isTemporaryWorkspace(workspaceUri)) {
|
|
277
|
+
return ( localizeWithPath(_moduleId, 10, "Workspace"));
|
|
278
|
+
}
|
|
279
|
+
let filename = basename(workspaceUri);
|
|
280
|
+
if (filename.endsWith(WORKSPACE_EXTENSION)) {
|
|
281
|
+
filename = filename.substr(0, filename.length - WORKSPACE_EXTENSION.length - 1);
|
|
282
|
+
}
|
|
283
|
+
let label;
|
|
284
|
+
switch (options?.verbose) {
|
|
285
|
+
case Verbosity.SHORT:
|
|
286
|
+
label = filename;
|
|
287
|
+
break;
|
|
288
|
+
case Verbosity.LONG:
|
|
289
|
+
label = ( localizeWithPath(
|
|
290
|
+
_moduleId,
|
|
291
|
+
11,
|
|
292
|
+
"{0} (Workspace)",
|
|
293
|
+
this.getUriLabel(joinPath(dirname(workspaceUri), filename))
|
|
294
|
+
));
|
|
295
|
+
break;
|
|
296
|
+
case Verbosity.MEDIUM:
|
|
297
|
+
default:
|
|
298
|
+
label = ( localizeWithPath(_moduleId, 12, "{0} (Workspace)", filename));
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
if (options?.verbose === Verbosity.SHORT) {
|
|
302
|
+
return label;
|
|
303
|
+
}
|
|
304
|
+
return this.appendWorkspaceSuffix(label, workspaceUri);
|
|
305
|
+
}
|
|
306
|
+
doGetSingleFolderWorkspaceLabel(folderUri, options) {
|
|
307
|
+
let label;
|
|
308
|
+
switch (options?.verbose) {
|
|
309
|
+
case Verbosity.LONG:
|
|
310
|
+
label = this.getUriLabel(folderUri);
|
|
311
|
+
break;
|
|
312
|
+
case Verbosity.SHORT:
|
|
313
|
+
case Verbosity.MEDIUM:
|
|
314
|
+
default:
|
|
315
|
+
label = basename(folderUri) || posix.sep;
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
if (options?.verbose === Verbosity.SHORT) {
|
|
319
|
+
return label;
|
|
320
|
+
}
|
|
321
|
+
return this.appendWorkspaceSuffix(label, folderUri);
|
|
322
|
+
}
|
|
323
|
+
getSeparator(scheme, authority) {
|
|
324
|
+
const formatter = this.findFormatting(( (URI.from({ scheme, authority }))));
|
|
325
|
+
return formatter?.separator || posix.sep;
|
|
326
|
+
}
|
|
327
|
+
getHostLabel(scheme, authority) {
|
|
328
|
+
const formatter = this.findFormatting(( (URI.from({ scheme, authority }))));
|
|
329
|
+
return formatter?.workspaceSuffix || authority || '';
|
|
330
|
+
}
|
|
331
|
+
getHostTooltip(scheme, authority) {
|
|
332
|
+
const formatter = this.findFormatting(( (URI.from({ scheme, authority }))));
|
|
333
|
+
return formatter?.workspaceTooltip;
|
|
334
|
+
}
|
|
335
|
+
registerCachedFormatter(formatter) {
|
|
336
|
+
const list = this.storedFormatters.formatters ??= [];
|
|
337
|
+
let replace = list.findIndex(f => f.scheme === formatter.scheme && f.authority === formatter.authority);
|
|
338
|
+
if (replace === -1 && list.length >= FORMATTER_CACHE_SIZE) {
|
|
339
|
+
replace = FORMATTER_CACHE_SIZE - 1;
|
|
340
|
+
}
|
|
341
|
+
if (replace === -1) {
|
|
342
|
+
list.unshift(formatter);
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
for (let i = replace; i > 0; i--) {
|
|
346
|
+
list[i] = list[i - 1];
|
|
347
|
+
}
|
|
348
|
+
list[0] = formatter;
|
|
349
|
+
}
|
|
350
|
+
this.storedFormattersMemento.saveMemento();
|
|
351
|
+
return this.registerFormatter(formatter);
|
|
352
|
+
}
|
|
353
|
+
registerFormatter(formatter) {
|
|
354
|
+
this.formatters.push(formatter);
|
|
355
|
+
this._onDidChangeFormatters.fire({ scheme: formatter.scheme });
|
|
356
|
+
return {
|
|
357
|
+
dispose: () => {
|
|
358
|
+
this.formatters = this.formatters.filter(f => f !== formatter);
|
|
359
|
+
this._onDidChangeFormatters.fire({ scheme: formatter.scheme });
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
formatUri(resource, formatting, forceNoTildify) {
|
|
364
|
+
let label = formatting.label.replace(labelMatchingRegexp, (match, token, qsToken, qsValue) => {
|
|
365
|
+
switch (token) {
|
|
366
|
+
case 'scheme': return resource.scheme;
|
|
367
|
+
case 'authority': return resource.authority;
|
|
368
|
+
case 'authoritySuffix': {
|
|
369
|
+
const i = resource.authority.indexOf('+');
|
|
370
|
+
return i === -1 ? resource.authority : resource.authority.slice(i + 1);
|
|
371
|
+
}
|
|
372
|
+
case 'path':
|
|
373
|
+
return formatting.stripPathStartingSeparator
|
|
374
|
+
? resource.path.slice(resource.path[0] === formatting.separator ? 1 : 0)
|
|
375
|
+
: resource.path;
|
|
376
|
+
default: {
|
|
377
|
+
if (qsToken === 'query') {
|
|
378
|
+
const { query } = resource;
|
|
379
|
+
if (query && query[0] === '{' && query[query.length - 1] === '}') {
|
|
380
|
+
try {
|
|
381
|
+
return JSON.parse(query)[qsValue] || '';
|
|
382
|
+
}
|
|
383
|
+
catch { }
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
return '';
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
if (formatting.normalizeDriveLetter && hasDriveLetterIgnorePlatform(label)) {
|
|
391
|
+
label = label.charAt(1).toUpperCase() + label.substr(2);
|
|
392
|
+
}
|
|
393
|
+
if (formatting.tildify && !forceNoTildify) {
|
|
394
|
+
if (this.userHome) {
|
|
395
|
+
label = tildify(label, this.userHome.fsPath, this.os);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
if (formatting.authorityPrefix && resource.authority) {
|
|
399
|
+
label = formatting.authorityPrefix + label;
|
|
400
|
+
}
|
|
401
|
+
return label.replace(sepRegexp, formatting.separator);
|
|
402
|
+
}
|
|
403
|
+
appendWorkspaceSuffix(label, uri) {
|
|
404
|
+
const formatting = this.findFormatting(uri);
|
|
405
|
+
const suffix = formatting && (typeof formatting.workspaceSuffix === 'string') ? formatting.workspaceSuffix : undefined;
|
|
406
|
+
return suffix ? `${label} [${suffix}]` : label;
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
LabelService = ( (__decorate([
|
|
410
|
+
( (__param(0, IWorkbenchEnvironmentService))),
|
|
411
|
+
( (__param(1, IWorkspaceContextService))),
|
|
412
|
+
( (__param(2, IPathService))),
|
|
413
|
+
( (__param(3, IRemoteAgentService))),
|
|
414
|
+
( (__param(4, IStorageService))),
|
|
415
|
+
( (__param(5, ILifecycleService)))
|
|
416
|
+
], LabelService)));
|
|
417
|
+
|
|
418
|
+
export { LabelService };
|