@codingame/monaco-vscode-api 1.83.1 → 1.83.2
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/monaco-editor-treemending.patch +555 -555
- package/package.json +1 -1
- package/vscode/src/vs/platform/extensionManagement/common/extensionNls.js +1 -1
- package/vscode/src/vs/platform/workspaces/common/workspaces.js +15 -15
- package/vscode/src/vs/workbench/api/browser/mainThreadCustomEditors.js +49 -51
- package/vscode/src/vs/workbench/api/browser/mainThreadDocumentsAndEditors.js +58 -69
- package/vscode/src/vs/workbench/api/browser/mainThreadFileSystem.js +23 -23
- package/vscode/src/vs/workbench/api/browser/mainThreadWebviews.js +16 -16
- package/vscode/src/vs/workbench/api/common/extHostCommands.js +59 -65
- package/vscode/src/vs/workbench/api/common/extHostConsoleForwarder.js +8 -8
- package/vscode/src/vs/workbench/api/common/extHostLanguageFeatures.js +151 -215
- package/vscode/src/vs/workbench/api/common/extHostSCM.js +54 -58
- package/vscode/src/vs/workbench/api/common/extHostTreeViews.js +53 -55
- package/vscode/src/vs/workbench/api/common/extHostTunnelService.js +28 -28
- package/vscode/src/vs/workbench/api/common/extHostTypeConverters.js +265 -277
- package/vscode/src/vs/workbench/api/common/extensionHostMain.js +17 -19
- package/vscode/src/vs/workbench/api/worker/extHostExtensionService.js +5 -5
- package/vscode/src/vs/workbench/browser/parts/editor/sideBySideEditor.js +26 -32
- package/vscode/src/vs/workbench/browser/parts/editor/textDiffEditor.js +20 -26
- package/vscode/src/vs/workbench/contrib/bulkEdit/browser/bulkFileEdits.js +58 -74
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.js +19 -19
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsTreeViewer.js +32 -36
- package/vscode/src/vs/workbench/contrib/debug/browser/debugColors.js +19 -19
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/mapping.js +73 -126
- package/vscode/src/vs/workbench/contrib/snippets/browser/snippetsService.js +66 -74
- package/vscode/src/vs/workbench/contrib/tasks/common/tasks.js +82 -92
- package/vscode/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.js +27 -29
- package/vscode/src/vs/workbench/services/extensions/common/abstractExtensionService.js +122 -124
- package/vscode/src/vs/workbench/services/extensions/common/extensionHostManager.js +35 -39
- package/vscode/src/vs/workbench/services/extensions/common/extensionRunningLocationTracker.js +25 -25
- package/vscode/src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.js +30 -32
- package/vscode/src/vs/workbench/services/remote/common/tunnelModel.js +82 -92
- package/vscode/src/vs/workbench/services/textfile/common/textFileEditorModel.js +31 -31
- package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorService.js +16 -16
- package/vscode/src/vs/workbench/services/workingCopy/common/workingCopyBackupService.js +32 -42
|
@@ -21,52 +21,38 @@ class LineRangeMapping {
|
|
|
21
21
|
}
|
|
22
22
|
const startDelta = extendedInputRange.startLineNumber - this.inputRange.startLineNumber;
|
|
23
23
|
const endDelta = extendedInputRange.endLineNumberExclusive - this.inputRange.endLineNumberExclusive;
|
|
24
|
-
return (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
))))
|
|
29
|
-
);
|
|
24
|
+
return ( new LineRangeMapping(extendedInputRange, ( new LineRange(
|
|
25
|
+
this.outputRange.startLineNumber + startDelta,
|
|
26
|
+
this.outputRange.lineCount - startDelta + endDelta
|
|
27
|
+
))));
|
|
30
28
|
}
|
|
31
29
|
join(other) {
|
|
32
|
-
return (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
))
|
|
37
|
-
);
|
|
30
|
+
return ( new LineRangeMapping(
|
|
31
|
+
this.inputRange.join(other.inputRange),
|
|
32
|
+
this.outputRange.join(other.outputRange)
|
|
33
|
+
));
|
|
38
34
|
}
|
|
39
35
|
get resultingDeltaFromOriginalToModified() {
|
|
40
36
|
return this.outputRange.endLineNumberExclusive - this.inputRange.endLineNumberExclusive;
|
|
41
37
|
}
|
|
42
38
|
toString() {
|
|
43
|
-
return `${(
|
|
39
|
+
return `${( this.inputRange.toString())} -> ${( this.outputRange.toString())}`;
|
|
44
40
|
}
|
|
45
41
|
addOutputLineDelta(delta) {
|
|
46
|
-
return (
|
|
47
|
-
(new LineRangeMapping(this.inputRange, this.outputRange.delta(delta)))
|
|
48
|
-
);
|
|
42
|
+
return ( new LineRangeMapping(this.inputRange, this.outputRange.delta(delta)));
|
|
49
43
|
}
|
|
50
44
|
addInputLineDelta(delta) {
|
|
51
|
-
return (
|
|
52
|
-
(new LineRangeMapping(this.inputRange.delta(delta), this.outputRange))
|
|
53
|
-
);
|
|
45
|
+
return ( new LineRangeMapping(this.inputRange.delta(delta), this.outputRange));
|
|
54
46
|
}
|
|
55
47
|
reverse() {
|
|
56
|
-
return (
|
|
57
|
-
(new LineRangeMapping(this.outputRange, this.inputRange))
|
|
58
|
-
);
|
|
48
|
+
return ( new LineRangeMapping(this.outputRange, this.inputRange));
|
|
59
49
|
}
|
|
60
50
|
}
|
|
61
51
|
class DocumentLineRangeMap {
|
|
62
52
|
static betweenOutputs(inputToOutput1, inputToOutput2, inputLineCount) {
|
|
63
53
|
const alignments = MappingAlignment.compute(inputToOutput1, inputToOutput2);
|
|
64
|
-
const mappings = (
|
|
65
|
-
|
|
66
|
-
)));
|
|
67
|
-
return (
|
|
68
|
-
(new DocumentLineRangeMap(mappings, inputLineCount))
|
|
69
|
-
);
|
|
54
|
+
const mappings = ( alignments.map((m) => ( new LineRangeMapping(m.output1Range, m.output2Range))));
|
|
55
|
+
return ( new DocumentLineRangeMap(mappings, inputLineCount));
|
|
70
56
|
}
|
|
71
57
|
constructor(
|
|
72
58
|
lineRangeMappings, inputLineCount) {
|
|
@@ -80,23 +66,16 @@ class DocumentLineRangeMap {
|
|
|
80
66
|
project(lineNumber) {
|
|
81
67
|
const lastBefore = findLast(this.lineRangeMappings, r => r.inputRange.startLineNumber <= lineNumber);
|
|
82
68
|
if (!lastBefore) {
|
|
83
|
-
return (
|
|
84
|
-
(new LineRangeMapping(
|
|
85
|
-
(new LineRange(lineNumber, 1)),
|
|
86
|
-
(new LineRange(lineNumber, 1))
|
|
87
|
-
))
|
|
88
|
-
);
|
|
69
|
+
return ( new LineRangeMapping(( new LineRange(lineNumber, 1)), ( new LineRange(lineNumber, 1))));
|
|
89
70
|
}
|
|
90
71
|
if (lastBefore.inputRange.contains(lineNumber)) {
|
|
91
72
|
return lastBefore;
|
|
92
73
|
}
|
|
93
|
-
const containingRange = (
|
|
94
|
-
const mappedRange = (
|
|
74
|
+
const containingRange = ( new LineRange(lineNumber, 1));
|
|
75
|
+
const mappedRange = ( new LineRange(lineNumber +
|
|
95
76
|
lastBefore.outputRange.endLineNumberExclusive -
|
|
96
|
-
lastBefore.inputRange.endLineNumberExclusive, 1))
|
|
97
|
-
return (
|
|
98
|
-
(new LineRangeMapping(containingRange, mappedRange))
|
|
99
|
-
);
|
|
77
|
+
lastBefore.inputRange.endLineNumberExclusive, 1));
|
|
78
|
+
return ( new LineRangeMapping(containingRange, mappedRange));
|
|
100
79
|
}
|
|
101
80
|
get outputLineCount() {
|
|
102
81
|
const last = lastOrDefault(this.lineRangeMappings);
|
|
@@ -104,31 +83,26 @@ class DocumentLineRangeMap {
|
|
|
104
83
|
return this.inputLineCount + diff;
|
|
105
84
|
}
|
|
106
85
|
reverse() {
|
|
107
|
-
return (
|
|
108
|
-
(new DocumentLineRangeMap(
|
|
109
|
-
(this.lineRangeMappings.map(r => r.reverse())),
|
|
110
|
-
this.outputLineCount
|
|
111
|
-
))
|
|
112
|
-
);
|
|
86
|
+
return ( new DocumentLineRangeMap(( this.lineRangeMappings.map(r => r.reverse())), this.outputLineCount));
|
|
113
87
|
}
|
|
114
88
|
}
|
|
115
89
|
class MappingAlignment {
|
|
116
90
|
static compute(fromInputToOutput1, fromInputToOutput2) {
|
|
117
91
|
const compareByStartLineNumber = compareBy((d) => d.inputRange.startLineNumber, numberComparator);
|
|
118
|
-
const combinedDiffs = concatArrays((
|
|
119
|
-
const currentDiffs = [(
|
|
92
|
+
const combinedDiffs = concatArrays(( fromInputToOutput1.map((diff) => ({ source: 0, diff }))), ( fromInputToOutput2.map((diff) => ({ source: 1, diff })))).sort(compareBy((d) => d.diff, compareByStartLineNumber));
|
|
93
|
+
const currentDiffs = [( new Array()), ( new Array())];
|
|
120
94
|
const deltaFromBaseToInput = [0, 0];
|
|
121
|
-
const alignments = (
|
|
95
|
+
const alignments = ( new Array());
|
|
122
96
|
function pushAndReset(inputRange) {
|
|
123
|
-
const mapping1 = LineRangeMapping.join(currentDiffs[0]) || (
|
|
124
|
-
const mapping2 = LineRangeMapping.join(currentDiffs[1]) || (
|
|
125
|
-
alignments.push((
|
|
97
|
+
const mapping1 = LineRangeMapping.join(currentDiffs[0]) || ( new LineRangeMapping(inputRange, inputRange.delta(deltaFromBaseToInput[0])));
|
|
98
|
+
const mapping2 = LineRangeMapping.join(currentDiffs[1]) || ( new LineRangeMapping(inputRange, inputRange.delta(deltaFromBaseToInput[1])));
|
|
99
|
+
alignments.push(( new MappingAlignment(
|
|
126
100
|
currentInputRange,
|
|
127
101
|
mapping1.extendInputRange(currentInputRange).outputRange,
|
|
128
102
|
currentDiffs[0],
|
|
129
103
|
mapping2.extendInputRange(currentInputRange).outputRange,
|
|
130
104
|
currentDiffs[1]
|
|
131
|
-
)))
|
|
105
|
+
)));
|
|
132
106
|
currentDiffs[0] = [];
|
|
133
107
|
currentDiffs[1] = [];
|
|
134
108
|
}
|
|
@@ -168,49 +142,39 @@ class DetailedLineRangeMapping extends LineRangeMapping {
|
|
|
168
142
|
super(inputRange, outputRange);
|
|
169
143
|
this.inputTextModel = inputTextModel;
|
|
170
144
|
this.outputTextModel = outputTextModel;
|
|
171
|
-
this.rangeMappings = rangeMappings || [(
|
|
145
|
+
this.rangeMappings = rangeMappings || [( new RangeMapping(this.inputRange.toRange(), this.outputRange.toRange()))];
|
|
172
146
|
}
|
|
173
147
|
addOutputLineDelta(delta) {
|
|
174
|
-
return (
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
))
|
|
182
|
-
);
|
|
148
|
+
return ( new DetailedLineRangeMapping(
|
|
149
|
+
this.inputRange,
|
|
150
|
+
this.inputTextModel,
|
|
151
|
+
this.outputRange.delta(delta),
|
|
152
|
+
this.outputTextModel,
|
|
153
|
+
( this.rangeMappings.map(d => d.addOutputLineDelta(delta)))
|
|
154
|
+
));
|
|
183
155
|
}
|
|
184
156
|
addInputLineDelta(delta) {
|
|
185
|
-
return (
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
))
|
|
193
|
-
);
|
|
157
|
+
return ( new DetailedLineRangeMapping(
|
|
158
|
+
this.inputRange.delta(delta),
|
|
159
|
+
this.inputTextModel,
|
|
160
|
+
this.outputRange,
|
|
161
|
+
this.outputTextModel,
|
|
162
|
+
( this.rangeMappings.map(d => d.addInputLineDelta(delta)))
|
|
163
|
+
));
|
|
194
164
|
}
|
|
195
165
|
join(other) {
|
|
196
|
-
return (
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
))
|
|
203
|
-
);
|
|
166
|
+
return ( new DetailedLineRangeMapping(
|
|
167
|
+
this.inputRange.join(other.inputRange),
|
|
168
|
+
this.inputTextModel,
|
|
169
|
+
this.outputRange.join(other.outputRange),
|
|
170
|
+
this.outputTextModel
|
|
171
|
+
));
|
|
204
172
|
}
|
|
205
173
|
getLineEdit() {
|
|
206
|
-
return (
|
|
207
|
-
(new LineRangeEdit(this.inputRange, this.getOutputLines()))
|
|
208
|
-
);
|
|
174
|
+
return ( new LineRangeEdit(this.inputRange, this.getOutputLines()));
|
|
209
175
|
}
|
|
210
176
|
getReverseLineEdit() {
|
|
211
|
-
return (
|
|
212
|
-
(new LineRangeEdit(this.outputRange, this.getInputLines()))
|
|
213
|
-
);
|
|
177
|
+
return ( new LineRangeEdit(this.outputRange, this.getInputLines()));
|
|
214
178
|
}
|
|
215
179
|
getOutputLines() {
|
|
216
180
|
return this.outputRange.getLines(this.outputTextModel);
|
|
@@ -231,29 +195,23 @@ class RangeMapping {
|
|
|
231
195
|
return `${rangeToString(this.inputRange)} -> ${rangeToString(this.outputRange)}`;
|
|
232
196
|
}
|
|
233
197
|
addOutputLineDelta(deltaLines) {
|
|
234
|
-
return (
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
))))
|
|
241
|
-
);
|
|
198
|
+
return ( new RangeMapping(this.inputRange, ( new Range(
|
|
199
|
+
this.outputRange.startLineNumber + deltaLines,
|
|
200
|
+
this.outputRange.startColumn,
|
|
201
|
+
this.outputRange.endLineNumber + deltaLines,
|
|
202
|
+
this.outputRange.endColumn
|
|
203
|
+
))));
|
|
242
204
|
}
|
|
243
205
|
addInputLineDelta(deltaLines) {
|
|
244
|
-
return (
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
)), this.outputRange))
|
|
251
|
-
);
|
|
206
|
+
return ( new RangeMapping(( new Range(
|
|
207
|
+
this.inputRange.startLineNumber + deltaLines,
|
|
208
|
+
this.inputRange.startColumn,
|
|
209
|
+
this.inputRange.endLineNumber + deltaLines,
|
|
210
|
+
this.inputRange.endColumn
|
|
211
|
+
)), this.outputRange));
|
|
252
212
|
}
|
|
253
213
|
reverse() {
|
|
254
|
-
return (
|
|
255
|
-
(new RangeMapping(this.outputRange, this.inputRange))
|
|
256
|
-
);
|
|
214
|
+
return ( new RangeMapping(this.outputRange, this.inputRange));
|
|
257
215
|
}
|
|
258
216
|
}
|
|
259
217
|
class DocumentRangeMap {
|
|
@@ -268,31 +226,25 @@ class DocumentRangeMap {
|
|
|
268
226
|
project(position) {
|
|
269
227
|
const lastBefore = findLast(this.rangeMappings, r => r.inputRange.getStartPosition().isBeforeOrEqual(position));
|
|
270
228
|
if (!lastBefore) {
|
|
271
|
-
return (
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
))
|
|
276
|
-
);
|
|
229
|
+
return ( new RangeMapping(
|
|
230
|
+
Range.fromPositions(position, position),
|
|
231
|
+
Range.fromPositions(position, position)
|
|
232
|
+
));
|
|
277
233
|
}
|
|
278
234
|
if (rangeContainsPosition(lastBefore.inputRange, position)) {
|
|
279
235
|
return lastBefore;
|
|
280
236
|
}
|
|
281
237
|
const dist = lengthBetweenPositions(lastBefore.inputRange.getEndPosition(), position);
|
|
282
238
|
const outputPos = addLength(lastBefore.outputRange.getEndPosition(), dist);
|
|
283
|
-
return (
|
|
284
|
-
(new RangeMapping(Range.fromPositions(position), Range.fromPositions(outputPos)))
|
|
285
|
-
);
|
|
239
|
+
return ( new RangeMapping(Range.fromPositions(position), Range.fromPositions(outputPos)));
|
|
286
240
|
}
|
|
287
241
|
projectRange(range) {
|
|
288
242
|
const start = this.project(range.getStartPosition());
|
|
289
243
|
const end = this.project(range.getEndPosition());
|
|
290
|
-
return (
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
))
|
|
295
|
-
);
|
|
244
|
+
return ( new RangeMapping(
|
|
245
|
+
start.inputRange.plusRange(end.inputRange),
|
|
246
|
+
start.outputRange.plusRange(end.outputRange)
|
|
247
|
+
));
|
|
296
248
|
}
|
|
297
249
|
get outputLineCount() {
|
|
298
250
|
const last = lastOrDefault(this.rangeMappings);
|
|
@@ -300,12 +252,7 @@ class DocumentRangeMap {
|
|
|
300
252
|
return this.inputLineCount + diff;
|
|
301
253
|
}
|
|
302
254
|
reverse() {
|
|
303
|
-
return (
|
|
304
|
-
(new DocumentRangeMap(
|
|
305
|
-
(this.rangeMappings.map(m => m.reverse())),
|
|
306
|
-
this.outputLineCount
|
|
307
|
-
))
|
|
308
|
-
);
|
|
255
|
+
return ( new DocumentRangeMap(( this.rangeMappings.map(m => m.reverse())), this.outputLineCount));
|
|
309
256
|
}
|
|
310
257
|
}
|
|
311
258
|
export { DetailedLineRangeMapping, DocumentLineRangeMap, DocumentRangeMap, LineRangeMapping, MappingAlignment, RangeMapping };
|
|
@@ -25,45 +25,45 @@ import { IUserDataProfileService } from '../../../services/userDataProfile/commo
|
|
|
25
25
|
import { insertInto } from 'monaco-editor/esm/vs/base/common/arrays.js';
|
|
26
26
|
var SnippetEnablement_1, SnippetUsageTimestamps_1;
|
|
27
27
|
var snippetExt;
|
|
28
|
-
( (
|
|
28
|
+
( (function(snippetExt) {
|
|
29
29
|
function toValidSnippet(extension, snippet, languageService) {
|
|
30
30
|
if (isFalsyOrWhitespace(snippet.path)) {
|
|
31
|
-
extension.collector.error((
|
|
31
|
+
extension.collector.error(( localize(
|
|
32
32
|
'invalid.path.0',
|
|
33
33
|
"Expected string in `contributes.{0}.path`. Provided value: {1}",
|
|
34
34
|
extension.description.name,
|
|
35
35
|
String(snippet.path)
|
|
36
|
-
)))
|
|
36
|
+
)));
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
39
|
if (isFalsyOrWhitespace(snippet.language) && !snippet.path.endsWith('.code-snippets')) {
|
|
40
|
-
extension.collector.error((
|
|
40
|
+
extension.collector.error(( localize(
|
|
41
41
|
'invalid.language.0',
|
|
42
42
|
"When omitting the language, the value of `contributes.{0}.path` must be a `.code-snippets`-file. Provided value: {1}",
|
|
43
43
|
extension.description.name,
|
|
44
44
|
String(snippet.path)
|
|
45
|
-
)))
|
|
45
|
+
)));
|
|
46
46
|
return null;
|
|
47
47
|
}
|
|
48
48
|
if (!isFalsyOrWhitespace(snippet.language) && !languageService.isRegisteredLanguageId(snippet.language)) {
|
|
49
|
-
extension.collector.error((
|
|
49
|
+
extension.collector.error(( localize(
|
|
50
50
|
'invalid.language',
|
|
51
51
|
"Unknown language in `contributes.{0}.language`. Provided value: {1}",
|
|
52
52
|
extension.description.name,
|
|
53
53
|
String(snippet.language)
|
|
54
|
-
)))
|
|
54
|
+
)));
|
|
55
55
|
return null;
|
|
56
56
|
}
|
|
57
57
|
const extensionLocation = extension.description.extensionLocation;
|
|
58
58
|
const snippetLocation = resources.joinPath(extensionLocation, snippet.path);
|
|
59
59
|
if (!resources.isEqualOrParent(snippetLocation, extensionLocation)) {
|
|
60
|
-
extension.collector.error((
|
|
60
|
+
extension.collector.error(( localize(
|
|
61
61
|
'invalid.path.1',
|
|
62
62
|
"Expected `contributes.{0}.path` ({1}) to be included inside extension's folder ({2}). This might make the extension non-portable.",
|
|
63
63
|
extension.description.name,
|
|
64
64
|
snippetLocation.path,
|
|
65
65
|
extensionLocation.path
|
|
66
|
-
)))
|
|
66
|
+
)));
|
|
67
67
|
return null;
|
|
68
68
|
}
|
|
69
69
|
return {
|
|
@@ -73,7 +73,7 @@ var snippetExt;
|
|
|
73
73
|
}
|
|
74
74
|
snippetExt.toValidSnippet = toValidSnippet;
|
|
75
75
|
snippetExt.snippetsContribution = {
|
|
76
|
-
description: (
|
|
76
|
+
description: ( localize('vscode.extension.contributes.snippets', 'Contributes snippets.')),
|
|
77
77
|
type: 'array',
|
|
78
78
|
defaultSnippets: [{ body: [{ language: '', path: '' }] }],
|
|
79
79
|
items: {
|
|
@@ -81,28 +81,28 @@ var snippetExt;
|
|
|
81
81
|
defaultSnippets: [{ body: { language: '${1:id}', path: './snippets/${2:id}.json.' } }],
|
|
82
82
|
properties: {
|
|
83
83
|
language: {
|
|
84
|
-
description: (
|
|
84
|
+
description: ( localize(
|
|
85
85
|
'vscode.extension.contributes.snippets-language',
|
|
86
86
|
'Language identifier for which this snippet is contributed to.'
|
|
87
|
-
))
|
|
87
|
+
)),
|
|
88
88
|
type: 'string'
|
|
89
89
|
},
|
|
90
90
|
path: {
|
|
91
|
-
description: (
|
|
91
|
+
description: ( localize(
|
|
92
92
|
'vscode.extension.contributes.snippets-path',
|
|
93
93
|
'Path of the snippets file. The path is relative to the extension folder and typically starts with \'./snippets/\'.'
|
|
94
|
-
))
|
|
94
|
+
)),
|
|
95
95
|
type: 'string'
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
|
-
snippetExt.point = (
|
|
100
|
+
snippetExt.point = ( ExtensionsRegistry.registerExtensionPoint({
|
|
101
101
|
extensionPoint: 'snippets',
|
|
102
102
|
deps: [languagesExtPoint],
|
|
103
103
|
jsonSchema: snippetExt.snippetsContribution
|
|
104
|
-
}))
|
|
105
|
-
})(snippetExt || (snippetExt = {})))
|
|
104
|
+
}));
|
|
105
|
+
})(snippetExt || (snippetExt = {})));
|
|
106
106
|
function watch(service, resource, callback) {
|
|
107
107
|
return combinedDisposable(service.watch(resource), service.onDidFilesChange(e => {
|
|
108
108
|
if (e.affects(resource)) {
|
|
@@ -121,20 +121,18 @@ let SnippetEnablement = class SnippetEnablement {
|
|
|
121
121
|
data = JSON.parse(raw);
|
|
122
122
|
}
|
|
123
123
|
catch { }
|
|
124
|
-
this._ignored = isStringArray(data) ? (
|
|
124
|
+
this._ignored = isStringArray(data) ? ( new Set(data)) : ( new Set());
|
|
125
125
|
}
|
|
126
126
|
isIgnored(id) {
|
|
127
|
-
return (
|
|
128
|
-
(this._ignored.has(id))
|
|
129
|
-
);
|
|
127
|
+
return ( this._ignored.has(id));
|
|
130
128
|
}
|
|
131
129
|
updateIgnored(id, value) {
|
|
132
130
|
let changed = false;
|
|
133
|
-
if ((
|
|
131
|
+
if (( this._ignored.has(id)) && !value) {
|
|
134
132
|
this._ignored.delete(id);
|
|
135
133
|
changed = true;
|
|
136
134
|
}
|
|
137
|
-
else if (!(
|
|
135
|
+
else if (!( this._ignored.has(id)) && value) {
|
|
138
136
|
this._ignored.add(id);
|
|
139
137
|
changed = true;
|
|
140
138
|
}
|
|
@@ -143,9 +141,9 @@ let SnippetEnablement = class SnippetEnablement {
|
|
|
143
141
|
}
|
|
144
142
|
}
|
|
145
143
|
};
|
|
146
|
-
SnippetEnablement = SnippetEnablement_1 = (
|
|
147
|
-
(
|
|
148
|
-
], SnippetEnablement))
|
|
144
|
+
SnippetEnablement = SnippetEnablement_1 = ( __decorate([
|
|
145
|
+
( __param(0, IStorageService))
|
|
146
|
+
], SnippetEnablement));
|
|
149
147
|
let SnippetUsageTimestamps = class SnippetUsageTimestamps {
|
|
150
148
|
static { SnippetUsageTimestamps_1 = this; }
|
|
151
149
|
static { this._key = 'snippets.usageTimestamps'; }
|
|
@@ -159,7 +157,7 @@ let SnippetUsageTimestamps = class SnippetUsageTimestamps {
|
|
|
159
157
|
catch {
|
|
160
158
|
data = [];
|
|
161
159
|
}
|
|
162
|
-
this._usages = Array.isArray(data) ? (
|
|
160
|
+
this._usages = Array.isArray(data) ? ( new Map(data)) : ( new Map());
|
|
163
161
|
}
|
|
164
162
|
getUsageTimestamp(id) {
|
|
165
163
|
return this._usages.get(id);
|
|
@@ -171,9 +169,9 @@ let SnippetUsageTimestamps = class SnippetUsageTimestamps {
|
|
|
171
169
|
this._storageService.store(SnippetUsageTimestamps_1._key, JSON.stringify(all), 0 , 0 );
|
|
172
170
|
}
|
|
173
171
|
};
|
|
174
|
-
SnippetUsageTimestamps = SnippetUsageTimestamps_1 = (
|
|
175
|
-
(
|
|
176
|
-
], SnippetUsageTimestamps))
|
|
172
|
+
SnippetUsageTimestamps = SnippetUsageTimestamps_1 = ( __decorate([
|
|
173
|
+
( __param(0, IStorageService))
|
|
174
|
+
], SnippetUsageTimestamps));
|
|
177
175
|
let SnippetsService = class SnippetsService {
|
|
178
176
|
constructor(_environmentService, _userDataProfileService, _contextService, _languageService, _logService, _fileService, _textfileService, _extensionResourceLoaderService, lifecycleService, instantiationService, languageConfigurationService) {
|
|
179
177
|
this._environmentService = _environmentService;
|
|
@@ -184,15 +182,15 @@ let SnippetsService = class SnippetsService {
|
|
|
184
182
|
this._fileService = _fileService;
|
|
185
183
|
this._textfileService = _textfileService;
|
|
186
184
|
this._extensionResourceLoaderService = _extensionResourceLoaderService;
|
|
187
|
-
this._disposables = (
|
|
185
|
+
this._disposables = ( new DisposableStore());
|
|
188
186
|
this._pendingWork = [];
|
|
189
|
-
this._files = (
|
|
187
|
+
this._files = ( new ResourceMap());
|
|
190
188
|
this._pendingWork.push(Promise.resolve(lifecycleService.when(3 ).then(() => {
|
|
191
189
|
this._initExtensionSnippets();
|
|
192
190
|
this._initUserSnippets();
|
|
193
191
|
this._initWorkspaceSnippets();
|
|
194
192
|
})));
|
|
195
|
-
setSnippetSuggestSupport((
|
|
193
|
+
setSnippetSuggestSupport(( new SnippetCompletionProvider(this._languageService, this, languageConfigurationService)));
|
|
196
194
|
this._enablement = instantiationService.createInstance(SnippetEnablement);
|
|
197
195
|
this._usageTimestamps = instantiationService.createInstance(SnippetUsageTimestamps);
|
|
198
196
|
}
|
|
@@ -215,9 +213,7 @@ let SnippetsService = class SnippetsService {
|
|
|
215
213
|
}
|
|
216
214
|
async getSnippetFiles() {
|
|
217
215
|
await this._joinSnippets();
|
|
218
|
-
return (
|
|
219
|
-
(this._files.values())
|
|
220
|
-
);
|
|
216
|
+
return ( this._files.values());
|
|
221
217
|
}
|
|
222
218
|
async getSnippets(languageId, opts) {
|
|
223
219
|
await this._joinSnippets();
|
|
@@ -225,18 +221,18 @@ let SnippetsService = class SnippetsService {
|
|
|
225
221
|
const promises = [];
|
|
226
222
|
if (languageId) {
|
|
227
223
|
if (this._languageService.isRegisteredLanguageId(languageId)) {
|
|
228
|
-
for (const file of (
|
|
224
|
+
for (const file of ( this._files.values())) {
|
|
229
225
|
promises.push(file.load()
|
|
230
226
|
.then(file => file.select(languageId, result))
|
|
231
|
-
.catch(err => this._logService.error(err, (
|
|
227
|
+
.catch(err => this._logService.error(err, ( file.location.toString()))));
|
|
232
228
|
}
|
|
233
229
|
}
|
|
234
230
|
}
|
|
235
231
|
else {
|
|
236
|
-
for (const file of (
|
|
232
|
+
for (const file of ( this._files.values())) {
|
|
237
233
|
promises.push(file.load()
|
|
238
234
|
.then(file => insertInto(result, result.length, file.data))
|
|
239
|
-
.catch(err => this._logService.error(err, (
|
|
235
|
+
.catch(err => this._logService.error(err, ( file.location.toString()))));
|
|
240
236
|
}
|
|
241
237
|
}
|
|
242
238
|
await Promise.all(promises);
|
|
@@ -245,7 +241,7 @@ let SnippetsService = class SnippetsService {
|
|
|
245
241
|
getSnippetsSync(languageId, opts) {
|
|
246
242
|
const result = [];
|
|
247
243
|
if (this._languageService.isRegisteredLanguageId(languageId)) {
|
|
248
|
-
for (const file of (
|
|
244
|
+
for (const file of ( this._files.values())) {
|
|
249
245
|
file.load().catch(_err => { });
|
|
250
246
|
file.select(languageId, result);
|
|
251
247
|
}
|
|
@@ -325,30 +321,26 @@ let SnippetsService = class SnippetsService {
|
|
|
325
321
|
}
|
|
326
322
|
}
|
|
327
323
|
else {
|
|
328
|
-
const file = (
|
|
324
|
+
const file = ( new SnippetFile(
|
|
329
325
|
3 ,
|
|
330
326
|
validContribution.location,
|
|
331
327
|
validContribution.language ? [validContribution.language] : undefined,
|
|
332
328
|
extension.description,
|
|
333
329
|
this._fileService,
|
|
334
330
|
this._extensionResourceLoaderService
|
|
335
|
-
))
|
|
331
|
+
));
|
|
336
332
|
this._files.set(file.location, file);
|
|
337
333
|
if (this._environmentService.isExtensionDevelopment) {
|
|
338
334
|
file.load().then(file => {
|
|
339
|
-
if ((
|
|
340
|
-
extension.collector.warn((
|
|
335
|
+
if (( file.data.some(snippet => snippet.isBogous))) {
|
|
336
|
+
extension.collector.warn(( localize(
|
|
341
337
|
'badVariableUse',
|
|
342
338
|
"One or more snippets from the extension '{0}' very likely confuse snippet-variables and snippet-placeholders (see https://code.visualstudio.com/docs/editor/userdefinedsnippets#_snippet-syntax for more details)",
|
|
343
339
|
extension.description.name
|
|
344
|
-
)))
|
|
340
|
+
)));
|
|
345
341
|
}
|
|
346
342
|
}, err => {
|
|
347
|
-
extension.collector.warn((
|
|
348
|
-
'badFile',
|
|
349
|
-
"The snippet file \"{0}\" could not be read.",
|
|
350
|
-
(file.location.toString())
|
|
351
|
-
))));
|
|
343
|
+
extension.collector.warn(( localize('badFile', "The snippet file \"{0}\" could not be read.", ( file.location.toString()))));
|
|
352
344
|
});
|
|
353
345
|
}
|
|
354
346
|
}
|
|
@@ -357,7 +349,7 @@ let SnippetsService = class SnippetsService {
|
|
|
357
349
|
});
|
|
358
350
|
}
|
|
359
351
|
_initWorkspaceSnippets() {
|
|
360
|
-
const disposables = (
|
|
352
|
+
const disposables = ( new DisposableStore());
|
|
361
353
|
const updateWorkspaceSnippets = () => {
|
|
362
354
|
disposables.clear();
|
|
363
355
|
this._pendingWork.push(this._initWorkspaceFolderSnippets(this._contextService.getWorkspace(), disposables));
|
|
@@ -368,7 +360,7 @@ let SnippetsService = class SnippetsService {
|
|
|
368
360
|
updateWorkspaceSnippets();
|
|
369
361
|
}
|
|
370
362
|
async _initWorkspaceFolderSnippets(workspace, bucket) {
|
|
371
|
-
const promises = (
|
|
363
|
+
const promises = ( workspace.folders.map(async (folder) => {
|
|
372
364
|
const snippetFolder = folder.toResource('.vscode');
|
|
373
365
|
const value = await this._fileService.exists(snippetFolder);
|
|
374
366
|
if (value) {
|
|
@@ -381,11 +373,11 @@ let SnippetsService = class SnippetsService {
|
|
|
381
373
|
}
|
|
382
374
|
}));
|
|
383
375
|
}
|
|
384
|
-
}))
|
|
376
|
+
}));
|
|
385
377
|
await Promise.all(promises);
|
|
386
378
|
}
|
|
387
379
|
async _initUserSnippets() {
|
|
388
|
-
const disposables = (
|
|
380
|
+
const disposables = ( new DisposableStore());
|
|
389
381
|
const updateUserSnippets = async () => {
|
|
390
382
|
disposables.clear();
|
|
391
383
|
const userSnippetsFolder = this._userDataProfileService.currentProfile.snippetsHome;
|
|
@@ -399,7 +391,7 @@ let SnippetsService = class SnippetsService {
|
|
|
399
391
|
await updateUserSnippets();
|
|
400
392
|
}
|
|
401
393
|
_initFolderSnippets(source, folder, bucket) {
|
|
402
|
-
const disposables = (
|
|
394
|
+
const disposables = ( new DisposableStore());
|
|
403
395
|
const addFolderSnippets = async () => {
|
|
404
396
|
disposables.clear();
|
|
405
397
|
if (!(await this._fileService.exists(folder))) {
|
|
@@ -412,7 +404,7 @@ let SnippetsService = class SnippetsService {
|
|
|
412
404
|
}
|
|
413
405
|
}
|
|
414
406
|
catch (err) {
|
|
415
|
-
this._logService.error(`Failed snippets from folder '${(
|
|
407
|
+
this._logService.error(`Failed snippets from folder '${( folder.toString())}'`, err);
|
|
416
408
|
}
|
|
417
409
|
};
|
|
418
410
|
bucket.add(this._textfileService.files.onDidSave(e => {
|
|
@@ -428,43 +420,43 @@ let SnippetsService = class SnippetsService {
|
|
|
428
420
|
const ext = resources.extname(uri);
|
|
429
421
|
if (source === 1 && ext === '.json') {
|
|
430
422
|
const langName = resources.basename(uri).replace(/\.json/, '');
|
|
431
|
-
this._files.set(uri, (
|
|
423
|
+
this._files.set(uri, ( new SnippetFile(
|
|
432
424
|
source,
|
|
433
425
|
uri,
|
|
434
426
|
[langName],
|
|
435
427
|
undefined,
|
|
436
428
|
this._fileService,
|
|
437
429
|
this._extensionResourceLoaderService
|
|
438
|
-
)))
|
|
430
|
+
)));
|
|
439
431
|
}
|
|
440
432
|
else if (ext === '.code-snippets') {
|
|
441
|
-
this._files.set(uri, (
|
|
433
|
+
this._files.set(uri, ( new SnippetFile(
|
|
442
434
|
source,
|
|
443
435
|
uri,
|
|
444
436
|
undefined,
|
|
445
437
|
undefined,
|
|
446
438
|
this._fileService,
|
|
447
439
|
this._extensionResourceLoaderService
|
|
448
|
-
)))
|
|
440
|
+
)));
|
|
449
441
|
}
|
|
450
442
|
return {
|
|
451
443
|
dispose: () => this._files.delete(uri)
|
|
452
444
|
};
|
|
453
445
|
}
|
|
454
446
|
};
|
|
455
|
-
SnippetsService = (
|
|
456
|
-
(
|
|
457
|
-
(
|
|
458
|
-
(
|
|
459
|
-
(
|
|
460
|
-
(
|
|
461
|
-
(
|
|
462
|
-
(
|
|
463
|
-
(
|
|
464
|
-
(
|
|
465
|
-
(
|
|
466
|
-
(
|
|
467
|
-
], SnippetsService))
|
|
447
|
+
SnippetsService = ( __decorate([
|
|
448
|
+
( __param(0, IEnvironmentService)),
|
|
449
|
+
( __param(1, IUserDataProfileService)),
|
|
450
|
+
( __param(2, IWorkspaceContextService)),
|
|
451
|
+
( __param(3, ILanguageService)),
|
|
452
|
+
( __param(4, ILogService)),
|
|
453
|
+
( __param(5, IFileService)),
|
|
454
|
+
( __param(6, ITextFileService)),
|
|
455
|
+
( __param(7, IExtensionResourceLoaderService)),
|
|
456
|
+
( __param(8, ILifecycleService)),
|
|
457
|
+
( __param(9, IInstantiationService)),
|
|
458
|
+
( __param(10, ILanguageConfigurationService))
|
|
459
|
+
], SnippetsService));
|
|
468
460
|
function getNonWhitespacePrefix(model, position) {
|
|
469
461
|
const MAX_PREFIX_LENGTH = 100;
|
|
470
462
|
const line = model.getLineContent(position.lineNumber).substr(0, position.column - 1);
|