custom-electron-titlebar 3.2.6 → 3.2.10
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/.github/FUNDING.yml +1 -0
- package/README.md +15 -24
- package/_config.yml +1 -0
- package/{lib → build}/browser/browser.d.ts +0 -0
- package/{lib → build}/browser/browser.js +0 -0
- package/{lib → build}/browser/browser.js.map +0 -0
- package/{lib → build}/browser/event.d.ts +0 -0
- package/{lib → build}/browser/event.js +2 -1
- package/{lib → build}/browser/event.js.map +1 -1
- package/{lib → build}/browser/iframe.d.ts +0 -0
- package/{lib → build}/browser/iframe.js +0 -0
- package/{lib → build}/browser/iframe.js.map +0 -0
- package/{lib → build}/browser/keyboardEvent.d.ts +0 -0
- package/{lib → build}/browser/keyboardEvent.js +0 -0
- package/{lib → build}/browser/keyboardEvent.js.map +0 -0
- package/{lib → build}/browser/mouseEvent.d.ts +0 -0
- package/{lib → build}/browser/mouseEvent.js +0 -0
- package/{lib → build}/browser/mouseEvent.js.map +0 -0
- package/{lib → build}/common/arrays.d.ts +0 -0
- package/{lib → build}/common/arrays.js +0 -0
- package/{lib → build}/common/arrays.js.map +0 -0
- package/{lib → build}/common/async.d.ts +0 -0
- package/{lib → build}/common/async.js +0 -0
- package/{lib → build}/common/async.js.map +0 -0
- package/{lib → build}/common/charCode.d.ts +0 -0
- package/{lib → build}/common/charCode.js +0 -0
- package/{lib → build}/common/charCode.js.map +0 -0
- package/{lib → build}/common/color.d.ts +0 -0
- package/{lib → build}/common/color.js +0 -0
- package/{lib → build}/common/color.js.map +0 -0
- package/{lib → build}/common/dom.d.ts +0 -0
- package/{lib → build}/common/dom.js +16 -14
- package/build/common/dom.js.map +1 -0
- package/{lib → build}/common/event.d.ts +0 -0
- package/{lib → build}/common/event.js +1 -1
- package/build/common/event.js.map +1 -0
- package/{lib → build}/common/iterator.d.ts +0 -0
- package/{lib → build}/common/iterator.js +0 -0
- package/{lib → build}/common/iterator.js.map +0 -0
- package/{lib → build}/common/keyCodes.d.ts +0 -0
- package/{lib → build}/common/keyCodes.js +0 -0
- package/{lib → build}/common/keyCodes.js.map +0 -0
- package/{lib → build}/common/lifecycle.d.ts +0 -0
- package/{lib → build}/common/lifecycle.js +0 -0
- package/{lib → build}/common/lifecycle.js.map +0 -0
- package/{lib → build}/common/linkedList.d.ts +0 -0
- package/{lib → build}/common/linkedList.js +0 -0
- package/{lib → build}/common/linkedList.js.map +0 -0
- package/{lib → build}/common/platform.d.ts +0 -0
- package/{lib → build}/common/platform.js +0 -0
- package/{lib → build}/common/platform.js.map +0 -0
- package/{lib → build}/index.d.ts +0 -0
- package/{lib → build}/index.js +0 -0
- package/{lib → build}/index.js.map +0 -0
- package/{lib → build}/menu/menu.d.ts +0 -0
- package/{lib → build}/menu/menu.js +38 -38
- package/build/menu/menu.js.map +1 -0
- package/{lib → build}/menu/menuitem.d.ts +10 -2
- package/{lib → build}/menu/menuitem.js +70 -34
- package/build/menu/menuitem.js.map +1 -0
- package/{lib → build}/menubar.d.ts +0 -0
- package/{lib → build}/menubar.js +29 -30
- package/build/menubar.js.map +1 -0
- package/{lib → build}/themebar.d.ts +0 -0
- package/{lib → build}/themebar.js +2 -2
- package/build/themebar.js.map +1 -0
- package/{lib → build}/titlebar.d.ts +0 -0
- package/{lib → build}/titlebar.js +61 -58
- package/build/titlebar.js.map +1 -0
- package/package.json +13 -7
- package/lib/common/dom.js.map +0 -1
- package/lib/common/enableNativeMenuCommands.d.ts +0 -1
- package/lib/common/enableNativeMenuCommands.js +0 -32
- package/lib/common/enableNativeMenuCommands.js.map +0 -1
- package/lib/common/event.js.map +0 -1
- package/lib/main.d.ts +0 -1
- package/lib/main.js +0 -14
- package/lib/main.js.map +0 -1
- package/lib/menu/menu.js.map +0 -1
- package/lib/menu/menuitem.js.map +0 -1
- package/lib/menubar.js.map +0 -1
- package/lib/themebar.js.map +0 -1
- package/lib/titlebar.js.map +0 -1
- package/lib/vs/base/browser/browser.js +0 -150
- package/lib/vs/base/browser/canIUse.js +0 -58
- package/lib/vs/base/browser/codicons.js +0 -37
- package/lib/vs/base/browser/contextmenu.js +0 -9
- package/lib/vs/base/browser/dnd.js +0 -113
- package/lib/vs/base/browser/dom.js +0 -1417
- package/lib/vs/base/browser/event.js +0 -36
- package/lib/vs/base/browser/fastDomNode.js +0 -265
- package/lib/vs/base/browser/formattedTextRenderer.js +0 -248
- package/lib/vs/base/browser/globalMouseMoveMonitor.js +0 -137
- package/lib/vs/base/browser/history.js +0 -9
- package/lib/vs/base/browser/iframe.js +0 -126
- package/lib/vs/base/browser/keyboardEvent.js +0 -599
- package/lib/vs/base/browser/mouseEvent.js +0 -155
- package/lib/vs/base/browser/touch.js +0 -315
- package/lib/vs/base/browser/ui/actionbar/actionViewItems.js +0 -397
- package/lib/vs/base/browser/ui/actionbar/actionbar.js +0 -583
- package/lib/vs/base/browser/ui/checkbox/checkbox.js +0 -251
- package/lib/vs/base/browser/ui/codicons/codiconLabel.js +0 -31
- package/lib/vs/base/browser/ui/codicons/codiconStyles.js +0 -47
- package/lib/vs/base/browser/ui/contextview/contextview.js +0 -367
- package/lib/vs/base/browser/ui/dropdown/dropdown.js +0 -256
- package/lib/vs/base/browser/ui/dropdown/dropdownActionViewItem.js +0 -120
- package/lib/vs/base/browser/ui/keybindingLabel/keybindingLabel.js +0 -118
- package/lib/vs/base/browser/ui/list/list.js +0 -54
- package/lib/vs/base/browser/ui/list/listPaging.js +0 -322
- package/lib/vs/base/browser/ui/list/listView.js +0 -1388
- package/lib/vs/base/browser/ui/list/listWidget.js +0 -1709
- package/lib/vs/base/browser/ui/list/rangeMap.js +0 -223
- package/lib/vs/base/browser/ui/list/rowCache.js +0 -113
- package/lib/vs/base/browser/ui/list/splice.js +0 -23
- package/lib/vs/base/browser/ui/menu/menu.js +0 -1371
- package/lib/vs/base/browser/ui/menu/menubar.js +0 -1139
- package/lib/vs/base/browser/ui/scrollbar/abstractScrollbar.js +0 -278
- package/lib/vs/base/browser/ui/scrollbar/horizontalScrollbar.js +0 -115
- package/lib/vs/base/browser/ui/scrollbar/scrollableElement.js +0 -646
- package/lib/vs/base/browser/ui/scrollbar/scrollableElementOptions.js +0 -9
- package/lib/vs/base/browser/ui/scrollbar/scrollbarArrow.js +0 -106
- package/lib/vs/base/browser/ui/scrollbar/scrollbarState.js +0 -184
- package/lib/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.js +0 -116
- package/lib/vs/base/browser/ui/scrollbar/verticalScrollbar.js +0 -114
- package/lib/vs/base/browser/ui/selectBox/selectBox.js +0 -85
- package/lib/vs/base/browser/ui/selectBox/selectBoxCustom.js +0 -985
- package/lib/vs/base/browser/ui/selectBox/selectBoxNative.js +0 -188
- package/lib/vs/base/browser/ui/toolbar/toolbar.js +0 -206
- package/lib/vs/base/browser/ui/widget.js +0 -69
- package/lib/vs/base/common/actions.js +0 -224
- package/lib/vs/base/common/amd.js +0 -31
- package/lib/vs/base/common/arrays.js +0 -641
- package/lib/vs/base/common/assert.js +0 -21
- package/lib/vs/base/common/async.js +0 -966
- package/lib/vs/base/common/buffer.js +0 -250
- package/lib/vs/base/common/cache.js +0 -40
- package/lib/vs/base/common/cancellation.js +0 -146
- package/lib/vs/base/common/charCode.js +0 -9
- package/lib/vs/base/common/codicon.js +0 -136
- package/lib/vs/base/common/codicons.js +0 -1378
- package/lib/vs/base/common/collections.js +0 -133
- package/lib/vs/base/common/color.js +0 -716
- package/lib/vs/base/common/comparers.js +0 -280
- package/lib/vs/base/common/console.js +0 -142
- package/lib/vs/base/common/date.js +0 -113
- package/lib/vs/base/common/decorators.js +0 -169
- package/lib/vs/base/common/errorMessage.js +0 -93
- package/lib/vs/base/common/errors.js +0 -213
- package/lib/vs/base/common/errorsWithActions.js +0 -28
- package/lib/vs/base/common/event.js +0 -873
- package/lib/vs/base/common/extpath.js +0 -401
- package/lib/vs/base/common/filters.js +0 -948
- package/lib/vs/base/common/functional.js +0 -28
- package/lib/vs/base/common/fuzzyScorer.js +0 -811
- package/lib/vs/base/common/glob.js +0 -696
- package/lib/vs/base/common/hash.js +0 -359
- package/lib/vs/base/common/history.js +0 -116
- package/lib/vs/base/common/htmlContent.js +0 -162
- package/lib/vs/base/common/idGenerator.js +0 -25
- package/lib/vs/base/common/iterator.js +0 -118
- package/lib/vs/base/common/json.js +0 -1624
- package/lib/vs/base/common/jsonEdit.js +0 -272
- package/lib/vs/base/common/jsonErrorMessages.js +0 -69
- package/lib/vs/base/common/jsonFormatter.js +0 -316
- package/lib/vs/base/common/jsonSchema.js +0 -9
- package/lib/vs/base/common/keyCodes.js +0 -591
- package/lib/vs/base/common/keybindingLabels.js +0 -231
- package/lib/vs/base/common/keybindingParser.js +0 -142
- package/lib/vs/base/common/labels.js +0 -430
- package/lib/vs/base/common/lazy.js +0 -71
- package/lib/vs/base/common/lifecycle.js +0 -308
- package/lib/vs/base/common/linkedList.js +0 -152
- package/lib/vs/base/common/linkedText.js +0 -73
- package/lib/vs/base/common/map.js +0 -1108
- package/lib/vs/base/common/marshalling.js +0 -80
- package/lib/vs/base/common/mime.js +0 -321
- package/lib/vs/base/common/navigator.js +0 -50
- package/lib/vs/base/common/network.js +0 -160
- package/lib/vs/base/common/normalization.js +0 -78
- package/lib/vs/base/common/numbers.js +0 -55
- package/lib/vs/base/common/objects.js +0 -268
- package/lib/vs/base/common/paging.js +0 -190
- package/lib/vs/base/common/parsers.js +0 -78
- package/lib/vs/base/common/path.js +0 -1550
- package/lib/vs/base/common/platform.js +0 -245
- package/lib/vs/base/common/process.js +0 -52
- package/lib/vs/base/common/processes.js +0 -32
- package/lib/vs/base/common/range.js +0 -79
- package/lib/vs/base/common/resourceTree.js +0 -185
- package/lib/vs/base/common/resources.js +0 -421
- package/lib/vs/base/common/scanCode.js +0 -1472
- package/lib/vs/base/common/scrollable.js +0 -397
- package/lib/vs/base/common/search.js +0 -55
- package/lib/vs/base/common/sequence.js +0 -64
- package/lib/vs/base/common/severity.js +0 -55
- package/lib/vs/base/common/skipList.js +0 -234
- package/lib/vs/base/common/stopwatch.js +0 -45
- package/lib/vs/base/common/stream.js +0 -418
- package/lib/vs/base/common/strings.js +0 -1283
- package/lib/vs/base/common/styler.js +0 -9
- package/lib/vs/base/common/types.js +0 -296
- package/lib/vs/base/common/uint.js +0 -46
- package/lib/vs/base/common/uri.js +0 -756
- package/lib/vs/base/common/uriIpc.js +0 -154
- package/lib/vs/base/common/uuid.js +0 -70
- package/lib/vs/nls.mock.js +0 -31
- package/lib/vs/platform/actions/browser/menuEntryActionViewItem.js +0 -342
- package/lib/vs/platform/actions/common/actions.js +0 -456
- package/lib/vs/platform/actions/common/menuService.js +0 -194
- package/lib/vs/platform/clipboard/browser/clipboardService.js +0 -99
- package/lib/vs/platform/clipboard/common/clipboardService.js +0 -14
- package/lib/vs/platform/contextkey/common/contextkey.js +0 -1210
- package/lib/vs/platform/contextkey/common/contextkeys.js +0 -23
- package/lib/vs/platform/contextview/browser/contextView.js +0 -15
- package/lib/vs/platform/contextview/browser/contextViewService.js +0 -96
- package/lib/vs/platform/environment/common/argv.js +0 -9
- package/lib/vs/platform/environment/common/environment.js +0 -15
- package/lib/vs/platform/instantiation/common/descriptors.js +0 -25
- package/lib/vs/platform/instantiation/common/extensions.js +0 -26
- package/lib/vs/platform/instantiation/common/graph.js +0 -93
- package/lib/vs/platform/instantiation/common/instantiation.js +0 -84
- package/lib/vs/platform/instantiation/common/instantiationService.js +0 -361
- package/lib/vs/platform/instantiation/common/serviceCollection.js +0 -39
- package/lib/vs/platform/keybinding/common/baseResolvedKeybinding.js +0 -73
- package/lib/vs/platform/keybinding/common/keybinding.js +0 -14
- package/lib/vs/platform/keybinding/common/keybindingResolver.js +0 -391
- package/lib/vs/platform/keybinding/common/keybindingsRegistry.js +0 -229
- package/lib/vs/platform/keybinding/common/resolvedKeybindingItem.js +0 -47
- package/lib/vs/platform/keybinding/common/usLayoutResolvedKeybinding.js +0 -160
- package/lib/vs/platform/layout/browser/layoutService.js +0 -14
- package/lib/vs/platform/menubar/common/menubar.js +0 -34
- package/lib/vs/platform/registry/common/platform.js +0 -38
- package/lib/vs/platform/theme/browser/checkbox.js +0 -32
- package/lib/vs/platform/theme/common/colorRegistry.js +0 -1154
- package/lib/vs/platform/theme/common/styler.js +0 -290
- package/lib/vs/platform/theme/common/theme.js +0 -21
- package/lib/vs/platform/theme/common/themeService.js +0 -176
- package/lib/vs/platform/theme/common/tokenClassificationRegistry.js +0 -540
- package/lib/vs/platform/theme/test/common/testThemeService.js +0 -98
|
@@ -1,430 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.splitName = exports.unmnemonicLabel = exports.mnemonicButtonLabel = exports.mnemonicMenuLabel = exports.template = exports.shorten = exports.untildify = exports.tildify = exports.normalizeDriveLetter = exports.getBaseLabel = exports.getPathLabel = void 0;
|
|
11
|
-
|
|
12
|
-
const uri_1 = require("./uri");
|
|
13
|
-
|
|
14
|
-
const path_1 = require("./path");
|
|
15
|
-
|
|
16
|
-
const strings_1 = require("./strings");
|
|
17
|
-
|
|
18
|
-
const network_1 = require("./network");
|
|
19
|
-
|
|
20
|
-
const platform_1 = require("./platform");
|
|
21
|
-
|
|
22
|
-
const resources_1 = require("./resources");
|
|
23
|
-
/**
|
|
24
|
-
* @deprecated use LabelService instead
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
function getPathLabel(resource, userHomeProvider, rootProvider) {
|
|
29
|
-
if (typeof resource === 'string') {
|
|
30
|
-
resource = uri_1.URI.file(resource);
|
|
31
|
-
} // return early if we can resolve a relative path label from the root
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (rootProvider) {
|
|
35
|
-
const baseResource = rootProvider.getWorkspaceFolder(resource);
|
|
36
|
-
|
|
37
|
-
if (baseResource) {
|
|
38
|
-
const hasMultipleRoots = rootProvider.getWorkspace().folders.length > 1;
|
|
39
|
-
let pathLabel;
|
|
40
|
-
|
|
41
|
-
if (resources_1.isEqual(baseResource.uri, resource)) {
|
|
42
|
-
pathLabel = ''; // no label if paths are identical
|
|
43
|
-
} else {
|
|
44
|
-
pathLabel = resources_1.relativePath(baseResource.uri, resource);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (hasMultipleRoots) {
|
|
48
|
-
const rootName = baseResource.name ? baseResource.name : resources_1.basename(baseResource.uri);
|
|
49
|
-
pathLabel = pathLabel ? rootName + ' • ' + pathLabel : rootName; // always show root basename if there are multiple
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return pathLabel;
|
|
53
|
-
}
|
|
54
|
-
} // return if the resource is neither file:// nor untitled:// and no baseResource was provided
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (resource.scheme !== network_1.Schemas.file && resource.scheme !== network_1.Schemas.untitled) {
|
|
58
|
-
return resource.with({
|
|
59
|
-
query: null,
|
|
60
|
-
fragment: null
|
|
61
|
-
}).toString(true);
|
|
62
|
-
} // convert c:\something => C:\something
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (hasDriveLetter(resource.fsPath)) {
|
|
66
|
-
return path_1.normalize(normalizeDriveLetter(resource.fsPath));
|
|
67
|
-
} // normalize and tildify (macOS, Linux only)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
let res = path_1.normalize(resource.fsPath);
|
|
71
|
-
|
|
72
|
-
if (!platform_1.isWindows && (userHomeProvider === null || userHomeProvider === void 0 ? void 0 : userHomeProvider.userHome)) {
|
|
73
|
-
res = tildify(res, userHomeProvider.userHome.fsPath);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return res;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
exports.getPathLabel = getPathLabel;
|
|
80
|
-
|
|
81
|
-
function getBaseLabel(resource) {
|
|
82
|
-
if (!resource) {
|
|
83
|
-
return undefined;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (typeof resource === 'string') {
|
|
87
|
-
resource = uri_1.URI.file(resource);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const base = resources_1.basename(resource) || (resource.scheme === network_1.Schemas.file ? resource.fsPath : resource.path)
|
|
91
|
-
/* can be empty string if '/' is passed in */
|
|
92
|
-
; // convert c: => C:
|
|
93
|
-
|
|
94
|
-
if (hasDriveLetter(base)) {
|
|
95
|
-
return normalizeDriveLetter(base);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return base;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
exports.getBaseLabel = getBaseLabel;
|
|
102
|
-
|
|
103
|
-
function hasDriveLetter(path) {
|
|
104
|
-
return !!(platform_1.isWindows && path && path[1] === ':');
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function normalizeDriveLetter(path) {
|
|
108
|
-
if (hasDriveLetter(path)) {
|
|
109
|
-
return path.charAt(0).toUpperCase() + path.slice(1);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return path;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
exports.normalizeDriveLetter = normalizeDriveLetter;
|
|
116
|
-
let normalizedUserHomeCached = Object.create(null);
|
|
117
|
-
|
|
118
|
-
function tildify(path, userHome) {
|
|
119
|
-
if (platform_1.isWindows || !path || !userHome) {
|
|
120
|
-
return path; // unsupported
|
|
121
|
-
} // Keep a normalized user home path as cache to prevent accumulated string creation
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
let normalizedUserHome = normalizedUserHomeCached.original === userHome ? normalizedUserHomeCached.normalized : undefined;
|
|
125
|
-
|
|
126
|
-
if (!normalizedUserHome) {
|
|
127
|
-
normalizedUserHome = `${strings_1.rtrim(userHome, path_1.posix.sep)}${path_1.posix.sep}`;
|
|
128
|
-
normalizedUserHomeCached = {
|
|
129
|
-
original: userHome,
|
|
130
|
-
normalized: normalizedUserHome
|
|
131
|
-
};
|
|
132
|
-
} // Linux: case sensitive, macOS: case insensitive
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (platform_1.isLinux ? path.startsWith(normalizedUserHome) : strings_1.startsWithIgnoreCase(path, normalizedUserHome)) {
|
|
136
|
-
path = `~/${path.substr(normalizedUserHome.length)}`;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return path;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
exports.tildify = tildify;
|
|
143
|
-
|
|
144
|
-
function untildify(path, userHome) {
|
|
145
|
-
return path.replace(/^~($|\/|\\)/, `${userHome}$1`);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
exports.untildify = untildify;
|
|
149
|
-
/**
|
|
150
|
-
* Shortens the paths but keeps them easy to distinguish.
|
|
151
|
-
* Replaces not important parts with ellipsis.
|
|
152
|
-
* Every shorten path matches only one original path and vice versa.
|
|
153
|
-
*
|
|
154
|
-
* Algorithm for shortening paths is as follows:
|
|
155
|
-
* 1. For every path in list, find unique substring of that path.
|
|
156
|
-
* 2. Unique substring along with ellipsis is shortened path of that path.
|
|
157
|
-
* 3. To find unique substring of path, consider every segment of length from 1 to path.length of path from end of string
|
|
158
|
-
* and if present segment is not substring to any other paths then present segment is unique path,
|
|
159
|
-
* else check if it is not present as suffix of any other path and present segment is suffix of path itself,
|
|
160
|
-
* if it is true take present segment as unique path.
|
|
161
|
-
* 4. Apply ellipsis to unique segment according to whether segment is present at start/in-between/end of path.
|
|
162
|
-
*
|
|
163
|
-
* Example 1
|
|
164
|
-
* 1. consider 2 paths i.e. ['a\\b\\c\\d', 'a\\f\\b\\c\\d']
|
|
165
|
-
* 2. find unique path of first path,
|
|
166
|
-
* a. 'd' is present in path2 and is suffix of path2, hence not unique of present path.
|
|
167
|
-
* b. 'c' is present in path2 and 'c' is not suffix of present path, similarly for 'b' and 'a' also.
|
|
168
|
-
* c. 'd\\c' is suffix of path2.
|
|
169
|
-
* d. 'b\\c' is not suffix of present path.
|
|
170
|
-
* e. 'a\\b' is not present in path2, hence unique path is 'a\\b...'.
|
|
171
|
-
* 3. for path2, 'f' is not present in path1 hence unique is '...\\f\\...'.
|
|
172
|
-
*
|
|
173
|
-
* Example 2
|
|
174
|
-
* 1. consider 2 paths i.e. ['a\\b', 'a\\b\\c'].
|
|
175
|
-
* a. Even if 'b' is present in path2, as 'b' is suffix of path1 and is not suffix of path2, unique path will be '...\\b'.
|
|
176
|
-
* 2. for path2, 'c' is not present in path1 hence unique path is '..\\c'.
|
|
177
|
-
*/
|
|
178
|
-
|
|
179
|
-
const ellipsis = '\u2026';
|
|
180
|
-
const unc = '\\\\';
|
|
181
|
-
const home = '~';
|
|
182
|
-
|
|
183
|
-
function shorten(paths, pathSeparator = path_1.sep) {
|
|
184
|
-
const shortenedPaths = new Array(paths.length); // for every path
|
|
185
|
-
|
|
186
|
-
let match = false;
|
|
187
|
-
|
|
188
|
-
for (let pathIndex = 0; pathIndex < paths.length; pathIndex++) {
|
|
189
|
-
let path = paths[pathIndex];
|
|
190
|
-
|
|
191
|
-
if (path === '') {
|
|
192
|
-
shortenedPaths[pathIndex] = `.${pathSeparator}`;
|
|
193
|
-
continue;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (!path) {
|
|
197
|
-
shortenedPaths[pathIndex] = path;
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
match = true; // trim for now and concatenate unc path (e.g. \\network) or root path (/etc, ~/etc) later
|
|
202
|
-
|
|
203
|
-
let prefix = '';
|
|
204
|
-
|
|
205
|
-
if (path.indexOf(unc) === 0) {
|
|
206
|
-
prefix = path.substr(0, path.indexOf(unc) + unc.length);
|
|
207
|
-
path = path.substr(path.indexOf(unc) + unc.length);
|
|
208
|
-
} else if (path.indexOf(pathSeparator) === 0) {
|
|
209
|
-
prefix = path.substr(0, path.indexOf(pathSeparator) + pathSeparator.length);
|
|
210
|
-
path = path.substr(path.indexOf(pathSeparator) + pathSeparator.length);
|
|
211
|
-
} else if (path.indexOf(home) === 0) {
|
|
212
|
-
prefix = path.substr(0, path.indexOf(home) + home.length);
|
|
213
|
-
path = path.substr(path.indexOf(home) + home.length);
|
|
214
|
-
} // pick the first shortest subpath found
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const segments = path.split(pathSeparator);
|
|
218
|
-
|
|
219
|
-
for (let subpathLength = 1; match && subpathLength <= segments.length; subpathLength++) {
|
|
220
|
-
for (let start = segments.length - subpathLength; match && start >= 0; start--) {
|
|
221
|
-
match = false;
|
|
222
|
-
let subpath = segments.slice(start, start + subpathLength).join(pathSeparator); // that is unique to any other path
|
|
223
|
-
|
|
224
|
-
for (let otherPathIndex = 0; !match && otherPathIndex < paths.length; otherPathIndex++) {
|
|
225
|
-
// suffix subpath treated specially as we consider no match 'x' and 'x/...'
|
|
226
|
-
if (otherPathIndex !== pathIndex && paths[otherPathIndex] && paths[otherPathIndex].indexOf(subpath) > -1) {
|
|
227
|
-
const isSubpathEnding = start + subpathLength === segments.length; // Adding separator as prefix for subpath, such that 'endsWith(src, trgt)' considers subpath as directory name instead of plain string.
|
|
228
|
-
// prefix is not added when either subpath is root directory or path[otherPathIndex] does not have multiple directories.
|
|
229
|
-
|
|
230
|
-
const subpathWithSep = start > 0 && paths[otherPathIndex].indexOf(pathSeparator) > -1 ? pathSeparator + subpath : subpath;
|
|
231
|
-
const isOtherPathEnding = paths[otherPathIndex].endsWith(subpathWithSep);
|
|
232
|
-
match = !isSubpathEnding || isOtherPathEnding;
|
|
233
|
-
}
|
|
234
|
-
} // found unique subpath
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
if (!match) {
|
|
238
|
-
let result = ''; // preserve disk drive or root prefix
|
|
239
|
-
|
|
240
|
-
if (segments[0].endsWith(':') || prefix !== '') {
|
|
241
|
-
if (start === 1) {
|
|
242
|
-
// extend subpath to include disk drive prefix
|
|
243
|
-
start = 0;
|
|
244
|
-
subpathLength++;
|
|
245
|
-
subpath = segments[0] + pathSeparator + subpath;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
if (start > 0) {
|
|
249
|
-
result = segments[0] + pathSeparator;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
result = prefix + result;
|
|
253
|
-
} // add ellipsis at the beginning if neeeded
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
if (start > 0) {
|
|
257
|
-
result = result + ellipsis + pathSeparator;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
result = result + subpath; // add ellipsis at the end if needed
|
|
261
|
-
|
|
262
|
-
if (start + subpathLength < segments.length) {
|
|
263
|
-
result = result + pathSeparator + ellipsis;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
shortenedPaths[pathIndex] = result;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
if (match) {
|
|
272
|
-
shortenedPaths[pathIndex] = path; // use full path if no unique subpaths found
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
return shortenedPaths;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
exports.shorten = shorten;
|
|
280
|
-
var Type;
|
|
281
|
-
|
|
282
|
-
(function (Type) {
|
|
283
|
-
Type[Type["TEXT"] = 0] = "TEXT";
|
|
284
|
-
Type[Type["VARIABLE"] = 1] = "VARIABLE";
|
|
285
|
-
Type[Type["SEPARATOR"] = 2] = "SEPARATOR";
|
|
286
|
-
})(Type || (Type = {}));
|
|
287
|
-
/**
|
|
288
|
-
* Helper to insert values for specific template variables into the string. E.g. "this $(is) a $(template)" can be
|
|
289
|
-
* passed to this function together with an object that maps "is" and "template" to strings to have them replaced.
|
|
290
|
-
* @param value string to which templating is applied
|
|
291
|
-
* @param values the values of the templates to use
|
|
292
|
-
*/
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
function template(template, values = Object.create(null)) {
|
|
296
|
-
const segments = [];
|
|
297
|
-
let inVariable = false;
|
|
298
|
-
let curVal = '';
|
|
299
|
-
|
|
300
|
-
for (const char of template) {
|
|
301
|
-
// Beginning of variable
|
|
302
|
-
if (char === '$' || inVariable && char === '{') {
|
|
303
|
-
if (curVal) {
|
|
304
|
-
segments.push({
|
|
305
|
-
value: curVal,
|
|
306
|
-
type: Type.TEXT
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
curVal = '';
|
|
311
|
-
inVariable = true;
|
|
312
|
-
} // End of variable
|
|
313
|
-
else if (char === '}' && inVariable) {
|
|
314
|
-
const resolved = values[curVal]; // Variable
|
|
315
|
-
|
|
316
|
-
if (typeof resolved === 'string') {
|
|
317
|
-
if (resolved.length) {
|
|
318
|
-
segments.push({
|
|
319
|
-
value: resolved,
|
|
320
|
-
type: Type.VARIABLE
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
} // Separator
|
|
324
|
-
else if (resolved) {
|
|
325
|
-
const prevSegment = segments[segments.length - 1];
|
|
326
|
-
|
|
327
|
-
if (!prevSegment || prevSegment.type !== Type.SEPARATOR) {
|
|
328
|
-
segments.push({
|
|
329
|
-
value: resolved.label,
|
|
330
|
-
type: Type.SEPARATOR
|
|
331
|
-
}); // prevent duplicate separators
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
curVal = '';
|
|
336
|
-
inVariable = false;
|
|
337
|
-
} // Text or Variable Name
|
|
338
|
-
else {
|
|
339
|
-
curVal += char;
|
|
340
|
-
}
|
|
341
|
-
} // Tail
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
if (curVal && !inVariable) {
|
|
345
|
-
segments.push({
|
|
346
|
-
value: curVal,
|
|
347
|
-
type: Type.TEXT
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
return segments.filter((segment, index) => {
|
|
352
|
-
// Only keep separator if we have values to the left and right
|
|
353
|
-
if (segment.type === Type.SEPARATOR) {
|
|
354
|
-
const left = segments[index - 1];
|
|
355
|
-
const right = segments[index + 1];
|
|
356
|
-
return [left, right].every(segment => segment && (segment.type === Type.VARIABLE || segment.type === Type.TEXT) && segment.value.length > 0);
|
|
357
|
-
} // accept any TEXT and VARIABLE
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
return true;
|
|
361
|
-
}).map(segment => segment.value).join('');
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
exports.template = template;
|
|
365
|
-
/**
|
|
366
|
-
* Handles mnemonics for menu items. Depending on OS:
|
|
367
|
-
* - Windows: Supported via & character (replace && with &)
|
|
368
|
-
* - Linux: Supported via & character (replace && with &)
|
|
369
|
-
* - macOS: Unsupported (replace && with empty string)
|
|
370
|
-
*/
|
|
371
|
-
|
|
372
|
-
function mnemonicMenuLabel(label, forceDisableMnemonics) {
|
|
373
|
-
if (platform_1.isMacintosh || forceDisableMnemonics) {
|
|
374
|
-
return label.replace(/\(&&\w\)|&&/g, '').replace(/&/g, platform_1.isMacintosh ? '&' : '&&');
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
return label.replace(/&&|&/g, m => m === '&' ? '&&' : '&');
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
exports.mnemonicMenuLabel = mnemonicMenuLabel;
|
|
381
|
-
/**
|
|
382
|
-
* Handles mnemonics for buttons. Depending on OS:
|
|
383
|
-
* - Windows: Supported via & character (replace && with & and & with && for escaping)
|
|
384
|
-
* - Linux: Supported via _ character (replace && with _)
|
|
385
|
-
* - macOS: Unsupported (replace && with empty string)
|
|
386
|
-
*/
|
|
387
|
-
|
|
388
|
-
function mnemonicButtonLabel(label, forceDisableMnemonics) {
|
|
389
|
-
if (platform_1.isMacintosh || forceDisableMnemonics) {
|
|
390
|
-
return label.replace(/\(&&\w\)|&&/g, '');
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
if (platform_1.isWindows) {
|
|
394
|
-
return label.replace(/&&|&/g, m => m === '&' ? '&&' : '&');
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
return label.replace(/&&/g, '_');
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
exports.mnemonicButtonLabel = mnemonicButtonLabel;
|
|
401
|
-
|
|
402
|
-
function unmnemonicLabel(label) {
|
|
403
|
-
return label.replace(/&/g, '&&');
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
exports.unmnemonicLabel = unmnemonicLabel;
|
|
407
|
-
/**
|
|
408
|
-
* Splits a path in name and parent path, supporting both '/' and '\'
|
|
409
|
-
*/
|
|
410
|
-
|
|
411
|
-
function splitName(fullPath) {
|
|
412
|
-
const p = fullPath.indexOf('/') !== -1 ? path_1.posix : path_1.win32;
|
|
413
|
-
const name = p.basename(fullPath);
|
|
414
|
-
const parentPath = p.dirname(fullPath);
|
|
415
|
-
|
|
416
|
-
if (name.length) {
|
|
417
|
-
return {
|
|
418
|
-
name,
|
|
419
|
-
parentPath
|
|
420
|
-
};
|
|
421
|
-
} // only the root segment
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
return {
|
|
425
|
-
name: parentPath,
|
|
426
|
-
parentPath: ''
|
|
427
|
-
};
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
exports.splitName = splitName;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.Lazy = void 0;
|
|
11
|
-
|
|
12
|
-
class Lazy {
|
|
13
|
-
constructor(executor) {
|
|
14
|
-
this.executor = executor;
|
|
15
|
-
this._didRun = false;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* True if the lazy value has been resolved.
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
hasValue() {
|
|
23
|
-
return this._didRun;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Get the wrapped value.
|
|
27
|
-
*
|
|
28
|
-
* This will force evaluation of the lazy value if it has not been resolved yet. Lazy values are only
|
|
29
|
-
* resolved once. `getValue` will re-throw exceptions that are hit while resolving the value
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
getValue() {
|
|
34
|
-
if (!this._didRun) {
|
|
35
|
-
try {
|
|
36
|
-
this._value = this.executor();
|
|
37
|
-
} catch (err) {
|
|
38
|
-
this._error = err;
|
|
39
|
-
} finally {
|
|
40
|
-
this._didRun = true;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (this._error) {
|
|
45
|
-
throw this._error;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return this._value;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Get the wrapped value without forcing evaluation.
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
get rawValue() {
|
|
56
|
-
return this._value;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Create a new lazy value that is the result of applying `f` to the wrapped value.
|
|
60
|
-
*
|
|
61
|
-
* This does not force the evaluation of the current lazy value.
|
|
62
|
-
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
map(f) {
|
|
66
|
-
return new Lazy(() => f(this.getValue()));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
exports.Lazy = Lazy;
|