@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
|
@@ -256,7 +256,7 @@ class ExtHostSCMInputBox {
|
|
|
256
256
|
this._sourceControlHandle = _sourceControlHandle;
|
|
257
257
|
this._documentUri = _documentUri;
|
|
258
258
|
this._value = '';
|
|
259
|
-
this._onDidChange = (
|
|
259
|
+
this._onDidChange = ( new Emitter());
|
|
260
260
|
this._placeholder = '';
|
|
261
261
|
this._enabled = true;
|
|
262
262
|
this._visible = true;
|
|
@@ -307,13 +307,13 @@ class ExtHostSourceControlResourceGroup {
|
|
|
307
307
|
this._label = _label;
|
|
308
308
|
this._resourceHandlePool = 0;
|
|
309
309
|
this._resourceStates = [];
|
|
310
|
-
this._resourceStatesMap = (
|
|
311
|
-
this._resourceStatesCommandsMap = (
|
|
312
|
-
this._resourceStatesDisposablesMap = (
|
|
313
|
-
this._onDidUpdateResourceStates = (
|
|
310
|
+
this._resourceStatesMap = ( new Map());
|
|
311
|
+
this._resourceStatesCommandsMap = ( new Map());
|
|
312
|
+
this._resourceStatesDisposablesMap = ( new Map());
|
|
313
|
+
this._onDidUpdateResourceStates = ( new Emitter());
|
|
314
314
|
this.onDidUpdateResourceStates = this._onDidUpdateResourceStates.event;
|
|
315
315
|
this._disposed = false;
|
|
316
|
-
this._onDidDispose = (
|
|
316
|
+
this._onDidDispose = ( new Emitter());
|
|
317
317
|
this.onDidDispose = this._onDidDispose.event;
|
|
318
318
|
this._handlesSnapshot = [];
|
|
319
319
|
this._resourceSnapshot = [];
|
|
@@ -333,15 +333,15 @@ class ExtHostSourceControlResourceGroup {
|
|
|
333
333
|
_takeResourceStateSnapshot() {
|
|
334
334
|
const snapshot = [...this._resourceStates].sort(compareResourceStates);
|
|
335
335
|
const diffs = sortedDiff(this._resourceSnapshot, snapshot, compareResourceStates);
|
|
336
|
-
const splices = (
|
|
337
|
-
const toInsert = (
|
|
336
|
+
const splices = ( diffs.map(diff => {
|
|
337
|
+
const toInsert = ( diff.toInsert.map(r => {
|
|
338
338
|
const handle = this._resourceHandlePool++;
|
|
339
339
|
this._resourceStatesMap.set(handle, r);
|
|
340
340
|
const sourceUri = r.resourceUri;
|
|
341
341
|
let command;
|
|
342
342
|
if (r.command) {
|
|
343
343
|
if (r.command.command === 'vscode.open' || r.command.command === 'vscode.diff') {
|
|
344
|
-
const disposables = (
|
|
344
|
+
const disposables = ( new DisposableStore());
|
|
345
345
|
command = this._commands.converter.toInternal(r.command, disposables);
|
|
346
346
|
this._resourceStatesDisposablesMap.set(handle, disposables);
|
|
347
347
|
}
|
|
@@ -359,16 +359,14 @@ class ExtHostSourceControlResourceGroup {
|
|
|
359
359
|
const contextValue = r.contextValue || '';
|
|
360
360
|
const rawResource = [handle, sourceUri, icons, tooltip, strikeThrough, faded, contextValue, command];
|
|
361
361
|
return { rawResource, handle };
|
|
362
|
-
}))
|
|
362
|
+
}));
|
|
363
363
|
return { start: diff.start, deleteCount: diff.deleteCount, toInsert };
|
|
364
|
-
}))
|
|
365
|
-
const rawResourceSplices = (
|
|
366
|
-
.map(
|
|
367
|
-
({ start, deleteCount, toInsert }) => [start, deleteCount, ( (toInsert.map(i => i.rawResource)))]
|
|
368
|
-
)));
|
|
364
|
+
}));
|
|
365
|
+
const rawResourceSplices = ( splices
|
|
366
|
+
.map(({ start, deleteCount, toInsert }) => [start, deleteCount, ( toInsert.map(i => i.rawResource))]));
|
|
369
367
|
const reverseSplices = splices.reverse();
|
|
370
368
|
for (const { start, deleteCount, toInsert } of reverseSplices) {
|
|
371
|
-
const handles = (
|
|
369
|
+
const handles = ( toInsert.map(i => i.handle));
|
|
372
370
|
const handlesToDelete = this._handlesSnapshot.splice(start, deleteCount, ...handles);
|
|
373
371
|
for (const handle of handlesToDelete) {
|
|
374
372
|
this._resourceStatesMap.delete(handle);
|
|
@@ -426,7 +424,7 @@ class ExtHostSourceControl {
|
|
|
426
424
|
set historyProvider(historyProvider) {
|
|
427
425
|
checkProposedApiEnabled(this._extension, 'scmHistoryProvider');
|
|
428
426
|
this._historyProvider = historyProvider;
|
|
429
|
-
this._historyProviderDisposable.value = (
|
|
427
|
+
this._historyProviderDisposable.value = ( new DisposableStore());
|
|
430
428
|
this.#proxy.$updateSourceControl(this.handle, { hasHistoryProvider: !!historyProvider });
|
|
431
429
|
if (historyProvider) {
|
|
432
430
|
this._historyProviderDisposable.value.add(historyProvider.onDidChangeCurrentHistoryItemGroup(() => {
|
|
@@ -438,7 +436,7 @@ class ExtHostSourceControl {
|
|
|
438
436
|
}));
|
|
439
437
|
this._historyProviderDisposable.value.add(historyProvider.onDidChangeActionButton(() => {
|
|
440
438
|
checkProposedApiEnabled(this._extension, 'scmActionButton');
|
|
441
|
-
this._historyProviderActionButtonDisposable.value = (
|
|
439
|
+
this._historyProviderActionButtonDisposable.value = ( new DisposableStore());
|
|
442
440
|
const internal = historyProvider.actionButton !== undefined ?
|
|
443
441
|
{
|
|
444
442
|
command: this._commands.converter.toInternal(historyProvider.actionButton.command, this._historyProviderActionButtonDisposable.value),
|
|
@@ -463,7 +461,7 @@ class ExtHostSourceControl {
|
|
|
463
461
|
return this._acceptInputCommand;
|
|
464
462
|
}
|
|
465
463
|
set acceptInputCommand(acceptInputCommand) {
|
|
466
|
-
this._acceptInputDisposables.value = (
|
|
464
|
+
this._acceptInputDisposables.value = ( new DisposableStore());
|
|
467
465
|
this._acceptInputCommand = acceptInputCommand;
|
|
468
466
|
const internal = this._commands.converter.toInternal(acceptInputCommand, this._acceptInputDisposables.value);
|
|
469
467
|
this.#proxy.$updateSourceControl(this.handle, { acceptInputCommand: internal });
|
|
@@ -474,17 +472,15 @@ class ExtHostSourceControl {
|
|
|
474
472
|
}
|
|
475
473
|
set actionButton(actionButton) {
|
|
476
474
|
checkProposedApiEnabled(this._extension, 'scmActionButton');
|
|
477
|
-
this._actionButtonDisposables.value = (
|
|
475
|
+
this._actionButtonDisposables.value = ( new DisposableStore());
|
|
478
476
|
this._actionButton = actionButton;
|
|
479
477
|
const internal = actionButton !== undefined ?
|
|
480
478
|
{
|
|
481
479
|
command: this._commands.converter.toInternal(actionButton.command, this._actionButtonDisposables.value),
|
|
482
480
|
secondaryCommands: actionButton.secondaryCommands?.map(commandGroup => {
|
|
483
|
-
return (
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
))
|
|
487
|
-
);
|
|
481
|
+
return ( commandGroup.map(
|
|
482
|
+
command => this._commands.converter.toInternal(command, this._actionButtonDisposables.value)
|
|
483
|
+
));
|
|
488
484
|
}),
|
|
489
485
|
description: actionButton.description,
|
|
490
486
|
enabled: actionButton.enabled
|
|
@@ -498,11 +494,11 @@ class ExtHostSourceControl {
|
|
|
498
494
|
if (this._statusBarCommands && statusBarCommands && commandListEquals(this._statusBarCommands, statusBarCommands)) {
|
|
499
495
|
return;
|
|
500
496
|
}
|
|
501
|
-
this._statusBarDisposables.value = (
|
|
497
|
+
this._statusBarDisposables.value = ( new DisposableStore());
|
|
502
498
|
this._statusBarCommands = statusBarCommands;
|
|
503
|
-
const internal = ( (
|
|
499
|
+
const internal = ( (statusBarCommands || []).map(
|
|
504
500
|
c => this._commands.converter.toInternal(c, this._statusBarDisposables.value)
|
|
505
|
-
))
|
|
501
|
+
));
|
|
506
502
|
this.#proxy.$updateSourceControl(this.handle, { statusBarCommands: internal });
|
|
507
503
|
}
|
|
508
504
|
get selected() {
|
|
@@ -514,40 +510,40 @@ class ExtHostSourceControl {
|
|
|
514
510
|
this._id = _id;
|
|
515
511
|
this._label = _label;
|
|
516
512
|
this._rootUri = _rootUri;
|
|
517
|
-
this._groups = (
|
|
513
|
+
this._groups = ( new Map());
|
|
518
514
|
this._count = undefined;
|
|
519
515
|
this._quickDiffProvider = undefined;
|
|
520
|
-
this._historyProviderDisposable = (
|
|
521
|
-
this._historyProviderActionButtonDisposable = (
|
|
516
|
+
this._historyProviderDisposable = ( new MutableDisposable());
|
|
517
|
+
this._historyProviderActionButtonDisposable = ( new MutableDisposable());
|
|
522
518
|
this._commitTemplate = undefined;
|
|
523
|
-
this._acceptInputDisposables = (
|
|
519
|
+
this._acceptInputDisposables = ( new MutableDisposable());
|
|
524
520
|
this._acceptInputCommand = undefined;
|
|
525
|
-
this._actionButtonDisposables = (
|
|
526
|
-
this._statusBarDisposables = (
|
|
521
|
+
this._actionButtonDisposables = ( new MutableDisposable());
|
|
522
|
+
this._statusBarDisposables = ( new MutableDisposable());
|
|
527
523
|
this._statusBarCommands = undefined;
|
|
528
524
|
this._selected = false;
|
|
529
|
-
this._onDidChangeSelection = (
|
|
525
|
+
this._onDidChangeSelection = ( new Emitter());
|
|
530
526
|
this.onDidChangeSelection = this._onDidChangeSelection.event;
|
|
531
527
|
this.handle = ExtHostSourceControl._handlePool++;
|
|
532
|
-
this.createdResourceGroups = (
|
|
533
|
-
this.updatedResourceGroups = (
|
|
528
|
+
this.createdResourceGroups = ( new Map());
|
|
529
|
+
this.updatedResourceGroups = ( new Set());
|
|
534
530
|
this.#proxy = proxy;
|
|
535
|
-
const inputBoxDocumentUri = (
|
|
531
|
+
const inputBoxDocumentUri = ( URI.from({
|
|
536
532
|
scheme: Schemas.vscodeSourceControl,
|
|
537
533
|
path: `${_id}/scm${this.handle}/input`,
|
|
538
|
-
query: _rootUri ? `rootUri=${encodeURIComponent((
|
|
539
|
-
}))
|
|
540
|
-
this._inputBox = (
|
|
534
|
+
query: _rootUri ? `rootUri=${encodeURIComponent(( _rootUri.toString()))}` : undefined
|
|
535
|
+
}));
|
|
536
|
+
this._inputBox = ( new ExtHostSCMInputBox(
|
|
541
537
|
_extension,
|
|
542
538
|
_extHostDocuments,
|
|
543
539
|
this.#proxy,
|
|
544
540
|
this.handle,
|
|
545
541
|
inputBoxDocumentUri
|
|
546
|
-
))
|
|
542
|
+
));
|
|
547
543
|
this.#proxy.$registerSourceControl(this.handle, _id, _label, _rootUri, inputBoxDocumentUri);
|
|
548
544
|
}
|
|
549
545
|
createResourceGroup(id, label) {
|
|
550
|
-
const group = (
|
|
546
|
+
const group = ( new ExtHostSourceControlResourceGroup(this.#proxy, this._commands, this.handle, id, label));
|
|
551
547
|
const disposable = Event.once(group.onDidDispose)(() => this.createdResourceGroups.delete(group));
|
|
552
548
|
this.createdResourceGroups.set(group, disposable);
|
|
553
549
|
this.eventuallyAddResourceGroups();
|
|
@@ -607,12 +603,12 @@ class ExtHostSourceControl {
|
|
|
607
603
|
this.#proxy.$unregisterSourceControl(this.handle);
|
|
608
604
|
}
|
|
609
605
|
}
|
|
610
|
-
ExtHostSourceControl.__decorator = (
|
|
606
|
+
ExtHostSourceControl.__decorator = ( __decorate([
|
|
611
607
|
debounce(100)
|
|
612
|
-
], ExtHostSourceControl.prototype, "eventuallyAddResourceGroups", null))
|
|
613
|
-
ExtHostSourceControl.__decorator = (
|
|
608
|
+
], ExtHostSourceControl.prototype, "eventuallyAddResourceGroups", null));
|
|
609
|
+
ExtHostSourceControl.__decorator = ( __decorate([
|
|
614
610
|
debounce(100)
|
|
615
|
-
], ExtHostSourceControl.prototype, "eventuallyUpdateResourceStates", null))
|
|
611
|
+
], ExtHostSourceControl.prototype, "eventuallyUpdateResourceStates", null));
|
|
616
612
|
let ExtHostSCM = class ExtHostSCM {
|
|
617
613
|
static { ExtHostSCM_1 = this; }
|
|
618
614
|
static { this._handlePool = 0; }
|
|
@@ -621,11 +617,11 @@ let ExtHostSCM = class ExtHostSCM {
|
|
|
621
617
|
this._commands = _commands;
|
|
622
618
|
this._extHostDocuments = _extHostDocuments;
|
|
623
619
|
this.logService = logService;
|
|
624
|
-
this._sourceControls = (
|
|
625
|
-
this._sourceControlsByExtension = (
|
|
626
|
-
this._onDidChangeActiveProvider = (
|
|
627
|
-
this._proxy = (
|
|
628
|
-
this._telemetry = (
|
|
620
|
+
this._sourceControls = ( new Map());
|
|
621
|
+
this._sourceControlsByExtension = ( new ExtensionIdentifierMap());
|
|
622
|
+
this._onDidChangeActiveProvider = ( new Emitter());
|
|
623
|
+
this._proxy = ( mainContext.getProxy(MainContext.MainThreadSCM));
|
|
624
|
+
this._telemetry = ( mainContext.getProxy(MainContext.MainThreadTelemetry));
|
|
629
625
|
_commands.registerArgumentProcessor({
|
|
630
626
|
processArgument: arg => {
|
|
631
627
|
if (arg && arg.$mid === 3 ) {
|
|
@@ -663,7 +659,7 @@ let ExtHostSCM = class ExtHostSCM {
|
|
|
663
659
|
extensionId: extension.identifier.value,
|
|
664
660
|
});
|
|
665
661
|
const handle = ExtHostSCM_1._handlePool++;
|
|
666
|
-
const sourceControl = (
|
|
662
|
+
const sourceControl = ( new ExtHostSourceControl(
|
|
667
663
|
extension,
|
|
668
664
|
this._extHostDocuments,
|
|
669
665
|
this._proxy,
|
|
@@ -671,7 +667,7 @@ let ExtHostSCM = class ExtHostSCM {
|
|
|
671
667
|
id,
|
|
672
668
|
label,
|
|
673
669
|
rootUri
|
|
674
|
-
))
|
|
670
|
+
));
|
|
675
671
|
this._sourceControls.set(handle, sourceControl);
|
|
676
672
|
const sourceControls = this._sourceControlsByExtension.get(extension.identifier) || [];
|
|
677
673
|
sourceControls.push(sourceControl);
|
|
@@ -686,7 +682,7 @@ let ExtHostSCM = class ExtHostSCM {
|
|
|
686
682
|
}
|
|
687
683
|
$provideOriginalResource(sourceControlHandle, uriComponents, token) {
|
|
688
684
|
const uri = URI.revive(uriComponents);
|
|
689
|
-
this.logService.trace('ExtHostSCM#$provideOriginalResource', sourceControlHandle, (
|
|
685
|
+
this.logService.trace('ExtHostSCM#$provideOriginalResource', sourceControlHandle, ( uri.toString()));
|
|
690
686
|
const sourceControl = this._sourceControls.get(sourceControlHandle);
|
|
691
687
|
if (!sourceControl || !sourceControl.quickDiffProvider || !sourceControl.quickDiffProvider.provideOriginalResource) {
|
|
692
688
|
return Promise.resolve(null);
|
|
@@ -771,7 +767,7 @@ let ExtHostSCM = class ExtHostSCM {
|
|
|
771
767
|
return (await historyProvider?.provideHistoryItemChanges(historyItemId, token)) ?? undefined;
|
|
772
768
|
}
|
|
773
769
|
};
|
|
774
|
-
ExtHostSCM = ExtHostSCM_1 = (
|
|
775
|
-
(
|
|
776
|
-
], ExtHostSCM))
|
|
770
|
+
ExtHostSCM = ExtHostSCM_1 = ( __decorate([
|
|
771
|
+
( __param(3, ILogService))
|
|
772
|
+
], ExtHostSCM));
|
|
777
773
|
export { ExtHostSCM, ExtHostSCMInputBox };
|
|
@@ -35,8 +35,8 @@ class ExtHostTreeViews extends Disposable {
|
|
|
35
35
|
this._proxy = _proxy;
|
|
36
36
|
this.commands = commands;
|
|
37
37
|
this.logService = logService;
|
|
38
|
-
this.treeViews = (
|
|
39
|
-
this.treeDragAndDropService = (
|
|
38
|
+
this.treeViews = ( new Map());
|
|
39
|
+
this.treeDragAndDropService = ( new TreeViewsDnDService());
|
|
40
40
|
function isTreeViewConvertableItem(arg) {
|
|
41
41
|
return arg && arg.$treeViewId && (arg.$treeItemHandle || arg.$selectedTreeItems || arg.$focusedTreeItem);
|
|
42
42
|
}
|
|
@@ -46,14 +46,12 @@ class ExtHostTreeViews extends Disposable {
|
|
|
46
46
|
return this.convertArgument(arg);
|
|
47
47
|
}
|
|
48
48
|
else if (Array.isArray(arg) && (arg.length > 0)) {
|
|
49
|
-
return (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}))
|
|
56
|
-
);
|
|
49
|
+
return ( arg.map(item => {
|
|
50
|
+
if (isTreeViewConvertableItem(item)) {
|
|
51
|
+
return this.convertArgument(item);
|
|
52
|
+
}
|
|
53
|
+
return item;
|
|
54
|
+
}));
|
|
57
55
|
}
|
|
58
56
|
return arg;
|
|
59
57
|
}
|
|
@@ -138,14 +136,14 @@ class ExtHostTreeViews extends Disposable {
|
|
|
138
136
|
$getChildren(treeViewId, treeItemHandle) {
|
|
139
137
|
const treeView = this.treeViews.get(treeViewId);
|
|
140
138
|
if (!treeView) {
|
|
141
|
-
return Promise.reject((
|
|
139
|
+
return Promise.reject(( new NoTreeViewError(treeViewId)));
|
|
142
140
|
}
|
|
143
141
|
return treeView.getChildren(treeItemHandle);
|
|
144
142
|
}
|
|
145
143
|
async $handleDrop(destinationViewId, requestId, treeDataTransferDTO, targetItemHandle, token, operationUuid, sourceViewId, sourceTreeItemHandles) {
|
|
146
144
|
const treeView = this.treeViews.get(destinationViewId);
|
|
147
145
|
if (!treeView) {
|
|
148
|
-
return Promise.reject((
|
|
146
|
+
return Promise.reject(( new NoTreeViewError(destinationViewId)));
|
|
149
147
|
}
|
|
150
148
|
const treeDataTransfer = DataTransfer.toDataTransfer(treeDataTransferDTO, async (dataItemIndex) => {
|
|
151
149
|
return (await this._proxy.$resolveDropFileData(destinationViewId, requestId, dataItemIndex)).buffer;
|
|
@@ -174,7 +172,7 @@ class ExtHostTreeViews extends Disposable {
|
|
|
174
172
|
async $handleDrag(sourceViewId, sourceTreeItemHandles, operationUuid, token) {
|
|
175
173
|
const treeView = this.treeViews.get(sourceViewId);
|
|
176
174
|
if (!treeView) {
|
|
177
|
-
return Promise.reject((
|
|
175
|
+
return Promise.reject(( new NoTreeViewError(sourceViewId)));
|
|
178
176
|
}
|
|
179
177
|
const treeDataTransfer = await this.addAdditionalTransferItems(new DataTransfer$1(), treeView, sourceTreeItemHandles, token, operationUuid);
|
|
180
178
|
if (!treeDataTransfer || token.isCancellationRequested) {
|
|
@@ -228,14 +226,14 @@ class ExtHostTreeViews extends Disposable {
|
|
|
228
226
|
treeView.setCheckboxState(checkboxUpdate);
|
|
229
227
|
}
|
|
230
228
|
createExtHostTreeView(id, options, extension) {
|
|
231
|
-
const treeView = this._register((
|
|
229
|
+
const treeView = this._register(( new ExtHostTreeView(
|
|
232
230
|
id,
|
|
233
231
|
options,
|
|
234
232
|
this._proxy,
|
|
235
233
|
this.commands.converter,
|
|
236
234
|
this.logService,
|
|
237
235
|
extension
|
|
238
|
-
)))
|
|
236
|
+
)));
|
|
239
237
|
this.treeViews.set(id, treeView);
|
|
240
238
|
return treeView;
|
|
241
239
|
}
|
|
@@ -254,7 +252,7 @@ class ExtHostTreeView extends Disposable {
|
|
|
254
252
|
static { this.LABEL_HANDLE_PREFIX = '0'; }
|
|
255
253
|
static { this.ID_HANDLE_PREFIX = '1'; }
|
|
256
254
|
get visible() { return this._visible; }
|
|
257
|
-
get selectedElements() { return (
|
|
255
|
+
get selectedElements() { return ( this._selectedHandles.map(handle => this.getExtensionElement(handle))).filter(element => !isUndefinedOrNull(element)); }
|
|
258
256
|
get focusedElement() { return (this._focusedHandle ? this.getExtensionElement(this._focusedHandle) : undefined); }
|
|
259
257
|
constructor(viewId, options, proxy, commands, logService, extension) {
|
|
260
258
|
super();
|
|
@@ -264,29 +262,29 @@ class ExtHostTreeView extends Disposable {
|
|
|
264
262
|
this.logService = logService;
|
|
265
263
|
this.extension = extension;
|
|
266
264
|
this.roots = undefined;
|
|
267
|
-
this.elements = (
|
|
268
|
-
this.nodes = (
|
|
265
|
+
this.elements = ( new Map());
|
|
266
|
+
this.nodes = ( new Map());
|
|
269
267
|
this._visible = false;
|
|
270
268
|
this._selectedHandles = [];
|
|
271
269
|
this._focusedHandle = undefined;
|
|
272
|
-
this._onDidExpandElement = this._register((
|
|
270
|
+
this._onDidExpandElement = this._register(( new Emitter()));
|
|
273
271
|
this.onDidExpandElement = this._onDidExpandElement.event;
|
|
274
|
-
this._onDidCollapseElement = this._register((
|
|
272
|
+
this._onDidCollapseElement = this._register(( new Emitter()));
|
|
275
273
|
this.onDidCollapseElement = this._onDidCollapseElement.event;
|
|
276
|
-
this._onDidChangeSelection = this._register((
|
|
274
|
+
this._onDidChangeSelection = this._register(( new Emitter()));
|
|
277
275
|
this.onDidChangeSelection = this._onDidChangeSelection.event;
|
|
278
|
-
this._onDidChangeActiveItem = this._register((
|
|
276
|
+
this._onDidChangeActiveItem = this._register(( new Emitter()));
|
|
279
277
|
this.onDidChangeActiveItem = this._onDidChangeActiveItem.event;
|
|
280
|
-
this._onDidChangeVisibility = this._register((
|
|
278
|
+
this._onDidChangeVisibility = this._register(( new Emitter()));
|
|
281
279
|
this.onDidChangeVisibility = this._onDidChangeVisibility.event;
|
|
282
|
-
this._onDidChangeCheckboxState = this._register((
|
|
280
|
+
this._onDidChangeCheckboxState = this._register(( new Emitter()));
|
|
283
281
|
this.onDidChangeCheckboxState = this._onDidChangeCheckboxState.event;
|
|
284
|
-
this._onDidChangeData = this._register((
|
|
282
|
+
this._onDidChangeData = this._register(( new Emitter()));
|
|
285
283
|
this.refreshPromise = Promise.resolve();
|
|
286
284
|
this.refreshQueue = Promise.resolve();
|
|
287
285
|
this._message = '';
|
|
288
286
|
this._title = '';
|
|
289
|
-
this._refreshCancellationSource = (
|
|
287
|
+
this._refreshCancellationSource = ( new CancellationTokenSource());
|
|
290
288
|
if (extension.contributes && extension.contributes.views) {
|
|
291
289
|
for (const location in extension.contributes.views) {
|
|
292
290
|
for (const view of extension.contributes.views[location]) {
|
|
@@ -309,7 +307,7 @@ class ExtHostTreeView extends Disposable {
|
|
|
309
307
|
}
|
|
310
308
|
if (current.element !== false) {
|
|
311
309
|
if (!refreshingPromise) {
|
|
312
|
-
refreshingPromise = (
|
|
310
|
+
refreshingPromise = ( new Promise(c => promiseCallback = c));
|
|
313
311
|
this.refreshPromise = this.refreshPromise.then(() => refreshingPromise);
|
|
314
312
|
}
|
|
315
313
|
if (Array.isArray(current.element)) {
|
|
@@ -347,7 +345,7 @@ class ExtHostTreeView extends Disposable {
|
|
|
347
345
|
if (!childrenNodes) {
|
|
348
346
|
childrenNodes = await this.fetchChildrenNodes(parentElement);
|
|
349
347
|
}
|
|
350
|
-
return childrenNodes ? (
|
|
348
|
+
return childrenNodes ? ( childrenNodes.map(n => n.item)) : undefined;
|
|
351
349
|
}
|
|
352
350
|
getExtensionElement(treeItemHandle) {
|
|
353
351
|
return this.elements.get(treeItemHandle);
|
|
@@ -358,15 +356,15 @@ class ExtHostTreeView extends Disposable {
|
|
|
358
356
|
const focus = isUndefinedOrNull(options.focus) ? false : options.focus;
|
|
359
357
|
const expand = isUndefinedOrNull(options.expand) ? false : options.expand;
|
|
360
358
|
if (typeof this.dataProvider.getParent !== 'function') {
|
|
361
|
-
return Promise.reject((
|
|
359
|
+
return Promise.reject(( new Error(
|
|
362
360
|
`Required registered TreeDataProvider to implement 'getParent' method to access 'reveal' method`
|
|
363
|
-
)))
|
|
361
|
+
)));
|
|
364
362
|
}
|
|
365
363
|
if (element) {
|
|
366
364
|
return this.refreshPromise
|
|
367
365
|
.then(() => this.resolveUnknownParentChain(element))
|
|
368
366
|
.then(parentChain => this.resolveTreeNode(element, parentChain[parentChain.length - 1])
|
|
369
|
-
.then(treeNode => this.proxy.$reveal(this.viewId, { item: treeNode.item, parentChain: (
|
|
367
|
+
.then(treeNode => this.proxy.$reveal(this.viewId, { item: treeNode.item, parentChain: ( parentChain.map(p => p.item)) }, { select, focus, expand })), error => this.logService.error(error));
|
|
370
368
|
}
|
|
371
369
|
else {
|
|
372
370
|
return this.proxy.$reveal(this.viewId, undefined, { select, focus, expand });
|
|
@@ -408,10 +406,10 @@ class ExtHostTreeView extends Disposable {
|
|
|
408
406
|
const element = this.getExtensionElement(treeItemHandle);
|
|
409
407
|
if (element) {
|
|
410
408
|
if (expanded) {
|
|
411
|
-
this._onDidExpandElement.fire((
|
|
409
|
+
this._onDidExpandElement.fire(( Object.freeze({ element })));
|
|
412
410
|
}
|
|
413
411
|
else {
|
|
414
|
-
this._onDidCollapseElement.fire((
|
|
412
|
+
this._onDidCollapseElement.fire(( Object.freeze({ element })));
|
|
415
413
|
}
|
|
416
414
|
}
|
|
417
415
|
}
|
|
@@ -421,20 +419,20 @@ class ExtHostTreeView extends Disposable {
|
|
|
421
419
|
const changedFocus = this._focusedHandle !== focusedHandle;
|
|
422
420
|
this._focusedHandle = focusedHandle;
|
|
423
421
|
if (changedSelection) {
|
|
424
|
-
this._onDidChangeSelection.fire((
|
|
422
|
+
this._onDidChangeSelection.fire(( Object.freeze({ selection: this.selectedElements })));
|
|
425
423
|
}
|
|
426
424
|
if (changedFocus) {
|
|
427
|
-
this._onDidChangeActiveItem.fire((
|
|
425
|
+
this._onDidChangeActiveItem.fire(( Object.freeze({ activeItem: this.focusedElement })));
|
|
428
426
|
}
|
|
429
427
|
}
|
|
430
428
|
setVisible(visible) {
|
|
431
429
|
if (visible !== this._visible) {
|
|
432
430
|
this._visible = visible;
|
|
433
|
-
this._onDidChangeVisibility.fire((
|
|
431
|
+
this._onDidChangeVisibility.fire(( Object.freeze({ visible: this._visible })));
|
|
434
432
|
}
|
|
435
433
|
}
|
|
436
434
|
async setCheckboxState(checkboxUpdates) {
|
|
437
|
-
const items = (await Promise.all((
|
|
435
|
+
const items = (await Promise.all(( checkboxUpdates.map(async (checkboxUpdate) => {
|
|
438
436
|
const extensionItem = this.getExtensionElement(checkboxUpdate.treeItemHandle);
|
|
439
437
|
if (extensionItem) {
|
|
440
438
|
return {
|
|
@@ -444,11 +442,11 @@ class ExtHostTreeView extends Disposable {
|
|
|
444
442
|
};
|
|
445
443
|
}
|
|
446
444
|
return Promise.resolve(undefined);
|
|
447
|
-
}))))
|
|
445
|
+
})))).filter((item) => item !== undefined);
|
|
448
446
|
items.forEach(item => {
|
|
449
447
|
item.treeItem.checkboxState = item.newState ? TreeItemCheckboxState.Checked : TreeItemCheckboxState.Unchecked;
|
|
450
448
|
});
|
|
451
|
-
this._onDidChangeCheckboxState.fire({ items: (
|
|
449
|
+
this._onDidChangeCheckboxState.fire({ items: ( items.map(item => [item.extensionItem, item.newState])) });
|
|
452
450
|
}
|
|
453
451
|
async handleDrag(sourceTreeItemHandles, treeDataTransfer, token) {
|
|
454
452
|
const extensionTreeItems = [];
|
|
@@ -552,17 +550,17 @@ class ExtHostTreeView extends Disposable {
|
|
|
552
550
|
}
|
|
553
551
|
async fetchChildrenNodes(parentElement) {
|
|
554
552
|
this.clearChildren(parentElement);
|
|
555
|
-
const cts = (
|
|
553
|
+
const cts = ( new CancellationTokenSource(this._refreshCancellationSource.token));
|
|
556
554
|
try {
|
|
557
555
|
const parentNode = parentElement ? this.nodes.get(parentElement) : undefined;
|
|
558
556
|
const elements = await this.dataProvider.getChildren(parentElement);
|
|
559
557
|
if (cts.token.isCancellationRequested) {
|
|
560
558
|
return undefined;
|
|
561
559
|
}
|
|
562
|
-
const items = await Promise.all((
|
|
560
|
+
const items = await Promise.all(( coalesce(elements || []).map(async (element) => {
|
|
563
561
|
const item = await this.dataProvider.getTreeItem(element);
|
|
564
562
|
return item && !cts.token.isCancellationRequested ? this.createAndRegisterTreeNode(element, item, parentNode) : null;
|
|
565
|
-
})))
|
|
563
|
+
})));
|
|
566
564
|
if (cts.token.isCancellationRequested) {
|
|
567
565
|
return undefined;
|
|
568
566
|
}
|
|
@@ -573,10 +571,10 @@ class ExtHostTreeView extends Disposable {
|
|
|
573
571
|
}
|
|
574
572
|
}
|
|
575
573
|
refresh(elements) {
|
|
576
|
-
const hasRoot = (
|
|
574
|
+
const hasRoot = ( elements.some(element => !element));
|
|
577
575
|
if (hasRoot) {
|
|
578
576
|
this._refreshCancellationSource.dispose(true);
|
|
579
|
-
this._refreshCancellationSource = (
|
|
577
|
+
this._refreshCancellationSource = ( new CancellationTokenSource());
|
|
580
578
|
this.clearAll();
|
|
581
579
|
return this.proxy.$refresh(this.viewId);
|
|
582
580
|
}
|
|
@@ -589,10 +587,10 @@ class ExtHostTreeView extends Disposable {
|
|
|
589
587
|
return Promise.resolve(undefined);
|
|
590
588
|
}
|
|
591
589
|
getHandlesToRefresh(elements) {
|
|
592
|
-
const elementsToUpdate = (
|
|
593
|
-
const elementNodes = (
|
|
590
|
+
const elementsToUpdate = ( new Set());
|
|
591
|
+
const elementNodes = ( elements.map(element => this.nodes.get(element)));
|
|
594
592
|
for (const elementNode of elementNodes) {
|
|
595
|
-
if (elementNode && !(
|
|
593
|
+
if (elementNode && !( elementsToUpdate.has(elementNode.item.handle))) {
|
|
596
594
|
let currentNode = elementNode;
|
|
597
595
|
while (currentNode && currentNode.parent && elementNodes.findIndex(node => currentNode && currentNode.parent && node && node.item.handle === currentNode.parent.item.handle) === -1) {
|
|
598
596
|
const parentElement = this.elements.get(currentNode.parent.item.handle);
|
|
@@ -608,7 +606,7 @@ class ExtHostTreeView extends Disposable {
|
|
|
608
606
|
const element = this.elements.get(handle);
|
|
609
607
|
if (element) {
|
|
610
608
|
const node = this.nodes.get(element);
|
|
611
|
-
if (node && (!node.parent || !(
|
|
609
|
+
if (node && (!node.parent || !( elementsToUpdate.has(node.parent.item.handle)))) {
|
|
612
610
|
handlesToUpdate.push(handle);
|
|
613
611
|
}
|
|
614
612
|
}
|
|
@@ -617,13 +615,13 @@ class ExtHostTreeView extends Disposable {
|
|
|
617
615
|
}
|
|
618
616
|
refreshHandles(itemHandles) {
|
|
619
617
|
const itemsToRefresh = {};
|
|
620
|
-
return Promise.all((
|
|
618
|
+
return Promise.all(( itemHandles.map(treeItemHandle => this.refreshNode(treeItemHandle)
|
|
621
619
|
.then(node => {
|
|
622
620
|
if (node) {
|
|
623
621
|
itemsToRefresh[treeItemHandle] = node.item;
|
|
624
622
|
}
|
|
625
|
-
}))))
|
|
626
|
-
.then(() => (
|
|
623
|
+
}))))
|
|
624
|
+
.then(() => ( Object.keys(itemsToRefresh)).length ? this.proxy.$refresh(this.viewId, itemsToRefresh) : undefined);
|
|
627
625
|
}
|
|
628
626
|
refreshNode(treeItemHandle) {
|
|
629
627
|
const extElement = this.getExtensionElement(treeItemHandle);
|
|
@@ -647,7 +645,7 @@ class ExtHostTreeView extends Disposable {
|
|
|
647
645
|
}
|
|
648
646
|
createAndRegisterTreeNode(element, extTreeItem, parentNode) {
|
|
649
647
|
const node = this.createTreeNode(element, extTreeItem, parentNode);
|
|
650
|
-
if (extTreeItem.id && (
|
|
648
|
+
if (extTreeItem.id && ( this.elements.has(node.item.handle))) {
|
|
651
649
|
throw new Error(localize('treeView.duplicateElement', 'Element with id {0} is already registered', extTreeItem.id));
|
|
652
650
|
}
|
|
653
651
|
this.addNodeToCache(element, node);
|
|
@@ -687,7 +685,7 @@ class ExtHostTreeView extends Disposable {
|
|
|
687
685
|
}
|
|
688
686
|
createTreeNode(element, extensionTreeItem, parent) {
|
|
689
687
|
this.validateTreeItem(extensionTreeItem);
|
|
690
|
-
const disposableStore = this._register((
|
|
688
|
+
const disposableStore = this._register(( new DisposableStore()));
|
|
691
689
|
const handle = this.createHandle(element, extensionTreeItem, parent);
|
|
692
690
|
const icon = this.getLightIconPath(extensionTreeItem);
|
|
693
691
|
const item = {
|
|
@@ -726,13 +724,13 @@ class ExtHostTreeView extends Disposable {
|
|
|
726
724
|
const prefix = parent ? parent.item.handle : ExtHostTreeView.LABEL_HANDLE_PREFIX;
|
|
727
725
|
let elementId = treeItemLabel ? treeItemLabel.label : resourceUri ? basename(resourceUri) : '';
|
|
728
726
|
elementId = elementId.indexOf('/') !== -1 ? elementId.replace('/', '//') : elementId;
|
|
729
|
-
const existingHandle = (
|
|
727
|
+
const existingHandle = ( this.nodes.has(element)) ? this.nodes.get(element).item.handle : undefined;
|
|
730
728
|
const childrenNodes = (this.getChildrenNodes(parent) || []);
|
|
731
729
|
let handle;
|
|
732
730
|
let counter = 0;
|
|
733
731
|
do {
|
|
734
732
|
handle = `${prefix}/${counter}:${elementId}`;
|
|
735
|
-
if (returnFirst || !(
|
|
733
|
+
if (returnFirst || !( this.elements.has(handle)) || existingHandle === handle) {
|
|
736
734
|
break;
|
|
737
735
|
}
|
|
738
736
|
counter++;
|