@codingame/monaco-vscode-bulk-edit-service-override 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bulkEdit.js +2 -2
- package/package.json +2 -2
- package/external/rollup-plugin-styles/dist/runtime/inject-css.js +0 -3
- package/external/tslib/tslib.es6.js +0 -11
- package/override/vs/platform/dialogs/common/dialogs.js +0 -10
- package/vscode/src/vs/workbench/contrib/bulkEdit/browser/bulkEditService.js +0 -360
- package/vscode/src/vs/workbench/contrib/bulkEdit/browser/bulkFileEdits.js +0 -364
- package/vscode/src/vs/workbench/contrib/bulkEdit/browser/bulkTextEdits.js +0 -267
- package/vscode/src/vs/workbench/contrib/bulkEdit/browser/conflicts.js +0 -80
- package/vscode/src/vs/workbench/contrib/bulkEdit/browser/preview/bulkEdit.contribution.js +0 -365
- package/vscode/src/vs/workbench/contrib/bulkEdit/browser/preview/bulkEdit.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/bulkEdit/browser/preview/bulkEditPane.js +0 -342
- package/vscode/src/vs/workbench/contrib/bulkEdit/browser/preview/bulkEditPreview.js +0 -363
- package/vscode/src/vs/workbench/contrib/bulkEdit/browser/preview/bulkEditTree.js +0 -657
|
@@ -1,363 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import { ITextModelService } from 'vscode/vscode/vs/editor/common/services/resolverService';
|
|
3
|
-
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
4
|
-
import { ILanguageService } from 'vscode/vscode/vs/editor/common/languages/language';
|
|
5
|
-
import { IModelService } from 'vscode/vscode/vs/editor/common/services/model';
|
|
6
|
-
import { createTextBufferFactoryFromSnapshot } from 'vscode/vscode/vs/editor/common/model/textModel';
|
|
7
|
-
import { DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
8
|
-
import { coalesceInPlace } from 'vscode/vscode/vs/base/common/arrays';
|
|
9
|
-
import { Range } from 'vscode/vscode/vs/editor/common/core/range';
|
|
10
|
-
import { EditOperation } from 'vscode/vscode/vs/editor/common/core/editOperation';
|
|
11
|
-
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
12
|
-
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
|
|
13
|
-
import { Event, Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
14
|
-
import { ConflictDetector } from '../conflicts.js';
|
|
15
|
-
import { ResourceMap } from 'vscode/vscode/vs/base/common/map';
|
|
16
|
-
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
17
|
-
import { extUri } from 'vscode/vscode/vs/base/common/resources';
|
|
18
|
-
import { ResourceTextEdit, ResourceFileEdit } from 'vscode/vscode/vs/editor/browser/services/bulkEditService';
|
|
19
|
-
import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
|
|
20
|
-
import { generateUuid } from 'vscode/vscode/vs/base/common/uuid';
|
|
21
|
-
import { SnippetParser } from 'vscode/vscode/vs/editor/contrib/snippet/browser/snippetParser';
|
|
22
|
-
import { MicrotaskDelay } from 'vscode/vscode/vs/base/common/symbols';
|
|
23
|
-
|
|
24
|
-
var BulkFileOperations_1, BulkEditPreviewProvider_1;
|
|
25
|
-
class CheckedStates {
|
|
26
|
-
constructor() {
|
|
27
|
-
this._states = ( new WeakMap());
|
|
28
|
-
this._checkedCount = 0;
|
|
29
|
-
this._onDidChange = ( new Emitter());
|
|
30
|
-
this.onDidChange = this._onDidChange.event;
|
|
31
|
-
}
|
|
32
|
-
dispose() {
|
|
33
|
-
this._onDidChange.dispose();
|
|
34
|
-
}
|
|
35
|
-
get checkedCount() {
|
|
36
|
-
return this._checkedCount;
|
|
37
|
-
}
|
|
38
|
-
isChecked(obj) {
|
|
39
|
-
return this._states.get(obj) ?? false;
|
|
40
|
-
}
|
|
41
|
-
updateChecked(obj, value) {
|
|
42
|
-
const valueNow = this._states.get(obj);
|
|
43
|
-
if (valueNow === value) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
if (valueNow === undefined) {
|
|
47
|
-
if (value) {
|
|
48
|
-
this._checkedCount += 1;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
if (value) {
|
|
53
|
-
this._checkedCount += 1;
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
this._checkedCount -= 1;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
this._states.set(obj, value);
|
|
60
|
-
this._onDidChange.fire(obj);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
class BulkTextEdit {
|
|
64
|
-
constructor(parent, textEdit) {
|
|
65
|
-
this.parent = parent;
|
|
66
|
-
this.textEdit = textEdit;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
class BulkFileOperation {
|
|
70
|
-
constructor(uri, parent) {
|
|
71
|
-
this.uri = uri;
|
|
72
|
-
this.parent = parent;
|
|
73
|
-
this.type = 0;
|
|
74
|
-
this.textEdits = [];
|
|
75
|
-
this.originalEdits = ( new Map());
|
|
76
|
-
}
|
|
77
|
-
addEdit(index, type, edit) {
|
|
78
|
-
this.type |= type;
|
|
79
|
-
this.originalEdits.set(index, edit);
|
|
80
|
-
if (edit instanceof ResourceTextEdit) {
|
|
81
|
-
this.textEdits.push(( new BulkTextEdit(this, edit)));
|
|
82
|
-
}
|
|
83
|
-
else if (type === 8 ) {
|
|
84
|
-
this.newUri = edit.newResource;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
needsConfirmation() {
|
|
88
|
-
for (const [, edit] of this.originalEdits) {
|
|
89
|
-
if (!this.parent.checked.isChecked(edit)) {
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
class BulkCategory {
|
|
97
|
-
static { this._defaultMetadata = ( Object.freeze({
|
|
98
|
-
label: ( localizeWithPath(
|
|
99
|
-
'vs/workbench/contrib/bulkEdit/browser/preview/bulkEditPreview',
|
|
100
|
-
'default',
|
|
101
|
-
"Other"
|
|
102
|
-
)),
|
|
103
|
-
icon: Codicon.symbolFile,
|
|
104
|
-
needsConfirmation: false
|
|
105
|
-
})); }
|
|
106
|
-
static keyOf(metadata) {
|
|
107
|
-
return metadata?.label || '<default>';
|
|
108
|
-
}
|
|
109
|
-
constructor(metadata = BulkCategory._defaultMetadata) {
|
|
110
|
-
this.metadata = metadata;
|
|
111
|
-
this.operationByResource = ( new Map());
|
|
112
|
-
}
|
|
113
|
-
get fileOperations() {
|
|
114
|
-
return ( this.operationByResource.values());
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
let BulkFileOperations = BulkFileOperations_1 = class BulkFileOperations {
|
|
118
|
-
static async create(accessor, bulkEdit) {
|
|
119
|
-
const result = accessor.get(IInstantiationService).createInstance(BulkFileOperations_1, bulkEdit);
|
|
120
|
-
return await result._init();
|
|
121
|
-
}
|
|
122
|
-
constructor(_bulkEdit, _fileService, instaService) {
|
|
123
|
-
this._bulkEdit = _bulkEdit;
|
|
124
|
-
this._fileService = _fileService;
|
|
125
|
-
this.checked = ( new CheckedStates());
|
|
126
|
-
this.fileOperations = [];
|
|
127
|
-
this.categories = [];
|
|
128
|
-
this.conflicts = instaService.createInstance(ConflictDetector, _bulkEdit);
|
|
129
|
-
}
|
|
130
|
-
dispose() {
|
|
131
|
-
this.checked.dispose();
|
|
132
|
-
this.conflicts.dispose();
|
|
133
|
-
}
|
|
134
|
-
async _init() {
|
|
135
|
-
const operationByResource = ( new Map());
|
|
136
|
-
const operationByCategory = ( new Map());
|
|
137
|
-
const newToOldUri = ( new ResourceMap());
|
|
138
|
-
for (let idx = 0; idx < this._bulkEdit.length; idx++) {
|
|
139
|
-
const edit = this._bulkEdit[idx];
|
|
140
|
-
let uri;
|
|
141
|
-
let type;
|
|
142
|
-
this.checked.updateChecked(edit, !edit.metadata?.needsConfirmation);
|
|
143
|
-
if (edit instanceof ResourceTextEdit) {
|
|
144
|
-
type = 1 ;
|
|
145
|
-
uri = edit.resource;
|
|
146
|
-
}
|
|
147
|
-
else if (edit instanceof ResourceFileEdit) {
|
|
148
|
-
if (edit.newResource && edit.oldResource) {
|
|
149
|
-
type = 8 ;
|
|
150
|
-
uri = edit.oldResource;
|
|
151
|
-
if (edit.options?.overwrite === undefined && edit.options?.ignoreIfExists && (await this._fileService.exists(uri))) {
|
|
152
|
-
continue;
|
|
153
|
-
}
|
|
154
|
-
newToOldUri.set(edit.newResource, uri);
|
|
155
|
-
}
|
|
156
|
-
else if (edit.oldResource) {
|
|
157
|
-
type = 4 ;
|
|
158
|
-
uri = edit.oldResource;
|
|
159
|
-
if (edit.options?.ignoreIfNotExists && !(await this._fileService.exists(uri))) {
|
|
160
|
-
continue;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
else if (edit.newResource) {
|
|
164
|
-
type = 2 ;
|
|
165
|
-
uri = edit.newResource;
|
|
166
|
-
if (edit.options?.overwrite === undefined && edit.options?.ignoreIfExists && (await this._fileService.exists(uri))) {
|
|
167
|
-
continue;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
continue;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
const insert = (uri, map) => {
|
|
178
|
-
let key = extUri.getComparisonKey(uri, true);
|
|
179
|
-
let operation = map.get(key);
|
|
180
|
-
if (!operation && ( newToOldUri.has(uri))) {
|
|
181
|
-
uri = newToOldUri.get(uri);
|
|
182
|
-
key = extUri.getComparisonKey(uri, true);
|
|
183
|
-
operation = map.get(key);
|
|
184
|
-
}
|
|
185
|
-
if (!operation) {
|
|
186
|
-
operation = ( new BulkFileOperation(uri, this));
|
|
187
|
-
map.set(key, operation);
|
|
188
|
-
}
|
|
189
|
-
operation.addEdit(idx, type, edit);
|
|
190
|
-
};
|
|
191
|
-
insert(uri, operationByResource);
|
|
192
|
-
const key = BulkCategory.keyOf(edit.metadata);
|
|
193
|
-
let category = operationByCategory.get(key);
|
|
194
|
-
if (!category) {
|
|
195
|
-
category = ( new BulkCategory(edit.metadata));
|
|
196
|
-
operationByCategory.set(key, category);
|
|
197
|
-
}
|
|
198
|
-
insert(uri, category.operationByResource);
|
|
199
|
-
}
|
|
200
|
-
operationByResource.forEach(value => this.fileOperations.push(value));
|
|
201
|
-
operationByCategory.forEach(value => this.categories.push(value));
|
|
202
|
-
for (const file of this.fileOperations) {
|
|
203
|
-
if (file.type !== 1 ) {
|
|
204
|
-
let checked = true;
|
|
205
|
-
for (const edit of ( file.originalEdits.values())) {
|
|
206
|
-
if (edit instanceof ResourceFileEdit) {
|
|
207
|
-
checked = checked && this.checked.isChecked(edit);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
if (!checked) {
|
|
211
|
-
for (const edit of ( file.originalEdits.values())) {
|
|
212
|
-
this.checked.updateChecked(edit, checked);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
this.categories.sort((a, b) => {
|
|
218
|
-
if (a.metadata.needsConfirmation === b.metadata.needsConfirmation) {
|
|
219
|
-
return a.metadata.label.localeCompare(b.metadata.label);
|
|
220
|
-
}
|
|
221
|
-
else if (a.metadata.needsConfirmation) {
|
|
222
|
-
return -1;
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
return 1;
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
return this;
|
|
229
|
-
}
|
|
230
|
-
getWorkspaceEdit() {
|
|
231
|
-
const result = [];
|
|
232
|
-
let allAccepted = true;
|
|
233
|
-
for (let i = 0; i < this._bulkEdit.length; i++) {
|
|
234
|
-
const edit = this._bulkEdit[i];
|
|
235
|
-
if (this.checked.isChecked(edit)) {
|
|
236
|
-
result[i] = edit;
|
|
237
|
-
continue;
|
|
238
|
-
}
|
|
239
|
-
allAccepted = false;
|
|
240
|
-
}
|
|
241
|
-
if (allAccepted) {
|
|
242
|
-
return this._bulkEdit;
|
|
243
|
-
}
|
|
244
|
-
coalesceInPlace(result);
|
|
245
|
-
return result;
|
|
246
|
-
}
|
|
247
|
-
getFileEdits(uri) {
|
|
248
|
-
for (const file of this.fileOperations) {
|
|
249
|
-
if (( file.uri.toString()) === ( uri.toString())) {
|
|
250
|
-
const result = [];
|
|
251
|
-
let ignoreAll = false;
|
|
252
|
-
for (const edit of ( file.originalEdits.values())) {
|
|
253
|
-
if (edit instanceof ResourceTextEdit) {
|
|
254
|
-
if (this.checked.isChecked(edit)) {
|
|
255
|
-
result.push(EditOperation.replaceMove(Range.lift(edit.textEdit.range), !edit.textEdit.insertAsSnippet ? edit.textEdit.text : SnippetParser.asInsertText(edit.textEdit.text)));
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
else if (!this.checked.isChecked(edit)) {
|
|
259
|
-
ignoreAll = true;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
if (ignoreAll) {
|
|
263
|
-
return [];
|
|
264
|
-
}
|
|
265
|
-
return result.sort((a, b) => Range.compareRangesUsingStarts(a.range, b.range));
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
return [];
|
|
269
|
-
}
|
|
270
|
-
getUriOfEdit(edit) {
|
|
271
|
-
for (const file of this.fileOperations) {
|
|
272
|
-
for (const value of ( file.originalEdits.values())) {
|
|
273
|
-
if (value === edit) {
|
|
274
|
-
return file.uri;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
throw new Error('invalid edit');
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
BulkFileOperations = BulkFileOperations_1 = ( __decorate([
|
|
282
|
-
( __param(1, IFileService)),
|
|
283
|
-
( __param(2, IInstantiationService))
|
|
284
|
-
], BulkFileOperations));
|
|
285
|
-
let BulkEditPreviewProvider = class BulkEditPreviewProvider {
|
|
286
|
-
static { BulkEditPreviewProvider_1 = this; }
|
|
287
|
-
static { this.Schema = 'vscode-bulkeditpreview-editor'; }
|
|
288
|
-
static { this.emptyPreview = ( URI.from({ scheme: BulkEditPreviewProvider_1.Schema, fragment: 'empty' })); }
|
|
289
|
-
static fromPreviewUri(uri) {
|
|
290
|
-
return ( URI.parse(uri.query));
|
|
291
|
-
}
|
|
292
|
-
constructor(_operations, _languageService, _modelService, _textModelResolverService) {
|
|
293
|
-
this._operations = _operations;
|
|
294
|
-
this._languageService = _languageService;
|
|
295
|
-
this._modelService = _modelService;
|
|
296
|
-
this._textModelResolverService = _textModelResolverService;
|
|
297
|
-
this._disposables = ( new DisposableStore());
|
|
298
|
-
this._modelPreviewEdits = ( new Map());
|
|
299
|
-
this._instanceId = generateUuid();
|
|
300
|
-
this._disposables.add(this._textModelResolverService.registerTextModelContentProvider(BulkEditPreviewProvider_1.Schema, this));
|
|
301
|
-
this._ready = this._init();
|
|
302
|
-
}
|
|
303
|
-
dispose() {
|
|
304
|
-
this._disposables.dispose();
|
|
305
|
-
}
|
|
306
|
-
asPreviewUri(uri) {
|
|
307
|
-
return ( URI.from(
|
|
308
|
-
{ scheme: BulkEditPreviewProvider_1.Schema, authority: this._instanceId, path: uri.path, query: ( uri.toString()) }
|
|
309
|
-
));
|
|
310
|
-
}
|
|
311
|
-
async _init() {
|
|
312
|
-
for (const operation of this._operations.fileOperations) {
|
|
313
|
-
await this._applyTextEditsToPreviewModel(operation.uri);
|
|
314
|
-
}
|
|
315
|
-
this._disposables.add(Event.debounce(this._operations.checked.onDidChange, (_last, e) => e, MicrotaskDelay)(e => {
|
|
316
|
-
const uri = this._operations.getUriOfEdit(e);
|
|
317
|
-
this._applyTextEditsToPreviewModel(uri);
|
|
318
|
-
}));
|
|
319
|
-
}
|
|
320
|
-
async _applyTextEditsToPreviewModel(uri) {
|
|
321
|
-
const model = await this._getOrCreatePreviewModel(uri);
|
|
322
|
-
const undoEdits = this._modelPreviewEdits.get(model.id);
|
|
323
|
-
if (undoEdits) {
|
|
324
|
-
model.applyEdits(undoEdits);
|
|
325
|
-
}
|
|
326
|
-
const newEdits = this._operations.getFileEdits(uri);
|
|
327
|
-
const newUndoEdits = model.applyEdits(newEdits, true);
|
|
328
|
-
this._modelPreviewEdits.set(model.id, newUndoEdits);
|
|
329
|
-
}
|
|
330
|
-
async _getOrCreatePreviewModel(uri) {
|
|
331
|
-
const previewUri = this.asPreviewUri(uri);
|
|
332
|
-
let model = this._modelService.getModel(previewUri);
|
|
333
|
-
if (!model) {
|
|
334
|
-
try {
|
|
335
|
-
const ref = await this._textModelResolverService.createModelReference(uri);
|
|
336
|
-
const sourceModel = ref.object.textEditorModel;
|
|
337
|
-
model = this._modelService.createModel(createTextBufferFactoryFromSnapshot(sourceModel.createSnapshot()), this._languageService.createById(sourceModel.getLanguageId()), previewUri);
|
|
338
|
-
ref.dispose();
|
|
339
|
-
}
|
|
340
|
-
catch {
|
|
341
|
-
model = this._modelService.createModel('', this._languageService.createByFilepathOrFirstLine(previewUri), previewUri);
|
|
342
|
-
}
|
|
343
|
-
queueMicrotask(async () => {
|
|
344
|
-
this._disposables.add(await this._textModelResolverService.createModelReference(model.uri));
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
return model;
|
|
348
|
-
}
|
|
349
|
-
async provideTextContent(previewUri) {
|
|
350
|
-
if (( previewUri.toString()) === ( BulkEditPreviewProvider_1.emptyPreview.toString())) {
|
|
351
|
-
return this._modelService.createModel('', null, previewUri);
|
|
352
|
-
}
|
|
353
|
-
await this._ready;
|
|
354
|
-
return this._modelService.getModel(previewUri);
|
|
355
|
-
}
|
|
356
|
-
};
|
|
357
|
-
BulkEditPreviewProvider = BulkEditPreviewProvider_1 = ( __decorate([
|
|
358
|
-
( __param(1, ILanguageService)),
|
|
359
|
-
( __param(2, IModelService)),
|
|
360
|
-
( __param(3, ITextModelService))
|
|
361
|
-
], BulkEditPreviewProvider));
|
|
362
|
-
|
|
363
|
-
export { BulkCategory, BulkEditPreviewProvider, BulkFileOperation, BulkFileOperations, BulkTextEdit, CheckedStates };
|