@codingame/monaco-vscode-explorer-service-override 3.2.3 → 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/explorer.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
2
- import { ExplorerService } from './vscode/src/vs/workbench/contrib/files/browser/explorerService.js';
2
+ import { ExplorerService } from 'vscode/vscode/vs/workbench/contrib/files/browser/explorerService';
3
3
  import { IExplorerService } from 'vscode/vscode/vs/workbench/contrib/files/browser/files';
4
- import './vscode/src/vs/workbench/contrib/files/browser/fileCommands.js';
5
- import './vscode/src/vs/workbench/contrib/files/browser/fileActions.contribution.js';
6
- import './vscode/src/vs/workbench/contrib/files/browser/files.explorer.contribution.js';
4
+ import 'vscode/vscode/vs/workbench/contrib/files/browser/fileCommands';
5
+ import 'vscode/vscode/vs/workbench/contrib/files/browser/fileActions.contribution';
6
+ import 'vscode/vscode/vs/workbench/contrib/files/browser/files.explorer.contribution';
7
7
 
8
8
  function getServiceOverride() {
9
9
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-explorer-service-override",
3
- "version": "3.2.3",
3
+ "version": "4.1.0",
4
4
  "keywords": [],
5
5
  "author": {
6
6
  "name": "CodinGame",
@@ -18,6 +18,6 @@
18
18
  "module": "index.js",
19
19
  "types": "index.d.ts",
20
20
  "dependencies": {
21
- "vscode": "npm:@codingame/monaco-vscode-api@3.2.3"
21
+ "vscode": "npm:@codingame/monaco-vscode-api@4.1.0"
22
22
  }
23
23
  }
@@ -1,11 +0,0 @@
1
- function __decorate(decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- }
7
- function __param(paramIndex, decorator) {
8
- return function (target, key) { decorator(target, key, paramIndex); }
9
- }
10
-
11
- export { __decorate, __param };
@@ -1,8 +0,0 @@
1
- var ConfirmResult;
2
- ( (function(ConfirmResult) {
3
- ConfirmResult[ConfirmResult["SAVE"] = 0] = "SAVE";
4
- ConfirmResult[ConfirmResult["DONT_SAVE"] = 1] = "DONT_SAVE";
5
- ConfirmResult[ConfirmResult["CANCEL"] = 2] = "CANCEL";
6
- })(ConfirmResult || (ConfirmResult = {})));
7
-
8
- export { ConfirmResult };
@@ -1,432 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { Event } from 'vscode/vscode/vs/base/common/event';
3
- import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace';
4
- import { DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
5
- import { ExplorerModel, ExplorerItem } from 'vscode/vscode/vs/workbench/contrib/files/common/explorerModel';
6
- import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
7
- import { dirname, basename } from 'vscode/vscode/vs/base/common/resources';
8
- import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
9
- import { IClipboardService } from 'vscode/vscode/vs/platform/clipboard/common/clipboardService';
10
- import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
11
- import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity';
12
- import { IBulkEditService } from 'vscode/vscode/vs/editor/browser/services/bulkEditService';
13
- import { UndoRedoSource } from 'vscode/vscode/vs/platform/undoRedo/common/undoRedo';
14
- import { IProgressService } from 'vscode/vscode/vs/platform/progress/common/progress';
15
- import { CancellationTokenSource } from 'vscode/vscode/vs/base/common/cancellation';
16
- import { RunOnceScheduler } from 'vscode/vscode/vs/base/common/async';
17
- import { IHostService } from 'vscode/vscode/vs/workbench/services/host/browser/host';
18
- import { ResourceGlobMatcher } from 'vscode/vscode/vs/workbench/common/resources';
19
- import { IFilesConfigurationService } from 'vscode/vscode/vs/workbench/services/filesConfiguration/common/filesConfigurationService';
20
- import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
21
-
22
- var ExplorerService_1;
23
- const UNDO_REDO_SOURCE = ( new UndoRedoSource());
24
- let ExplorerService = class ExplorerService {
25
- static { ExplorerService_1 = this; }
26
- static { this.EXPLORER_FILE_CHANGES_REACT_DELAY = 500; }
27
- constructor(fileService, configurationService, contextService, clipboardService, editorService, uriIdentityService, bulkEditService, progressService, hostService, filesConfigurationService, telemetryService) {
28
- this.fileService = fileService;
29
- this.configurationService = configurationService;
30
- this.contextService = contextService;
31
- this.clipboardService = clipboardService;
32
- this.editorService = editorService;
33
- this.uriIdentityService = uriIdentityService;
34
- this.bulkEditService = bulkEditService;
35
- this.progressService = progressService;
36
- this.filesConfigurationService = filesConfigurationService;
37
- this.telemetryService = telemetryService;
38
- this.disposables = ( new DisposableStore());
39
- this.fileChangeEvents = [];
40
- this.config = this.configurationService.getValue('explorer');
41
- this.model = ( new ExplorerModel(
42
- this.contextService,
43
- this.uriIdentityService,
44
- this.fileService,
45
- this.configurationService,
46
- this.filesConfigurationService
47
- ));
48
- this.disposables.add(this.model);
49
- this.disposables.add(this.fileService.onDidRunOperation(e => this.onDidRunOperation(e)));
50
- this.onFileChangesScheduler = ( new RunOnceScheduler(async () => {
51
- const events = this.fileChangeEvents;
52
- this.fileChangeEvents = [];
53
- const types = [2 ];
54
- if (this.config.sortOrder === "modified" ) {
55
- types.push(0 );
56
- }
57
- let shouldRefresh = false;
58
- this.roots.forEach(r => {
59
- if (this.view && !shouldRefresh) {
60
- shouldRefresh = doesFileEventAffect(r, this.view, events, types);
61
- }
62
- });
63
- events.forEach(e => {
64
- if (!shouldRefresh) {
65
- for (const resource of e.rawAdded) {
66
- const parent = this.model.findClosest(dirname(resource));
67
- if (parent && !parent.getChild(basename(resource))) {
68
- shouldRefresh = true;
69
- break;
70
- }
71
- }
72
- }
73
- });
74
- if (shouldRefresh) {
75
- await this.refresh(false);
76
- }
77
- }, ExplorerService_1.EXPLORER_FILE_CHANGES_REACT_DELAY));
78
- this.disposables.add(this.fileService.onDidFilesChange(e => {
79
- this.fileChangeEvents.push(e);
80
- if (this.editable) {
81
- return;
82
- }
83
- if (!this.onFileChangesScheduler.isScheduled()) {
84
- this.onFileChangesScheduler.schedule();
85
- }
86
- }));
87
- this.disposables.add(this.configurationService.onDidChangeConfiguration(e => this.onConfigurationUpdated(e)));
88
- this.disposables.add(Event.any(this.fileService.onDidChangeFileSystemProviderRegistrations, this.fileService.onDidChangeFileSystemProviderCapabilities)(async (e) => {
89
- let affected = false;
90
- this.model.roots.forEach(r => {
91
- if (r.resource.scheme === e.scheme) {
92
- affected = true;
93
- r.forgetChildren();
94
- }
95
- });
96
- if (affected) {
97
- if (this.view) {
98
- await this.view.setTreeInput();
99
- }
100
- }
101
- }));
102
- this.disposables.add(this.model.onDidChangeRoots(() => {
103
- this.view?.setTreeInput();
104
- }));
105
- this.disposables.add(hostService.onDidChangeFocus(hasFocus => {
106
- if (hasFocus) {
107
- this.refresh(false);
108
- }
109
- }));
110
- this.revealExcludeMatcher = ( new ResourceGlobMatcher(
111
- (uri) => getRevealExcludes(configurationService.getValue({ resource: uri })),
112
- (event) => event.affectsConfiguration('explorer.autoRevealExclude'),
113
- contextService,
114
- configurationService
115
- ));
116
- this.disposables.add(this.revealExcludeMatcher);
117
- }
118
- get roots() {
119
- return this.model.roots;
120
- }
121
- get sortOrderConfiguration() {
122
- return {
123
- sortOrder: this.config.sortOrder,
124
- lexicographicOptions: this.config.sortOrderLexicographicOptions,
125
- };
126
- }
127
- registerView(contextProvider) {
128
- this.view = contextProvider;
129
- }
130
- getContext(respectMultiSelection, ignoreNestedChildren = false) {
131
- if (!this.view) {
132
- return [];
133
- }
134
- const items = ( new Set(this.view.getContext(respectMultiSelection)));
135
- items.forEach(item => {
136
- try {
137
- if (respectMultiSelection && !ignoreNestedChildren && this.view?.isItemCollapsed(item) && item.nestedChildren) {
138
- for (const child of item.nestedChildren) {
139
- items.add(child);
140
- }
141
- }
142
- }
143
- catch {
144
- return;
145
- }
146
- });
147
- return [...items];
148
- }
149
- async applyBulkEdit(edit, options) {
150
- const cancellationTokenSource = ( new CancellationTokenSource());
151
- const promise = this.progressService.withProgress({
152
- location: options.progressLocation || 10 ,
153
- title: options.progressLabel,
154
- cancellable: edit.length > 1,
155
- delay: 500,
156
- }, async (progress) => {
157
- await this.bulkEditService.apply(edit, {
158
- undoRedoSource: UNDO_REDO_SOURCE,
159
- label: options.undoLabel,
160
- code: 'undoredo.explorerOperation',
161
- progress,
162
- token: cancellationTokenSource.token,
163
- confirmBeforeUndo: options.confirmBeforeUndo
164
- });
165
- }, () => cancellationTokenSource.cancel());
166
- await this.progressService.withProgress({ location: 1 , delay: 500 }, () => promise);
167
- cancellationTokenSource.dispose();
168
- }
169
- hasViewFocus() {
170
- return !!this.view && this.view.hasFocus();
171
- }
172
- findClosest(resource) {
173
- return this.model.findClosest(resource);
174
- }
175
- findClosestRoot(resource) {
176
- const parentRoots = this.model.roots.filter(r => this.uriIdentityService.extUri.isEqualOrParent(resource, r.resource))
177
- .sort((first, second) => second.resource.path.length - first.resource.path.length);
178
- return parentRoots.length ? parentRoots[0] : null;
179
- }
180
- async setEditable(stat, data) {
181
- if (!this.view) {
182
- return;
183
- }
184
- if (!data) {
185
- this.editable = undefined;
186
- }
187
- else {
188
- this.editable = { stat, data };
189
- }
190
- const isEditing = this.isEditable(stat);
191
- try {
192
- await this.view.setEditable(stat, isEditing);
193
- }
194
- catch {
195
- const parent = stat.parent;
196
- const errorData = {
197
- parentIsDirectory: parent?.isDirectory,
198
- isDirectory: stat.isDirectory,
199
- isReadonly: !!stat.isReadonly,
200
- parentIsReadonly: !!parent?.isReadonly,
201
- parentIsExcluded: parent?.isExcluded,
202
- isExcluded: stat.isExcluded,
203
- parentIsRoot: parent?.isRoot,
204
- isRoot: stat.isRoot,
205
- parentHasNests: parent?.hasNests,
206
- hasNests: stat.hasNests,
207
- };
208
- this.telemetryService.publicLogError2('explorerView.setEditableError', errorData);
209
- return;
210
- }
211
- if (!this.editable && this.fileChangeEvents.length && !this.onFileChangesScheduler.isScheduled()) {
212
- this.onFileChangesScheduler.schedule();
213
- }
214
- }
215
- async setToCopy(items, cut) {
216
- const previouslyCutItems = this.cutItems;
217
- this.cutItems = cut ? items : undefined;
218
- await this.clipboardService.writeResources(( items.map(s => s.resource)));
219
- this.view?.itemsCopied(items, cut, previouslyCutItems);
220
- }
221
- isCut(item) {
222
- return !!this.cutItems && ( this.cutItems.some(i => this.uriIdentityService.extUri.isEqual(i.resource, item.resource)));
223
- }
224
- getEditable() {
225
- return this.editable;
226
- }
227
- getEditableData(stat) {
228
- return this.editable && this.editable.stat === stat ? this.editable.data : undefined;
229
- }
230
- isEditable(stat) {
231
- return !!this.editable && (this.editable.stat === stat || !stat);
232
- }
233
- async select(resource, reveal) {
234
- if (!this.view) {
235
- return;
236
- }
237
- const ignoreRevealExcludes = reveal === 'force';
238
- const fileStat = this.findClosest(resource);
239
- if (fileStat) {
240
- if (!this.shouldAutoRevealItem(fileStat, ignoreRevealExcludes)) {
241
- return;
242
- }
243
- await this.view.selectResource(fileStat.resource, reveal);
244
- return Promise.resolve(undefined);
245
- }
246
- const options = { resolveTo: [resource], resolveMetadata: this.config.sortOrder === "modified" };
247
- const root = this.findClosestRoot(resource);
248
- if (!root) {
249
- return undefined;
250
- }
251
- try {
252
- const stat = await this.fileService.resolve(root.resource, options);
253
- const modelStat = ExplorerItem.create(this.fileService, this.configurationService, this.filesConfigurationService, stat, undefined, options.resolveTo);
254
- ExplorerItem.mergeLocalWithDisk(modelStat, root);
255
- const item = root.find(resource);
256
- await this.view.refresh(true, root);
257
- if (item && !this.shouldAutoRevealItem(item, ignoreRevealExcludes)) {
258
- return;
259
- }
260
- await this.view.selectResource(item ? item.resource : undefined, reveal);
261
- }
262
- catch (error) {
263
- root.error = error;
264
- await this.view.refresh(false, root);
265
- }
266
- }
267
- async refresh(reveal = true) {
268
- this.model.roots.forEach(r => r.forgetChildren());
269
- if (this.view) {
270
- await this.view.refresh(true);
271
- const resource = this.editorService.activeEditor?.resource;
272
- const autoReveal = this.configurationService.getValue().explorer.autoReveal;
273
- if (reveal && resource && autoReveal) {
274
- this.select(resource, autoReveal);
275
- }
276
- }
277
- }
278
- async onDidRunOperation(e) {
279
- const shouldDeepRefresh = this.config.fileNesting.enabled;
280
- if (e.isOperation(0 ) || e.isOperation(3 )) {
281
- const addedElement = e.target;
282
- const parentResource = dirname(addedElement.resource);
283
- const parents = this.model.findAll(parentResource);
284
- if (parents.length) {
285
- await Promise.all(( parents.map(async (p) => {
286
- const resolveMetadata = this.config.sortOrder === `modified`;
287
- if (!p.isDirectoryResolved) {
288
- const stat = await this.fileService.resolve(p.resource, { resolveMetadata });
289
- if (stat) {
290
- const modelStat = ExplorerItem.create(this.fileService, this.configurationService, this.filesConfigurationService, stat, p.parent);
291
- ExplorerItem.mergeLocalWithDisk(modelStat, p);
292
- }
293
- }
294
- const childElement = ExplorerItem.create(this.fileService, this.configurationService, this.filesConfigurationService, addedElement, p.parent);
295
- p.removeChild(childElement);
296
- p.addChild(childElement);
297
- await this.view?.refresh(shouldDeepRefresh, p);
298
- })));
299
- }
300
- }
301
- else if (e.isOperation(2 )) {
302
- const oldResource = e.resource;
303
- const newElement = e.target;
304
- const oldParentResource = dirname(oldResource);
305
- const newParentResource = dirname(newElement.resource);
306
- const modelElements = this.model.findAll(oldResource);
307
- const sameParentMove = modelElements.every(e => !e.nestedParent) && this.uriIdentityService.extUri.isEqual(oldParentResource, newParentResource);
308
- if (sameParentMove) {
309
- await Promise.all(( modelElements.map(async (modelElement) => {
310
- modelElement.rename(newElement);
311
- await this.view?.refresh(shouldDeepRefresh, modelElement.parent);
312
- })));
313
- }
314
- else {
315
- const newParents = this.model.findAll(newParentResource);
316
- if (newParents.length && modelElements.length) {
317
- await Promise.all(( modelElements.map(async (modelElement, index) => {
318
- const oldParent = modelElement.parent;
319
- const oldNestedParent = modelElement.nestedParent;
320
- modelElement.move(newParents[index]);
321
- if (oldNestedParent) {
322
- await this.view?.refresh(false, oldNestedParent);
323
- }
324
- await this.view?.refresh(false, oldParent);
325
- await this.view?.refresh(shouldDeepRefresh, newParents[index]);
326
- })));
327
- }
328
- }
329
- }
330
- else if (e.isOperation(1 )) {
331
- const modelElements = this.model.findAll(e.resource);
332
- await Promise.all(( modelElements.map(async (modelElement) => {
333
- if (modelElement.parent) {
334
- const parent = modelElement.parent;
335
- parent.removeChild(modelElement);
336
- this.view?.focusNext();
337
- const oldNestedParent = modelElement.nestedParent;
338
- if (oldNestedParent) {
339
- oldNestedParent.removeChild(modelElement);
340
- await this.view?.refresh(false, oldNestedParent);
341
- }
342
- await this.view?.refresh(shouldDeepRefresh, parent);
343
- if (this.view?.getFocus().length === 0) {
344
- this.view?.focusLast();
345
- }
346
- }
347
- })));
348
- }
349
- }
350
- shouldAutoRevealItem(item, ignore) {
351
- if (item === undefined || ignore) {
352
- return true;
353
- }
354
- if (this.revealExcludeMatcher.matches(item.resource, name => !!(item.parent && item.parent.getChild(name)))) {
355
- return false;
356
- }
357
- const root = item.root;
358
- let currentItem = item.parent;
359
- while (currentItem !== root) {
360
- if (currentItem === undefined) {
361
- return true;
362
- }
363
- if (this.revealExcludeMatcher.matches(currentItem.resource)) {
364
- return false;
365
- }
366
- currentItem = currentItem.parent;
367
- }
368
- return true;
369
- }
370
- async onConfigurationUpdated(event) {
371
- if (!event.affectsConfiguration('explorer')) {
372
- return;
373
- }
374
- let shouldRefresh = false;
375
- if (event.affectsConfiguration('explorer.fileNesting')) {
376
- shouldRefresh = true;
377
- }
378
- const configuration = this.configurationService.getValue();
379
- const configSortOrder = configuration?.explorer?.sortOrder || "default" ;
380
- if (this.config.sortOrder !== configSortOrder) {
381
- shouldRefresh = this.config.sortOrder !== undefined;
382
- }
383
- const configLexicographicOptions = configuration?.explorer?.sortOrderLexicographicOptions || "default" ;
384
- if (this.config.sortOrderLexicographicOptions !== configLexicographicOptions) {
385
- shouldRefresh = shouldRefresh || this.config.sortOrderLexicographicOptions !== undefined;
386
- }
387
- this.config = configuration.explorer;
388
- if (shouldRefresh) {
389
- await this.refresh();
390
- }
391
- }
392
- dispose() {
393
- this.disposables.dispose();
394
- }
395
- };
396
- ExplorerService = ExplorerService_1 = ( __decorate([
397
- ( __param(0, IFileService)),
398
- ( __param(1, IConfigurationService)),
399
- ( __param(2, IWorkspaceContextService)),
400
- ( __param(3, IClipboardService)),
401
- ( __param(4, IEditorService)),
402
- ( __param(5, IUriIdentityService)),
403
- ( __param(6, IBulkEditService)),
404
- ( __param(7, IProgressService)),
405
- ( __param(8, IHostService)),
406
- ( __param(9, IFilesConfigurationService)),
407
- ( __param(10, ITelemetryService))
408
- ], ExplorerService));
409
- function doesFileEventAffect(item, view, events, types) {
410
- for (const [_name, child] of item.children) {
411
- if (view.isItemVisible(child)) {
412
- if (( events.some(e => e.contains(child.resource, ...types)))) {
413
- return true;
414
- }
415
- if (child.isDirectory && child.isDirectoryResolved) {
416
- if (doesFileEventAffect(child, view, events, types)) {
417
- return true;
418
- }
419
- }
420
- }
421
- }
422
- return false;
423
- }
424
- function getRevealExcludes(configuration) {
425
- const revealExcludes = configuration && configuration.explorer && configuration.explorer.autoRevealExclude;
426
- if (!revealExcludes) {
427
- return {};
428
- }
429
- return revealExcludes;
430
- }
431
-
432
- export { ExplorerService, UNDO_REDO_SOURCE };