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,272 +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.applyEdits = exports.applyEdit = exports.withFormatting = exports.setProperty = exports.removeProperty = void 0;
|
|
11
|
-
|
|
12
|
-
const json_1 = require("./json");
|
|
13
|
-
|
|
14
|
-
const jsonFormatter_1 = require("./jsonFormatter");
|
|
15
|
-
|
|
16
|
-
const arrays_1 = require("./arrays");
|
|
17
|
-
|
|
18
|
-
function removeProperty(text, path, formattingOptions) {
|
|
19
|
-
return setProperty(text, path, undefined, formattingOptions);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
exports.removeProperty = removeProperty;
|
|
23
|
-
|
|
24
|
-
function setProperty(text, originalPath, value, formattingOptions, getInsertionIndex) {
|
|
25
|
-
const path = originalPath.slice();
|
|
26
|
-
const errors = [];
|
|
27
|
-
const root = json_1.parseTree(text, errors);
|
|
28
|
-
let parent = undefined;
|
|
29
|
-
let lastSegment = undefined;
|
|
30
|
-
|
|
31
|
-
while (path.length > 0) {
|
|
32
|
-
lastSegment = path.pop();
|
|
33
|
-
parent = json_1.findNodeAtLocation(root, path);
|
|
34
|
-
|
|
35
|
-
if (parent === undefined && value !== undefined) {
|
|
36
|
-
if (typeof lastSegment === 'string') {
|
|
37
|
-
value = {
|
|
38
|
-
[lastSegment]: value
|
|
39
|
-
};
|
|
40
|
-
} else {
|
|
41
|
-
value = [value];
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (!parent) {
|
|
49
|
-
// empty document
|
|
50
|
-
if (value === undefined) {
|
|
51
|
-
// delete
|
|
52
|
-
throw new Error('Can not delete in empty document');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return withFormatting(text, {
|
|
56
|
-
offset: root ? root.offset : 0,
|
|
57
|
-
length: root ? root.length : 0,
|
|
58
|
-
content: JSON.stringify(value)
|
|
59
|
-
}, formattingOptions);
|
|
60
|
-
} else if (parent.type === 'object' && typeof lastSegment === 'string' && Array.isArray(parent.children)) {
|
|
61
|
-
const existing = json_1.findNodeAtLocation(parent, [lastSegment]);
|
|
62
|
-
|
|
63
|
-
if (existing !== undefined) {
|
|
64
|
-
if (value === undefined) {
|
|
65
|
-
// delete
|
|
66
|
-
if (!existing.parent) {
|
|
67
|
-
throw new Error('Malformed AST');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const propertyIndex = parent.children.indexOf(existing.parent);
|
|
71
|
-
let removeBegin;
|
|
72
|
-
let removeEnd = existing.parent.offset + existing.parent.length;
|
|
73
|
-
|
|
74
|
-
if (propertyIndex > 0) {
|
|
75
|
-
// remove the comma of the previous node
|
|
76
|
-
const previous = parent.children[propertyIndex - 1];
|
|
77
|
-
removeBegin = previous.offset + previous.length;
|
|
78
|
-
} else {
|
|
79
|
-
removeBegin = parent.offset + 1;
|
|
80
|
-
|
|
81
|
-
if (parent.children.length > 1) {
|
|
82
|
-
// remove the comma of the next node
|
|
83
|
-
const next = parent.children[1];
|
|
84
|
-
removeEnd = next.offset;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return withFormatting(text, {
|
|
89
|
-
offset: removeBegin,
|
|
90
|
-
length: removeEnd - removeBegin,
|
|
91
|
-
content: ''
|
|
92
|
-
}, formattingOptions);
|
|
93
|
-
} else {
|
|
94
|
-
// set value of existing property
|
|
95
|
-
return withFormatting(text, {
|
|
96
|
-
offset: existing.offset,
|
|
97
|
-
length: existing.length,
|
|
98
|
-
content: JSON.stringify(value)
|
|
99
|
-
}, formattingOptions);
|
|
100
|
-
}
|
|
101
|
-
} else {
|
|
102
|
-
if (value === undefined) {
|
|
103
|
-
// delete
|
|
104
|
-
return []; // property does not exist, nothing to do
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const newProperty = `${JSON.stringify(lastSegment)}: ${JSON.stringify(value)}`;
|
|
108
|
-
const index = getInsertionIndex ? getInsertionIndex(parent.children.map(p => p.children[0].value)) : parent.children.length;
|
|
109
|
-
let edit;
|
|
110
|
-
|
|
111
|
-
if (index > 0) {
|
|
112
|
-
const previous = parent.children[index - 1];
|
|
113
|
-
edit = {
|
|
114
|
-
offset: previous.offset + previous.length,
|
|
115
|
-
length: 0,
|
|
116
|
-
content: ',' + newProperty
|
|
117
|
-
};
|
|
118
|
-
} else if (parent.children.length === 0) {
|
|
119
|
-
edit = {
|
|
120
|
-
offset: parent.offset + 1,
|
|
121
|
-
length: 0,
|
|
122
|
-
content: newProperty
|
|
123
|
-
};
|
|
124
|
-
} else {
|
|
125
|
-
edit = {
|
|
126
|
-
offset: parent.offset + 1,
|
|
127
|
-
length: 0,
|
|
128
|
-
content: newProperty + ','
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return withFormatting(text, edit, formattingOptions);
|
|
133
|
-
}
|
|
134
|
-
} else if (parent.type === 'array' && typeof lastSegment === 'number' && Array.isArray(parent.children)) {
|
|
135
|
-
if (value !== undefined) {
|
|
136
|
-
// Insert
|
|
137
|
-
const newProperty = `${JSON.stringify(value)}`;
|
|
138
|
-
let edit;
|
|
139
|
-
|
|
140
|
-
if (parent.children.length === 0 || lastSegment === 0) {
|
|
141
|
-
edit = {
|
|
142
|
-
offset: parent.offset + 1,
|
|
143
|
-
length: 0,
|
|
144
|
-
content: parent.children.length === 0 ? newProperty : newProperty + ','
|
|
145
|
-
};
|
|
146
|
-
} else {
|
|
147
|
-
const index = lastSegment === -1 || lastSegment > parent.children.length ? parent.children.length : lastSegment;
|
|
148
|
-
const previous = parent.children[index - 1];
|
|
149
|
-
edit = {
|
|
150
|
-
offset: previous.offset + previous.length,
|
|
151
|
-
length: 0,
|
|
152
|
-
content: ',' + newProperty
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return withFormatting(text, edit, formattingOptions);
|
|
157
|
-
} else {
|
|
158
|
-
//Removal
|
|
159
|
-
const removalIndex = lastSegment;
|
|
160
|
-
const toRemove = parent.children[removalIndex];
|
|
161
|
-
let edit;
|
|
162
|
-
|
|
163
|
-
if (parent.children.length === 1) {
|
|
164
|
-
// only item
|
|
165
|
-
edit = {
|
|
166
|
-
offset: parent.offset + 1,
|
|
167
|
-
length: parent.length - 2,
|
|
168
|
-
content: ''
|
|
169
|
-
};
|
|
170
|
-
} else if (parent.children.length - 1 === removalIndex) {
|
|
171
|
-
// last item
|
|
172
|
-
const previous = parent.children[removalIndex - 1];
|
|
173
|
-
const offset = previous.offset + previous.length;
|
|
174
|
-
const parentEndOffset = parent.offset + parent.length;
|
|
175
|
-
edit = {
|
|
176
|
-
offset,
|
|
177
|
-
length: parentEndOffset - 2 - offset,
|
|
178
|
-
content: ''
|
|
179
|
-
};
|
|
180
|
-
} else {
|
|
181
|
-
edit = {
|
|
182
|
-
offset: toRemove.offset,
|
|
183
|
-
length: parent.children[removalIndex + 1].offset - toRemove.offset,
|
|
184
|
-
content: ''
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
return withFormatting(text, edit, formattingOptions);
|
|
189
|
-
}
|
|
190
|
-
} else {
|
|
191
|
-
throw new Error(`Can not add ${typeof lastSegment !== 'number' ? 'index' : 'property'} to parent of type ${parent.type}`);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
exports.setProperty = setProperty;
|
|
196
|
-
|
|
197
|
-
function withFormatting(text, edit, formattingOptions) {
|
|
198
|
-
// apply the edit
|
|
199
|
-
let newText = applyEdit(text, edit); // format the new text
|
|
200
|
-
|
|
201
|
-
let begin = edit.offset;
|
|
202
|
-
let end = edit.offset + edit.content.length;
|
|
203
|
-
|
|
204
|
-
if (edit.length === 0 || edit.content.length === 0) {
|
|
205
|
-
// insert or remove
|
|
206
|
-
while (begin > 0 && !jsonFormatter_1.isEOL(newText, begin - 1)) {
|
|
207
|
-
begin--;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
while (end < newText.length && !jsonFormatter_1.isEOL(newText, end)) {
|
|
211
|
-
end++;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
const edits = jsonFormatter_1.format(newText, {
|
|
216
|
-
offset: begin,
|
|
217
|
-
length: end - begin
|
|
218
|
-
}, formattingOptions); // apply the formatting edits and track the begin and end offsets of the changes
|
|
219
|
-
|
|
220
|
-
for (let i = edits.length - 1; i >= 0; i--) {
|
|
221
|
-
const curr = edits[i];
|
|
222
|
-
newText = applyEdit(newText, curr);
|
|
223
|
-
begin = Math.min(begin, curr.offset);
|
|
224
|
-
end = Math.max(end, curr.offset + curr.length);
|
|
225
|
-
end += curr.content.length - curr.length;
|
|
226
|
-
} // create a single edit with all changes
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
const editLength = text.length - (newText.length - end) - begin;
|
|
230
|
-
return [{
|
|
231
|
-
offset: begin,
|
|
232
|
-
length: editLength,
|
|
233
|
-
content: newText.substring(begin, end)
|
|
234
|
-
}];
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
exports.withFormatting = withFormatting;
|
|
238
|
-
|
|
239
|
-
function applyEdit(text, edit) {
|
|
240
|
-
return text.substring(0, edit.offset) + edit.content + text.substring(edit.offset + edit.length);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
exports.applyEdit = applyEdit;
|
|
244
|
-
|
|
245
|
-
function applyEdits(text, edits) {
|
|
246
|
-
let sortedEdits = arrays_1.mergeSort(edits, (a, b) => {
|
|
247
|
-
const diff = a.offset - b.offset;
|
|
248
|
-
|
|
249
|
-
if (diff === 0) {
|
|
250
|
-
return a.length - b.length;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
return diff;
|
|
254
|
-
});
|
|
255
|
-
let lastModifiedOffset = text.length;
|
|
256
|
-
|
|
257
|
-
for (let i = sortedEdits.length - 1; i >= 0; i--) {
|
|
258
|
-
let e = sortedEdits[i];
|
|
259
|
-
|
|
260
|
-
if (e.offset + e.length <= lastModifiedOffset) {
|
|
261
|
-
text = applyEdit(text, e);
|
|
262
|
-
} else {
|
|
263
|
-
throw new Error('Overlapping edit');
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
lastModifiedOffset = e.offset;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
return text;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
exports.applyEdits = applyEdits;
|
|
@@ -1,69 +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.getParseErrorMessage = void 0;
|
|
11
|
-
/**
|
|
12
|
-
* Extracted from json.ts to keep json nls free.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
const nls_1 = require("../../nls");
|
|
16
|
-
|
|
17
|
-
function getParseErrorMessage(errorCode) {
|
|
18
|
-
switch (errorCode) {
|
|
19
|
-
case 1
|
|
20
|
-
/* InvalidSymbol */
|
|
21
|
-
:
|
|
22
|
-
return nls_1.localize('error.invalidSymbol', 'Invalid symbol');
|
|
23
|
-
|
|
24
|
-
case 2
|
|
25
|
-
/* InvalidNumberFormat */
|
|
26
|
-
:
|
|
27
|
-
return nls_1.localize('error.invalidNumberFormat', 'Invalid number format');
|
|
28
|
-
|
|
29
|
-
case 3
|
|
30
|
-
/* PropertyNameExpected */
|
|
31
|
-
:
|
|
32
|
-
return nls_1.localize('error.propertyNameExpected', 'Property name expected');
|
|
33
|
-
|
|
34
|
-
case 4
|
|
35
|
-
/* ValueExpected */
|
|
36
|
-
:
|
|
37
|
-
return nls_1.localize('error.valueExpected', 'Value expected');
|
|
38
|
-
|
|
39
|
-
case 5
|
|
40
|
-
/* ColonExpected */
|
|
41
|
-
:
|
|
42
|
-
return nls_1.localize('error.colonExpected', 'Colon expected');
|
|
43
|
-
|
|
44
|
-
case 6
|
|
45
|
-
/* CommaExpected */
|
|
46
|
-
:
|
|
47
|
-
return nls_1.localize('error.commaExpected', 'Comma expected');
|
|
48
|
-
|
|
49
|
-
case 7
|
|
50
|
-
/* CloseBraceExpected */
|
|
51
|
-
:
|
|
52
|
-
return nls_1.localize('error.closeBraceExpected', 'Closing brace expected');
|
|
53
|
-
|
|
54
|
-
case 8
|
|
55
|
-
/* CloseBracketExpected */
|
|
56
|
-
:
|
|
57
|
-
return nls_1.localize('error.closeBracketExpected', 'Closing bracket expected');
|
|
58
|
-
|
|
59
|
-
case 9
|
|
60
|
-
/* EndOfFileExpected */
|
|
61
|
-
:
|
|
62
|
-
return nls_1.localize('error.endOfFileExpected', 'End of file expected');
|
|
63
|
-
|
|
64
|
-
default:
|
|
65
|
-
return '';
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
exports.getParseErrorMessage = getParseErrorMessage;
|
|
@@ -1,316 +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.isEOL = exports.getEOL = exports.format = void 0;
|
|
11
|
-
|
|
12
|
-
const json_1 = require("./json");
|
|
13
|
-
|
|
14
|
-
function format(documentText, range, options) {
|
|
15
|
-
let initialIndentLevel;
|
|
16
|
-
let formatText;
|
|
17
|
-
let formatTextStart;
|
|
18
|
-
let rangeStart;
|
|
19
|
-
let rangeEnd;
|
|
20
|
-
|
|
21
|
-
if (range) {
|
|
22
|
-
rangeStart = range.offset;
|
|
23
|
-
rangeEnd = rangeStart + range.length;
|
|
24
|
-
formatTextStart = rangeStart;
|
|
25
|
-
|
|
26
|
-
while (formatTextStart > 0 && !isEOL(documentText, formatTextStart - 1)) {
|
|
27
|
-
formatTextStart--;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
let endOffset = rangeEnd;
|
|
31
|
-
|
|
32
|
-
while (endOffset < documentText.length && !isEOL(documentText, endOffset)) {
|
|
33
|
-
endOffset++;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
formatText = documentText.substring(formatTextStart, endOffset);
|
|
37
|
-
initialIndentLevel = computeIndentLevel(formatText, options);
|
|
38
|
-
} else {
|
|
39
|
-
formatText = documentText;
|
|
40
|
-
initialIndentLevel = 0;
|
|
41
|
-
formatTextStart = 0;
|
|
42
|
-
rangeStart = 0;
|
|
43
|
-
rangeEnd = documentText.length;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const eol = getEOL(options, documentText);
|
|
47
|
-
let lineBreak = false;
|
|
48
|
-
let indentLevel = 0;
|
|
49
|
-
let indentValue;
|
|
50
|
-
|
|
51
|
-
if (options.insertSpaces) {
|
|
52
|
-
indentValue = repeat(' ', options.tabSize || 4);
|
|
53
|
-
} else {
|
|
54
|
-
indentValue = '\t';
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const scanner = json_1.createScanner(formatText, false);
|
|
58
|
-
let hasError = false;
|
|
59
|
-
|
|
60
|
-
function newLineAndIndent() {
|
|
61
|
-
return eol + repeat(indentValue, initialIndentLevel + indentLevel);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function scanNext() {
|
|
65
|
-
let token = scanner.scan();
|
|
66
|
-
lineBreak = false;
|
|
67
|
-
|
|
68
|
-
while (token === 15
|
|
69
|
-
/* Trivia */
|
|
70
|
-
|| token === 14
|
|
71
|
-
/* LineBreakTrivia */
|
|
72
|
-
) {
|
|
73
|
-
lineBreak = lineBreak || token === 14
|
|
74
|
-
/* LineBreakTrivia */
|
|
75
|
-
;
|
|
76
|
-
token = scanner.scan();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
hasError = token === 16
|
|
80
|
-
/* Unknown */
|
|
81
|
-
|| scanner.getTokenError() !== 0
|
|
82
|
-
/* None */
|
|
83
|
-
;
|
|
84
|
-
return token;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const editOperations = [];
|
|
88
|
-
|
|
89
|
-
function addEdit(text, startOffset, endOffset) {
|
|
90
|
-
if (!hasError && startOffset < rangeEnd && endOffset > rangeStart && documentText.substring(startOffset, endOffset) !== text) {
|
|
91
|
-
editOperations.push({
|
|
92
|
-
offset: startOffset,
|
|
93
|
-
length: endOffset - startOffset,
|
|
94
|
-
content: text
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
let firstToken = scanNext();
|
|
100
|
-
|
|
101
|
-
if (firstToken !== 17
|
|
102
|
-
/* EOF */
|
|
103
|
-
) {
|
|
104
|
-
const firstTokenStart = scanner.getTokenOffset() + formatTextStart;
|
|
105
|
-
const initialIndent = repeat(indentValue, initialIndentLevel);
|
|
106
|
-
addEdit(initialIndent, formatTextStart, firstTokenStart);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
while (firstToken !== 17
|
|
110
|
-
/* EOF */
|
|
111
|
-
) {
|
|
112
|
-
let firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
|
|
113
|
-
let secondToken = scanNext();
|
|
114
|
-
let replaceContent = '';
|
|
115
|
-
|
|
116
|
-
while (!lineBreak && (secondToken === 12
|
|
117
|
-
/* LineCommentTrivia */
|
|
118
|
-
|| secondToken === 13
|
|
119
|
-
/* BlockCommentTrivia */
|
|
120
|
-
)) {
|
|
121
|
-
// comments on the same line: keep them on the same line, but ignore them otherwise
|
|
122
|
-
const commentTokenStart = scanner.getTokenOffset() + formatTextStart;
|
|
123
|
-
addEdit(' ', firstTokenEnd, commentTokenStart);
|
|
124
|
-
firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
|
|
125
|
-
replaceContent = secondToken === 12
|
|
126
|
-
/* LineCommentTrivia */
|
|
127
|
-
? newLineAndIndent() : '';
|
|
128
|
-
secondToken = scanNext();
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (secondToken === 2
|
|
132
|
-
/* CloseBraceToken */
|
|
133
|
-
) {
|
|
134
|
-
if (firstToken !== 1
|
|
135
|
-
/* OpenBraceToken */
|
|
136
|
-
) {
|
|
137
|
-
indentLevel--;
|
|
138
|
-
replaceContent = newLineAndIndent();
|
|
139
|
-
}
|
|
140
|
-
} else if (secondToken === 4
|
|
141
|
-
/* CloseBracketToken */
|
|
142
|
-
) {
|
|
143
|
-
if (firstToken !== 3
|
|
144
|
-
/* OpenBracketToken */
|
|
145
|
-
) {
|
|
146
|
-
indentLevel--;
|
|
147
|
-
replaceContent = newLineAndIndent();
|
|
148
|
-
}
|
|
149
|
-
} else {
|
|
150
|
-
switch (firstToken) {
|
|
151
|
-
case 3
|
|
152
|
-
/* OpenBracketToken */
|
|
153
|
-
:
|
|
154
|
-
case 1
|
|
155
|
-
/* OpenBraceToken */
|
|
156
|
-
:
|
|
157
|
-
indentLevel++;
|
|
158
|
-
replaceContent = newLineAndIndent();
|
|
159
|
-
break;
|
|
160
|
-
|
|
161
|
-
case 5
|
|
162
|
-
/* CommaToken */
|
|
163
|
-
:
|
|
164
|
-
case 12
|
|
165
|
-
/* LineCommentTrivia */
|
|
166
|
-
:
|
|
167
|
-
replaceContent = newLineAndIndent();
|
|
168
|
-
break;
|
|
169
|
-
|
|
170
|
-
case 13
|
|
171
|
-
/* BlockCommentTrivia */
|
|
172
|
-
:
|
|
173
|
-
if (lineBreak) {
|
|
174
|
-
replaceContent = newLineAndIndent();
|
|
175
|
-
} else {
|
|
176
|
-
// symbol following comment on the same line: keep on same line, separate with ' '
|
|
177
|
-
replaceContent = ' ';
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
break;
|
|
181
|
-
|
|
182
|
-
case 6
|
|
183
|
-
/* ColonToken */
|
|
184
|
-
:
|
|
185
|
-
replaceContent = ' ';
|
|
186
|
-
break;
|
|
187
|
-
|
|
188
|
-
case 10
|
|
189
|
-
/* StringLiteral */
|
|
190
|
-
:
|
|
191
|
-
if (secondToken === 6
|
|
192
|
-
/* ColonToken */
|
|
193
|
-
) {
|
|
194
|
-
replaceContent = '';
|
|
195
|
-
break;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// fall through
|
|
199
|
-
|
|
200
|
-
case 7
|
|
201
|
-
/* NullKeyword */
|
|
202
|
-
:
|
|
203
|
-
case 8
|
|
204
|
-
/* TrueKeyword */
|
|
205
|
-
:
|
|
206
|
-
case 9
|
|
207
|
-
/* FalseKeyword */
|
|
208
|
-
:
|
|
209
|
-
case 11
|
|
210
|
-
/* NumericLiteral */
|
|
211
|
-
:
|
|
212
|
-
case 2
|
|
213
|
-
/* CloseBraceToken */
|
|
214
|
-
:
|
|
215
|
-
case 4
|
|
216
|
-
/* CloseBracketToken */
|
|
217
|
-
:
|
|
218
|
-
if (secondToken === 12
|
|
219
|
-
/* LineCommentTrivia */
|
|
220
|
-
|| secondToken === 13
|
|
221
|
-
/* BlockCommentTrivia */
|
|
222
|
-
) {
|
|
223
|
-
replaceContent = ' ';
|
|
224
|
-
} else if (secondToken !== 5
|
|
225
|
-
/* CommaToken */
|
|
226
|
-
&& secondToken !== 17
|
|
227
|
-
/* EOF */
|
|
228
|
-
) {
|
|
229
|
-
hasError = true;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
break;
|
|
233
|
-
|
|
234
|
-
case 16
|
|
235
|
-
/* Unknown */
|
|
236
|
-
:
|
|
237
|
-
hasError = true;
|
|
238
|
-
break;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
if (lineBreak && (secondToken === 12
|
|
242
|
-
/* LineCommentTrivia */
|
|
243
|
-
|| secondToken === 13
|
|
244
|
-
/* BlockCommentTrivia */
|
|
245
|
-
)) {
|
|
246
|
-
replaceContent = newLineAndIndent();
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
const secondTokenStart = scanner.getTokenOffset() + formatTextStart;
|
|
251
|
-
addEdit(replaceContent, firstTokenEnd, secondTokenStart);
|
|
252
|
-
firstToken = secondToken;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
return editOperations;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
exports.format = format;
|
|
259
|
-
|
|
260
|
-
function repeat(s, count) {
|
|
261
|
-
let result = '';
|
|
262
|
-
|
|
263
|
-
for (let i = 0; i < count; i++) {
|
|
264
|
-
result += s;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
return result;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
function computeIndentLevel(content, options) {
|
|
271
|
-
let i = 0;
|
|
272
|
-
let nChars = 0;
|
|
273
|
-
const tabSize = options.tabSize || 4;
|
|
274
|
-
|
|
275
|
-
while (i < content.length) {
|
|
276
|
-
const ch = content.charAt(i);
|
|
277
|
-
|
|
278
|
-
if (ch === ' ') {
|
|
279
|
-
nChars++;
|
|
280
|
-
} else if (ch === '\t') {
|
|
281
|
-
nChars += tabSize;
|
|
282
|
-
} else {
|
|
283
|
-
break;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
i++;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
return Math.floor(nChars / tabSize);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
function getEOL(options, text) {
|
|
293
|
-
for (let i = 0; i < text.length; i++) {
|
|
294
|
-
const ch = text.charAt(i);
|
|
295
|
-
|
|
296
|
-
if (ch === '\r') {
|
|
297
|
-
if (i + 1 < text.length && text.charAt(i + 1) === '\n') {
|
|
298
|
-
return '\r\n';
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
return '\r';
|
|
302
|
-
} else if (ch === '\n') {
|
|
303
|
-
return '\n';
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
return options && options.eol || '\n';
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
exports.getEOL = getEOL;
|
|
311
|
-
|
|
312
|
-
function isEOL(text, offset) {
|
|
313
|
-
return '\r\n'.indexOf(text.charAt(offset)) !== -1;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
exports.isEOL = isEOL;
|
|
@@ -1,9 +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
|
-
});
|