-
Notifications
You must be signed in to change notification settings - Fork 29.7k
/
extensions.contribution.ts
1842 lines (1738 loc) · 84.1 KB
/
extensions.contribution.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { localize, localize2 } from '../../../../nls.js';
import { KeyMod, KeyCode } from '../../../../base/common/keyCodes.js';
import { Registry } from '../../../../platform/registry/common/platform.js';
import { MenuRegistry, MenuId, registerAction2, Action2, IMenuItem, IAction2Options } from '../../../../platform/actions/common/actions.js';
import { InstantiationType, registerSingleton } from '../../../../platform/instantiation/common/extensions.js';
import { ExtensionsLocalizedLabel, IExtensionManagementService, IExtensionGalleryService, PreferencesLocalizedLabel, EXTENSION_INSTALL_SOURCE_CONTEXT, ExtensionInstallSource } from '../../../../platform/extensionManagement/common/extensionManagement.js';
import { EnablementState, IExtensionManagementServerService, IWorkbenchExtensionEnablementService, IWorkbenchExtensionManagementService, extensionsConfigurationNodeBase } from '../../../services/extensionManagement/common/extensionManagement.js';
import { IExtensionIgnoredRecommendationsService, IExtensionRecommendationsService } from '../../../services/extensionRecommendations/common/extensionRecommendations.js';
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions, IWorkbenchContribution } from '../../../common/contributions.js';
import { SyncDescriptor } from '../../../../platform/instantiation/common/descriptors.js';
import { VIEWLET_ID, IExtensionsWorkbenchService, IExtensionsViewPaneContainer, TOGGLE_IGNORE_EXTENSION_ACTION_ID, INSTALL_EXTENSION_FROM_VSIX_COMMAND_ID, WORKSPACE_RECOMMENDATIONS_VIEW_ID, IWorkspaceRecommendedExtensionsView, AutoUpdateConfigurationKey, HasOutdatedExtensionsContext, SELECT_INSTALL_VSIX_EXTENSION_COMMAND_ID, LIST_WORKSPACE_UNSUPPORTED_EXTENSIONS_COMMAND_ID, ExtensionEditorTab, THEME_ACTIONS_GROUP, INSTALL_ACTIONS_GROUP, OUTDATED_EXTENSIONS_VIEW_ID, CONTEXT_HAS_GALLERY, extensionsSearchActionsMenu, UPDATE_ACTIONS_GROUP, IExtensionArg, ExtensionRuntimeActionType } from '../common/extensions.js';
import { ReinstallAction, InstallSpecificVersionOfExtensionAction, ConfigureWorkspaceRecommendedExtensionsAction, ConfigureWorkspaceFolderRecommendedExtensionsAction, SetColorThemeAction, SetFileIconThemeAction, SetProductIconThemeAction, ClearLanguageAction, ToggleAutoUpdateForExtensionAction, ToggleAutoUpdatesForPublisherAction, TogglePreReleaseExtensionAction, InstallAnotherVersionAction, InstallAction } from './extensionsActions.js';
import { ExtensionsInput } from '../common/extensionsInput.js';
import { ExtensionEditor } from './extensionEditor.js';
import { StatusUpdater, MaliciousExtensionChecker, ExtensionsViewletViewsContribution, ExtensionsViewPaneContainer, BuiltInExtensionsContext, SearchMarketplaceExtensionsContext, RecommendedExtensionsContext, DefaultViewsContext, ExtensionsSortByContext, SearchHasTextContext } from './extensionsViewlet.js';
import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope } from '../../../../platform/configuration/common/configurationRegistry.js';
import * as jsonContributionRegistry from '../../../../platform/jsonschemas/common/jsonContributionRegistry.js';
import { ExtensionsConfigurationSchema, ExtensionsConfigurationSchemaId } from '../common/extensionsFileTemplate.js';
import { CommandsRegistry, ICommandService } from '../../../../platform/commands/common/commands.js';
import { IInstantiationService, ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js';
import { KeymapExtensions } from '../common/extensionsUtils.js';
import { areSameExtensions, getIdAndVersion } from '../../../../platform/extensionManagement/common/extensionManagementUtil.js';
import { EditorPaneDescriptor, IEditorPaneRegistry } from '../../../browser/editor.js';
import { LifecyclePhase } from '../../../services/lifecycle/common/lifecycle.js';
import { URI, UriComponents } from '../../../../base/common/uri.js';
import { ExtensionActivationProgress } from './extensionsActivationProgress.js';
import { onUnexpectedError } from '../../../../base/common/errors.js';
import { ExtensionDependencyChecker } from './extensionsDependencyChecker.js';
import { CancellationToken } from '../../../../base/common/cancellation.js';
import { IViewContainersRegistry, ViewContainerLocation, Extensions as ViewContainerExtensions } from '../../../common/views.js';
import { IViewsService } from '../../../services/views/common/viewsService.js';
import { IClipboardService } from '../../../../platform/clipboard/common/clipboardService.js';
import { IPreferencesService } from '../../../services/preferences/common/preferences.js';
import { ContextKeyExpr, IContextKeyService, RawContextKey } from '../../../../platform/contextkey/common/contextkey.js';
import { IQuickAccessRegistry, Extensions } from '../../../../platform/quickinput/common/quickAccess.js';
import { InstallExtensionQuickAccessProvider, ManageExtensionsQuickAccessProvider } from './extensionsQuickAccess.js';
import { ExtensionRecommendationsService } from './extensionRecommendationsService.js';
import { CONTEXT_SYNC_ENABLEMENT } from '../../../services/userDataSync/common/userDataSync.js';
import { CopyAction, CutAction, PasteAction } from '../../../../editor/contrib/clipboard/browser/clipboard.js';
import { IEditorService } from '../../../services/editor/common/editorService.js';
import { MultiCommand } from '../../../../editor/browser/editorExtensions.js';
import { IWebview } from '../../webview/browser/webview.js';
import { ExtensionsWorkbenchService } from './extensionsWorkbenchService.js';
import { Categories } from '../../../../platform/action/common/actionCommonCategories.js';
import { IExtensionRecommendationNotificationService } from '../../../../platform/extensionRecommendations/common/extensionRecommendations.js';
import { ExtensionRecommendationNotificationService } from './extensionRecommendationNotificationService.js';
import { INotificationService, Severity } from '../../../../platform/notification/common/notification.js';
import { IHostService } from '../../../services/host/browser/host.js';
import { ResourceContextKey, WorkbenchStateContext } from '../../../common/contextkeys.js';
import { IAction } from '../../../../base/common/actions.js';
import { IWorkspaceExtensionsConfigService } from '../../../services/extensionRecommendations/common/workspaceExtensionsConfig.js';
import { Schemas } from '../../../../base/common/network.js';
import { ShowRuntimeExtensionsAction } from './abstractRuntimeExtensionsEditor.js';
import { ExtensionEnablementWorkspaceTrustTransitionParticipant } from './extensionEnablementWorkspaceTrustTransitionParticipant.js';
import { clearSearchResultsIcon, configureRecommendedIcon, extensionsViewIcon, filterIcon, installWorkspaceRecommendedIcon, refreshIcon } from './extensionsIcons.js';
import { EXTENSION_CATEGORIES } from '../../../../platform/extensions/common/extensions.js';
import { Disposable, DisposableStore, IDisposable, isDisposable } from '../../../../base/common/lifecycle.js';
import { IDialogService, IFileDialogService } from '../../../../platform/dialogs/common/dialogs.js';
import { mnemonicButtonLabel } from '../../../../base/common/labels.js';
import { Query } from '../common/extensionQuery.js';
import { EditorExtensions } from '../../../common/editor.js';
import { WORKSPACE_TRUST_EXTENSION_SUPPORT } from '../../../services/workspaces/common/workspaceTrust.js';
import { ExtensionsCompletionItemsProvider } from './extensionsCompletionItemsProvider.js';
import { IQuickInputService } from '../../../../platform/quickinput/common/quickInput.js';
import { Event } from '../../../../base/common/event.js';
import { UnsupportedExtensionsMigrationContrib } from './unsupportedExtensionsMigrationContribution.js';
import { isLinux, isNative, isWeb } from '../../../../base/common/platform.js';
import { ExtensionStorageService } from '../../../../platform/extensionManagement/common/extensionStorage.js';
import { IStorageService } from '../../../../platform/storage/common/storage.js';
import { IStringDictionary } from '../../../../base/common/collections.js';
import { CONTEXT_KEYBINDINGS_EDITOR } from '../../preferences/common/preferences.js';
import { ProgressLocation } from '../../../../platform/progress/common/progress.js';
import { IUriIdentityService } from '../../../../platform/uriIdentity/common/uriIdentity.js';
import { IConfigurationMigrationRegistry, Extensions as ConfigurationMigrationExtensions } from '../../../common/configuration.js';
// Singletons
registerSingleton(IExtensionsWorkbenchService, ExtensionsWorkbenchService, InstantiationType.Eager /* Auto updates extensions */);
registerSingleton(IExtensionRecommendationNotificationService, ExtensionRecommendationNotificationService, InstantiationType.Delayed);
registerSingleton(IExtensionRecommendationsService, ExtensionRecommendationsService, InstantiationType.Eager /* Prompts recommendations in the background */);
// Quick Access
Registry.as<IQuickAccessRegistry>(Extensions.Quickaccess).registerQuickAccessProvider({
ctor: ManageExtensionsQuickAccessProvider,
prefix: ManageExtensionsQuickAccessProvider.PREFIX,
placeholder: localize('manageExtensionsQuickAccessPlaceholder', "Press Enter to manage extensions."),
helpEntries: [{ description: localize('manageExtensionsHelp', "Manage Extensions") }]
});
// Editor
Registry.as<IEditorPaneRegistry>(EditorExtensions.EditorPane).registerEditorPane(
EditorPaneDescriptor.create(
ExtensionEditor,
ExtensionEditor.ID,
localize('extension', "Extension")
),
[
new SyncDescriptor(ExtensionsInput)
]);
Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry).registerViewContainer(
{
id: VIEWLET_ID,
title: localize2('extensions', "Extensions"),
openCommandActionDescriptor: {
id: VIEWLET_ID,
mnemonicTitle: localize({ key: 'miViewExtensions', comment: ['&& denotes a mnemonic'] }, "E&&xtensions"),
keybindings: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KeyX },
order: 4,
},
ctorDescriptor: new SyncDescriptor(ExtensionsViewPaneContainer),
icon: extensionsViewIcon,
order: 4,
rejectAddedViews: true,
alwaysUseContainerInfo: true,
}, ViewContainerLocation.Sidebar);
Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration)
.registerConfiguration({
...extensionsConfigurationNodeBase,
properties: {
'extensions.autoUpdate': {
enum: [true, 'onlyEnabledExtensions', false,],
enumItemLabels: [
localize('all', "All Extensions"),
localize('enabled', "Only Enabled Extensions"),
localize('none', "None"),
],
enumDescriptions: [
localize('extensions.autoUpdate.true', 'Download and install updates automatically for all extensions.'),
localize('extensions.autoUpdate.enabled', 'Download and install updates automatically only for enabled extensions.'),
localize('extensions.autoUpdate.false', 'Extensions are not automatically updated.'),
],
description: localize('extensions.autoUpdate', "Controls the automatic update behavior of extensions. The updates are fetched from a Microsoft online service."),
default: true,
scope: ConfigurationScope.APPLICATION,
tags: ['usesOnlineServices']
},
'extensions.autoCheckUpdates': {
type: 'boolean',
description: localize('extensionsCheckUpdates', "When enabled, automatically checks extensions for updates. If an extension has an update, it is marked as outdated in the Extensions view. The updates are fetched from a Microsoft online service."),
default: true,
scope: ConfigurationScope.APPLICATION,
tags: ['usesOnlineServices']
},
'extensions.ignoreRecommendations': {
type: 'boolean',
description: localize('extensionsIgnoreRecommendations', "When enabled, the notifications for extension recommendations will not be shown."),
default: false
},
'extensions.showRecommendationsOnlyOnDemand': {
type: 'boolean',
deprecationMessage: localize('extensionsShowRecommendationsOnlyOnDemand_Deprecated', "This setting is deprecated. Use extensions.ignoreRecommendations setting to control recommendation notifications. Use Extensions view's visibility actions to hide Recommended view by default."),
default: false,
tags: ['usesOnlineServices']
},
'extensions.closeExtensionDetailsOnViewChange': {
type: 'boolean',
description: localize('extensionsCloseExtensionDetailsOnViewChange', "When enabled, editors with extension details will be automatically closed upon navigating away from the Extensions View."),
default: false
},
'extensions.confirmedUriHandlerExtensionIds': {
type: 'array',
items: {
type: 'string'
},
description: localize('handleUriConfirmedExtensions', "When an extension is listed here, a confirmation prompt will not be shown when that extension handles a URI."),
default: [],
scope: ConfigurationScope.APPLICATION
},
'extensions.webWorker': {
type: ['boolean', 'string'],
enum: [true, false, 'auto'],
enumDescriptions: [
localize('extensionsWebWorker.true', "The Web Worker Extension Host will always be launched."),
localize('extensionsWebWorker.false', "The Web Worker Extension Host will never be launched."),
localize('extensionsWebWorker.auto', "The Web Worker Extension Host will be launched when a web extension needs it."),
],
description: localize('extensionsWebWorker', "Enable web worker extension host."),
default: 'auto'
},
'extensions.supportVirtualWorkspaces': {
type: 'object',
markdownDescription: localize('extensions.supportVirtualWorkspaces', "Override the virtual workspaces support of an extension."),
patternProperties: {
'([a-z0-9A-Z][a-z0-9-A-Z]*)\\.([a-z0-9A-Z][a-z0-9-A-Z]*)$': {
type: 'boolean',
default: false
}
},
additionalProperties: false,
default: {},
defaultSnippets: [{
'body': {
'pub.name': false
}
}]
},
'extensions.experimental.affinity': {
type: 'object',
markdownDescription: localize('extensions.affinity', "Configure an extension to execute in a different extension host process."),
patternProperties: {
'([a-z0-9A-Z][a-z0-9-A-Z]*)\\.([a-z0-9A-Z][a-z0-9-A-Z]*)$': {
type: 'integer',
default: 1
}
},
additionalProperties: false,
default: {},
defaultSnippets: [{
'body': {
'pub.name': 1
}
}]
},
[WORKSPACE_TRUST_EXTENSION_SUPPORT]: {
type: 'object',
scope: ConfigurationScope.APPLICATION,
markdownDescription: localize('extensions.supportUntrustedWorkspaces', "Override the untrusted workspace support of an extension. Extensions using `true` will always be enabled. Extensions using `limited` will always be enabled, and the extension will hide functionality that requires trust. Extensions using `false` will only be enabled only when the workspace is trusted."),
patternProperties: {
'([a-z0-9A-Z][a-z0-9-A-Z]*)\\.([a-z0-9A-Z][a-z0-9-A-Z]*)$': {
type: 'object',
properties: {
'supported': {
type: ['boolean', 'string'],
enum: [true, false, 'limited'],
enumDescriptions: [
localize('extensions.supportUntrustedWorkspaces.true', "Extension will always be enabled."),
localize('extensions.supportUntrustedWorkspaces.false', "Extension will only be enabled only when the workspace is trusted."),
localize('extensions.supportUntrustedWorkspaces.limited', "Extension will always be enabled, and the extension will hide functionality requiring trust."),
],
description: localize('extensions.supportUntrustedWorkspaces.supported', "Defines the untrusted workspace support setting for the extension."),
},
'version': {
type: 'string',
description: localize('extensions.supportUntrustedWorkspaces.version', "Defines the version of the extension for which the override should be applied. If not specified, the override will be applied independent of the extension version."),
}
}
}
}
},
'extensions.experimental.deferredStartupFinishedActivation': {
type: 'boolean',
description: localize('extensionsDeferredStartupFinishedActivation', "When enabled, extensions which declare the `onStartupFinished` activation event will be activated after a timeout."),
default: false
},
'extensions.experimental.issueQuickAccess': {
type: 'boolean',
description: localize('extensionsInQuickAccess', "When enabled, extensions can be searched for via Quick Access and report issues from there."),
default: true
},
'extensions.verifySignature': {
type: 'boolean',
description: localize('extensions.verifySignature', "When enabled, extensions are verified to be signed before getting installed."),
default: true,
scope: ConfigurationScope.APPLICATION,
included: isNative && !isLinux
}
}
});
const jsonRegistry = <jsonContributionRegistry.IJSONContributionRegistry>Registry.as(jsonContributionRegistry.Extensions.JSONContribution);
jsonRegistry.registerSchema(ExtensionsConfigurationSchemaId, ExtensionsConfigurationSchema);
// Register Commands
CommandsRegistry.registerCommand('_extensions.manage', (accessor: ServicesAccessor, extensionId: string, tab?: ExtensionEditorTab, preserveFocus?: boolean, feature?: string) => {
const extensionService = accessor.get(IExtensionsWorkbenchService);
const extension = extensionService.local.find(e => areSameExtensions(e.identifier, { id: extensionId }));
if (extension) {
extensionService.open(extension, { tab, preserveFocus, feature });
} else {
throw new Error(localize('notFound', "Extension '{0}' not found.", extensionId));
}
});
CommandsRegistry.registerCommand('extension.open', async (accessor: ServicesAccessor, extensionId: string, tab?: ExtensionEditorTab, preserveFocus?: boolean, feature?: string, sideByside?: boolean) => {
const extensionService = accessor.get(IExtensionsWorkbenchService);
const commandService = accessor.get(ICommandService);
const [extension] = await extensionService.getExtensions([{ id: extensionId }], CancellationToken.None);
if (extension) {
return extensionService.open(extension, { tab, preserveFocus, feature, sideByside });
}
return commandService.executeCommand('_extensions.manage', extensionId, tab, preserveFocus, feature);
});
CommandsRegistry.registerCommand({
id: 'workbench.extensions.installExtension',
metadata: {
description: localize('workbench.extensions.installExtension.description', "Install the given extension"),
args: [
{
name: 'extensionIdOrVSIXUri',
description: localize('workbench.extensions.installExtension.arg.decription', "Extension id or VSIX resource uri"),
constraint: (value: any) => typeof value === 'string' || value instanceof URI,
},
{
name: 'options',
description: '(optional) Options for installing the extension. Object with the following properties: ' +
'`installOnlyNewlyAddedFromExtensionPackVSIX`: When enabled, VS Code installs only newly added extensions from the extension pack VSIX. This option is considered only when installing VSIX. ',
isOptional: true,
schema: {
'type': 'object',
'properties': {
'installOnlyNewlyAddedFromExtensionPackVSIX': {
'type': 'boolean',
'description': localize('workbench.extensions.installExtension.option.installOnlyNewlyAddedFromExtensionPackVSIX', "When enabled, VS Code installs only newly added extensions from the extension pack VSIX. This option is considered only while installing a VSIX."),
default: false
},
'installPreReleaseVersion': {
'type': 'boolean',
'description': localize('workbench.extensions.installExtension.option.installPreReleaseVersion', "When enabled, VS Code installs the pre-release version of the extension if available."),
default: false
},
'donotSync': {
'type': 'boolean',
'description': localize('workbench.extensions.installExtension.option.donotSync', "When enabled, VS Code do not sync this extension when Settings Sync is on."),
default: false
},
'justification': {
'type': ['string', 'object'],
'description': localize('workbench.extensions.installExtension.option.justification', "Justification for installing the extension. This is a string or an object that can be used to pass any information to the installation handlers. i.e. `{reason: 'This extension wants to open a URI', action: 'Open URI'}` will show a message box with the reason and action upon install."),
},
'enable': {
'type': 'boolean',
'description': localize('workbench.extensions.installExtension.option.enable', "When enabled, the extension will be enabled if it is installed but disabled. If the extension is already enabled, this has no effect."),
default: false
},
'context': {
'type': 'object',
'description': localize('workbench.extensions.installExtension.option.context', "Context for the installation. This is a JSON object that can be used to pass any information to the installation handlers. i.e. `{skipWalkthrough: true}` will skip opening the walkthrough upon install."),
}
}
}
}
]
},
handler: async (
accessor,
arg: string | UriComponents,
options?: {
installOnlyNewlyAddedFromExtensionPackVSIX?: boolean;
installPreReleaseVersion?: boolean;
donotSync?: boolean;
justification?: string | { reason: string; action: string };
enable?: boolean;
context?: IStringDictionary<any>;
}) => {
const extensionsWorkbenchService = accessor.get(IExtensionsWorkbenchService);
const extensionManagementService = accessor.get(IWorkbenchExtensionManagementService);
const extensionGalleryService = accessor.get(IExtensionGalleryService);
try {
if (typeof arg === 'string') {
const [id, version] = getIdAndVersion(arg);
const extension = extensionsWorkbenchService.local.find(e => areSameExtensions(e.identifier, { id, uuid: version }));
if (extension?.enablementState === EnablementState.DisabledByExtensionKind) {
const [gallery] = await extensionGalleryService.getExtensions([{ id, preRelease: options?.installPreReleaseVersion }], CancellationToken.None);
if (!gallery) {
throw new Error(localize('notFound', "Extension '{0}' not found.", arg));
}
await extensionManagementService.installFromGallery(gallery, {
isMachineScoped: options?.donotSync ? true : undefined, /* do not allow syncing extensions automatically while installing through the command */
installPreReleaseVersion: options?.installPreReleaseVersion,
installGivenVersion: !!version,
context: { ...options?.context, [EXTENSION_INSTALL_SOURCE_CONTEXT]: ExtensionInstallSource.COMMAND },
});
} else {
await extensionsWorkbenchService.install(arg, {
version,
installPreReleaseVersion: options?.installPreReleaseVersion,
context: { ...options?.context, [EXTENSION_INSTALL_SOURCE_CONTEXT]: ExtensionInstallSource.COMMAND },
justification: options?.justification,
enable: options?.enable,
isMachineScoped: options?.donotSync ? true : undefined, /* do not allow syncing extensions automatically while installing through the command */
}, ProgressLocation.Notification);
}
} else {
const vsix = URI.revive(arg);
await extensionsWorkbenchService.install(vsix, { installOnlyNewlyAddedFromExtensionPack: options?.installOnlyNewlyAddedFromExtensionPackVSIX, installGivenVersion: true });
}
} catch (e) {
onUnexpectedError(e);
throw e;
}
}
});
CommandsRegistry.registerCommand({
id: 'workbench.extensions.uninstallExtension',
metadata: {
description: localize('workbench.extensions.uninstallExtension.description', "Uninstall the given extension"),
args: [
{
name: localize('workbench.extensions.uninstallExtension.arg.name', "Id of the extension to uninstall"),
schema: {
'type': 'string'
}
}
]
},
handler: async (accessor, id: string) => {
if (!id) {
throw new Error(localize('id required', "Extension id required."));
}
const extensionManagementService = accessor.get(IExtensionManagementService);
const installed = await extensionManagementService.getInstalled();
const [extensionToUninstall] = installed.filter(e => areSameExtensions(e.identifier, { id }));
if (!extensionToUninstall) {
throw new Error(localize('notInstalled', "Extension '{0}' is not installed. Make sure you use the full extension ID, including the publisher, e.g.: ms-dotnettools.csharp.", id));
}
if (extensionToUninstall.isBuiltin) {
throw new Error(localize('builtin', "Extension '{0}' is a Built-in extension and cannot be installed", id));
}
try {
await extensionManagementService.uninstall(extensionToUninstall);
} catch (e) {
onUnexpectedError(e);
throw e;
}
}
});
CommandsRegistry.registerCommand({
id: 'workbench.extensions.search',
metadata: {
description: localize('workbench.extensions.search.description', "Search for a specific extension"),
args: [
{
name: localize('workbench.extensions.search.arg.name', "Query to use in search"),
schema: { 'type': 'string' }
}
]
},
handler: async (accessor, query: string = '') => {
return accessor.get(IExtensionsWorkbenchService).openSearch(query);
}
});
function overrideActionForActiveExtensionEditorWebview(command: MultiCommand | undefined, f: (webview: IWebview) => void) {
command?.addImplementation(105, 'extensions-editor', (accessor) => {
const editorService = accessor.get(IEditorService);
const editor = editorService.activeEditorPane;
if (editor instanceof ExtensionEditor) {
if (editor.activeWebview?.isFocused) {
f(editor.activeWebview);
return true;
}
}
return false;
});
}
overrideActionForActiveExtensionEditorWebview(CopyAction, webview => webview.copy());
overrideActionForActiveExtensionEditorWebview(CutAction, webview => webview.cut());
overrideActionForActiveExtensionEditorWebview(PasteAction, webview => webview.paste());
// Contexts
export const CONTEXT_HAS_LOCAL_SERVER = new RawContextKey<boolean>('hasLocalServer', false);
export const CONTEXT_HAS_REMOTE_SERVER = new RawContextKey<boolean>('hasRemoteServer', false);
export const CONTEXT_HAS_WEB_SERVER = new RawContextKey<boolean>('hasWebServer', false);
async function runAction(action: IAction): Promise<void> {
try {
await action.run();
} finally {
if (isDisposable(action)) {
action.dispose();
}
}
}
type IExtensionActionOptions = IAction2Options & {
menuTitles?: { [id: string]: string };
run(accessor: ServicesAccessor, ...args: any[]): Promise<any>;
};
class ExtensionsContributions extends Disposable implements IWorkbenchContribution {
constructor(
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService,
@IExtensionGalleryService extensionGalleryService: IExtensionGalleryService,
@IContextKeyService contextKeyService: IContextKeyService,
@IViewsService private readonly viewsService: IViewsService,
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
@IWorkbenchExtensionEnablementService private readonly extensionEnablementService: IWorkbenchExtensionEnablementService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IDialogService private readonly dialogService: IDialogService,
@ICommandService private readonly commandService: ICommandService,
) {
super();
const hasGalleryContext = CONTEXT_HAS_GALLERY.bindTo(contextKeyService);
if (extensionGalleryService.isEnabled()) {
hasGalleryContext.set(true);
}
const hasLocalServerContext = CONTEXT_HAS_LOCAL_SERVER.bindTo(contextKeyService);
if (this.extensionManagementServerService.localExtensionManagementServer) {
hasLocalServerContext.set(true);
}
const hasRemoteServerContext = CONTEXT_HAS_REMOTE_SERVER.bindTo(contextKeyService);
if (this.extensionManagementServerService.remoteExtensionManagementServer) {
hasRemoteServerContext.set(true);
}
const hasWebServerContext = CONTEXT_HAS_WEB_SERVER.bindTo(contextKeyService);
if (this.extensionManagementServerService.webExtensionManagementServer) {
hasWebServerContext.set(true);
}
this.registerGlobalActions();
this.registerContextMenuActions();
this.registerQuickAccessProvider();
}
private registerQuickAccessProvider(): void {
if (this.extensionManagementServerService.localExtensionManagementServer
|| this.extensionManagementServerService.remoteExtensionManagementServer
|| this.extensionManagementServerService.webExtensionManagementServer
) {
Registry.as<IQuickAccessRegistry>(Extensions.Quickaccess).registerQuickAccessProvider({
ctor: InstallExtensionQuickAccessProvider,
prefix: InstallExtensionQuickAccessProvider.PREFIX,
placeholder: localize('installExtensionQuickAccessPlaceholder', "Type the name of an extension to install or search."),
helpEntries: [{ description: localize('installExtensionQuickAccessHelp', "Install or Search Extensions") }]
});
}
}
// Global actions
private registerGlobalActions(): void {
this._register(MenuRegistry.appendMenuItem(MenuId.MenubarPreferencesMenu, {
command: {
id: VIEWLET_ID,
title: localize({ key: 'miPreferencesExtensions', comment: ['&& denotes a mnemonic'] }, "&&Extensions")
},
group: '2_configuration',
order: 3
}));
this._register(MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
command: {
id: VIEWLET_ID,
title: localize('showExtensions', "Extensions")
},
group: '2_configuration',
order: 3
}));
this.registerExtensionAction({
id: 'workbench.extensions.action.focusExtensionsView',
title: localize2('focusExtensions', 'Focus on Extensions View'),
category: ExtensionsLocalizedLabel,
f1: true,
run: async (accessor: ServicesAccessor) => {
await accessor.get(IExtensionsWorkbenchService).openSearch('');
}
});
this.registerExtensionAction({
id: 'workbench.extensions.action.installExtensions',
title: localize2('installExtensions', 'Install Extensions'),
category: ExtensionsLocalizedLabel,
menu: {
id: MenuId.CommandPalette,
when: ContextKeyExpr.and(CONTEXT_HAS_GALLERY, ContextKeyExpr.or(CONTEXT_HAS_LOCAL_SERVER, CONTEXT_HAS_REMOTE_SERVER, CONTEXT_HAS_WEB_SERVER))
},
run: async (accessor: ServicesAccessor) => {
accessor.get(IViewsService).openViewContainer(VIEWLET_ID, true);
}
});
this.registerExtensionAction({
id: 'workbench.extensions.action.showRecommendedKeymapExtensions',
title: localize2('showRecommendedKeymapExtensionsShort', 'Keymaps'),
category: PreferencesLocalizedLabel,
menu: [{
id: MenuId.CommandPalette,
when: CONTEXT_HAS_GALLERY
}, {
id: MenuId.EditorTitle,
when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_HAS_GALLERY),
group: '2_keyboard_discover_actions'
}],
menuTitles: {
[MenuId.EditorTitle.id]: localize('importKeyboardShortcutsFroms', "Migrate Keyboard Shortcuts from...")
},
run: () => this.extensionsWorkbenchService.openSearch('@recommended:keymaps ')
});
this.registerExtensionAction({
id: 'workbench.extensions.action.showLanguageExtensions',
title: localize2('showLanguageExtensionsShort', 'Language Extensions'),
category: PreferencesLocalizedLabel,
menu: {
id: MenuId.CommandPalette,
when: CONTEXT_HAS_GALLERY
},
run: () => this.extensionsWorkbenchService.openSearch('@recommended:languages ')
});
this.registerExtensionAction({
id: 'workbench.extensions.action.checkForUpdates',
title: localize2('checkForUpdates', 'Check for Extension Updates'),
category: ExtensionsLocalizedLabel,
menu: [{
id: MenuId.CommandPalette,
when: ContextKeyExpr.and(CONTEXT_HAS_GALLERY, ContextKeyExpr.or(CONTEXT_HAS_LOCAL_SERVER, CONTEXT_HAS_REMOTE_SERVER, CONTEXT_HAS_WEB_SERVER))
}, {
id: MenuId.ViewContainerTitle,
when: ContextKeyExpr.and(ContextKeyExpr.equals('viewContainer', VIEWLET_ID), CONTEXT_HAS_GALLERY),
group: '1_updates',
order: 1
}],
run: async () => {
await this.extensionsWorkbenchService.checkForUpdates();
const outdated = this.extensionsWorkbenchService.outdated;
if (outdated.length) {
return this.extensionsWorkbenchService.openSearch('@outdated ');
} else {
return this.dialogService.info(localize('noUpdatesAvailable', "All extensions are up to date."));
}
}
});
const enableAutoUpdateWhenCondition = ContextKeyExpr.equals(`config.${AutoUpdateConfigurationKey}`, false);
this.registerExtensionAction({
id: 'workbench.extensions.action.enableAutoUpdate',
title: localize2('enableAutoUpdate', 'Enable Auto Update for All Extensions'),
category: ExtensionsLocalizedLabel,
precondition: enableAutoUpdateWhenCondition,
menu: [{
id: MenuId.ViewContainerTitle,
order: 5,
group: '1_updates',
when: ContextKeyExpr.and(ContextKeyExpr.equals('viewContainer', VIEWLET_ID), enableAutoUpdateWhenCondition)
}, {
id: MenuId.CommandPalette,
}],
run: (accessor: ServicesAccessor) => accessor.get(IExtensionsWorkbenchService).updateAutoUpdateForAllExtensions(true)
});
const disableAutoUpdateWhenCondition = ContextKeyExpr.notEquals(`config.${AutoUpdateConfigurationKey}`, false);
this.registerExtensionAction({
id: 'workbench.extensions.action.disableAutoUpdate',
title: localize2('disableAutoUpdate', 'Disable Auto Update for All Extensions'),
precondition: disableAutoUpdateWhenCondition,
category: ExtensionsLocalizedLabel,
menu: [{
id: MenuId.ViewContainerTitle,
order: 5,
group: '1_updates',
when: ContextKeyExpr.and(ContextKeyExpr.equals('viewContainer', VIEWLET_ID), disableAutoUpdateWhenCondition)
}, {
id: MenuId.CommandPalette,
}],
run: (accessor: ServicesAccessor) => accessor.get(IExtensionsWorkbenchService).updateAutoUpdateForAllExtensions(false)
});
this.registerExtensionAction({
id: 'workbench.extensions.action.updateAllExtensions',
title: localize2('updateAll', 'Update All Extensions'),
category: ExtensionsLocalizedLabel,
precondition: HasOutdatedExtensionsContext,
menu: [
{
id: MenuId.CommandPalette,
when: ContextKeyExpr.and(CONTEXT_HAS_GALLERY, ContextKeyExpr.or(CONTEXT_HAS_LOCAL_SERVER, CONTEXT_HAS_REMOTE_SERVER, CONTEXT_HAS_WEB_SERVER))
}, {
id: MenuId.ViewContainerTitle,
when: ContextKeyExpr.and(ContextKeyExpr.equals('viewContainer', VIEWLET_ID), ContextKeyExpr.or(ContextKeyExpr.has(`config.${AutoUpdateConfigurationKey}`).negate(), ContextKeyExpr.equals(`config.${AutoUpdateConfigurationKey}`, 'onlyEnabledExtensions'))),
group: '1_updates',
order: 2
}, {
id: MenuId.ViewTitle,
when: ContextKeyExpr.equals('view', OUTDATED_EXTENSIONS_VIEW_ID),
group: 'navigation',
order: 1
}
],
icon: installWorkspaceRecommendedIcon,
run: async () => {
await this.extensionsWorkbenchService.updateAll();
}
});
this.registerExtensionAction({
id: 'workbench.extensions.action.enableAll',
title: localize2('enableAll', 'Enable All Extensions'),
category: ExtensionsLocalizedLabel,
menu: [{
id: MenuId.CommandPalette,
when: ContextKeyExpr.or(CONTEXT_HAS_LOCAL_SERVER, CONTEXT_HAS_REMOTE_SERVER, CONTEXT_HAS_WEB_SERVER)
}, {
id: MenuId.ViewContainerTitle,
when: ContextKeyExpr.equals('viewContainer', VIEWLET_ID),
group: '2_enablement',
order: 1
}],
run: async () => {
const extensionsToEnable = this.extensionsWorkbenchService.local.filter(e => !!e.local && this.extensionEnablementService.canChangeEnablement(e.local) && !this.extensionEnablementService.isEnabled(e.local));
if (extensionsToEnable.length) {
await this.extensionsWorkbenchService.setEnablement(extensionsToEnable, EnablementState.EnabledGlobally);
}
}
});
this.registerExtensionAction({
id: 'workbench.extensions.action.enableAllWorkspace',
title: localize2('enableAllWorkspace', 'Enable All Extensions for this Workspace'),
category: ExtensionsLocalizedLabel,
menu: {
id: MenuId.CommandPalette,
when: ContextKeyExpr.and(WorkbenchStateContext.notEqualsTo('empty'), ContextKeyExpr.or(CONTEXT_HAS_LOCAL_SERVER, CONTEXT_HAS_REMOTE_SERVER, CONTEXT_HAS_WEB_SERVER))
},
run: async () => {
const extensionsToEnable = this.extensionsWorkbenchService.local.filter(e => !!e.local && this.extensionEnablementService.canChangeEnablement(e.local) && !this.extensionEnablementService.isEnabled(e.local));
if (extensionsToEnable.length) {
await this.extensionsWorkbenchService.setEnablement(extensionsToEnable, EnablementState.EnabledWorkspace);
}
}
});
this.registerExtensionAction({
id: 'workbench.extensions.action.disableAll',
title: localize2('disableAll', 'Disable All Installed Extensions'),
category: ExtensionsLocalizedLabel,
menu: [{
id: MenuId.CommandPalette,
when: ContextKeyExpr.or(CONTEXT_HAS_LOCAL_SERVER, CONTEXT_HAS_REMOTE_SERVER, CONTEXT_HAS_WEB_SERVER)
}, {
id: MenuId.ViewContainerTitle,
when: ContextKeyExpr.equals('viewContainer', VIEWLET_ID),
group: '2_enablement',
order: 2
}],
run: async () => {
const extensionsToDisable = this.extensionsWorkbenchService.local.filter(e => !e.isBuiltin && !!e.local && this.extensionEnablementService.isEnabled(e.local) && this.extensionEnablementService.canChangeEnablement(e.local));
if (extensionsToDisable.length) {
await this.extensionsWorkbenchService.setEnablement(extensionsToDisable, EnablementState.DisabledGlobally);
}
}
});
this.registerExtensionAction({
id: 'workbench.extensions.action.disableAllWorkspace',
title: localize2('disableAllWorkspace', 'Disable All Installed Extensions for this Workspace'),
category: ExtensionsLocalizedLabel,
menu: {
id: MenuId.CommandPalette,
when: ContextKeyExpr.and(WorkbenchStateContext.notEqualsTo('empty'), ContextKeyExpr.or(CONTEXT_HAS_LOCAL_SERVER, CONTEXT_HAS_REMOTE_SERVER, CONTEXT_HAS_WEB_SERVER))
},
run: async () => {
const extensionsToDisable = this.extensionsWorkbenchService.local.filter(e => !e.isBuiltin && !!e.local && this.extensionEnablementService.isEnabled(e.local) && this.extensionEnablementService.canChangeEnablement(e.local));
if (extensionsToDisable.length) {
await this.extensionsWorkbenchService.setEnablement(extensionsToDisable, EnablementState.DisabledWorkspace);
}
}
});
this.registerExtensionAction({
id: SELECT_INSTALL_VSIX_EXTENSION_COMMAND_ID,
title: localize2('InstallFromVSIX', 'Install from VSIX...'),
category: ExtensionsLocalizedLabel,
menu: [{
id: MenuId.CommandPalette,
when: ContextKeyExpr.or(CONTEXT_HAS_LOCAL_SERVER, CONTEXT_HAS_REMOTE_SERVER)
}, {
id: MenuId.ViewContainerTitle,
when: ContextKeyExpr.and(ContextKeyExpr.equals('viewContainer', VIEWLET_ID), ContextKeyExpr.or(CONTEXT_HAS_LOCAL_SERVER, CONTEXT_HAS_REMOTE_SERVER)),
group: '3_install',
order: 1
}],
run: async (accessor: ServicesAccessor) => {
const fileDialogService = accessor.get(IFileDialogService);
const commandService = accessor.get(ICommandService);
const vsixPaths = await fileDialogService.showOpenDialog({
title: localize('installFromVSIX', "Install from VSIX"),
filters: [{ name: 'VSIX Extensions', extensions: ['vsix'] }],
canSelectFiles: true,
canSelectMany: true,
openLabel: mnemonicButtonLabel(localize({ key: 'installButton', comment: ['&& denotes a mnemonic'] }, "&&Install"))
});
if (vsixPaths) {
await commandService.executeCommand(INSTALL_EXTENSION_FROM_VSIX_COMMAND_ID, vsixPaths);
}
}
});
this.registerExtensionAction({
id: INSTALL_EXTENSION_FROM_VSIX_COMMAND_ID,
title: localize('installVSIX', "Install Extension VSIX"),
menu: [{
id: MenuId.ExplorerContext,
group: 'extensions',
when: ContextKeyExpr.and(ResourceContextKey.Extension.isEqualTo('.vsix'), ContextKeyExpr.or(CONTEXT_HAS_LOCAL_SERVER, CONTEXT_HAS_REMOTE_SERVER)),
}],
run: async (accessor: ServicesAccessor, resources: URI[] | URI) => {
const extensionsWorkbenchService = accessor.get(IExtensionsWorkbenchService);
const hostService = accessor.get(IHostService);
const notificationService = accessor.get(INotificationService);
const vsixs = Array.isArray(resources) ? resources : [resources];
const result = await Promise.allSettled(vsixs.map(async (vsix) => await extensionsWorkbenchService.install(vsix, { installGivenVersion: true })));
let error: Error | undefined, requireReload = false, requireRestart = false;
for (const r of result) {
if (r.status === 'rejected') {
error = new Error(r.reason);
break;
}
requireReload = requireReload || r.value.runtimeState?.action === ExtensionRuntimeActionType.ReloadWindow;
requireRestart = requireRestart || r.value.runtimeState?.action === ExtensionRuntimeActionType.RestartExtensions;
}
if (error) {
throw error;
}
if (requireReload) {
notificationService.prompt(
Severity.Info,
localize('InstallVSIXAction.successReload', "Completed installing extension from VSIX. Please reload Visual Studio Code to enable it."),
[{
label: localize('InstallVSIXAction.reloadNow', "Reload Now"),
run: () => hostService.reload()
}]
);
}
else if (requireRestart) {
notificationService.prompt(
Severity.Info,
localize('InstallVSIXAction.successRestart', "Completed installing extension from VSIX. Please restart extensions to enable it."),
[{
label: localize('InstallVSIXAction.restartExtensions', "Restart Extensions"),
run: () => extensionsWorkbenchService.updateRunningExtensions()
}]
);
}
else {
notificationService.prompt(
Severity.Info,
localize('InstallVSIXAction.successNoReload', "Completed installing extension."),
[]
);
}
}
});
this.registerExtensionAction({
id: 'workbench.extensions.action.installExtensionFromLocation',
title: localize2('installExtensionFromLocation', 'Install Extension from Location...'),
category: Categories.Developer,
menu: [{
id: MenuId.CommandPalette,
when: ContextKeyExpr.or(CONTEXT_HAS_WEB_SERVER, CONTEXT_HAS_LOCAL_SERVER)
}],
run: async (accessor: ServicesAccessor) => {
const extensionManagementService = accessor.get(IWorkbenchExtensionManagementService);
if (isWeb) {
return new Promise<void>((c, e) => {
const quickInputService = accessor.get(IQuickInputService);
const disposables = new DisposableStore();
const quickPick = disposables.add(quickInputService.createQuickPick());
quickPick.title = localize('installFromLocation', "Install Extension from Location");
quickPick.customButton = true;
quickPick.customLabel = localize('install button', "Install");
quickPick.placeholder = localize('installFromLocationPlaceHolder', "Location of the web extension");
quickPick.ignoreFocusOut = true;
disposables.add(Event.any(quickPick.onDidAccept, quickPick.onDidCustom)(async () => {
quickPick.hide();
if (quickPick.value) {
try {
await extensionManagementService.installFromLocation(URI.parse(quickPick.value));
} catch (error) {
e(error);
return;
}
}
c();
}));
disposables.add(quickPick.onDidHide(() => disposables.dispose()));
quickPick.show();
});
} else {
const fileDialogService = accessor.get(IFileDialogService);
const extensionLocation = await fileDialogService.showOpenDialog({
canSelectFolders: true,
canSelectFiles: false,
canSelectMany: false,
title: localize('installFromLocation', "Install Extension from Location"),
});
if (extensionLocation?.[0]) {
await extensionManagementService.installFromLocation(extensionLocation[0]);
}
}
}
});
const extensionsFilterSubMenu = new MenuId('extensionsFilterSubMenu');
MenuRegistry.appendMenuItem(extensionsSearchActionsMenu, {
submenu: extensionsFilterSubMenu,
title: localize('filterExtensions', "Filter Extensions..."),
group: 'navigation',
order: 2,
icon: filterIcon,
});
const showFeaturedExtensionsId = 'extensions.filter.featured';
this.registerExtensionAction({
id: showFeaturedExtensionsId,
title: localize2('showFeaturedExtensions', 'Show Featured Extensions'),
category: ExtensionsLocalizedLabel,
menu: [{
id: MenuId.CommandPalette,
when: CONTEXT_HAS_GALLERY
}, {
id: extensionsFilterSubMenu,
when: CONTEXT_HAS_GALLERY,
group: '1_predefined',
order: 1,
}],
menuTitles: {
[extensionsFilterSubMenu.id]: localize('featured filter', "Featured")
},
run: () => this.extensionsWorkbenchService.openSearch('@featured ')
});
this.registerExtensionAction({
id: 'workbench.extensions.action.showPopularExtensions',
title: localize2('showPopularExtensions', 'Show Popular Extensions'),
category: ExtensionsLocalizedLabel,
menu: [{
id: MenuId.CommandPalette,
when: CONTEXT_HAS_GALLERY
}, {
id: extensionsFilterSubMenu,
when: CONTEXT_HAS_GALLERY,
group: '1_predefined',
order: 2,
}],
menuTitles: {
[extensionsFilterSubMenu.id]: localize('most popular filter', "Most Popular")
},
run: () => this.extensionsWorkbenchService.openSearch('@popular ')
});
this.registerExtensionAction({
id: 'workbench.extensions.action.showRecommendedExtensions',
title: localize2('showRecommendedExtensions', 'Show Recommended Extensions'),
category: ExtensionsLocalizedLabel,
menu: [{
id: MenuId.CommandPalette,
when: CONTEXT_HAS_GALLERY
}, {
id: extensionsFilterSubMenu,
when: CONTEXT_HAS_GALLERY,
group: '1_predefined',
order: 2,
}],
menuTitles: {
[extensionsFilterSubMenu.id]: localize('most popular recommended', "Recommended")
},
run: () => this.extensionsWorkbenchService.openSearch('@recommended ')
});
this.registerExtensionAction({
id: 'workbench.extensions.action.recentlyPublishedExtensions',
title: localize2('recentlyPublishedExtensions', 'Show Recently Published Extensions'),
category: ExtensionsLocalizedLabel,
menu: [{
id: MenuId.CommandPalette,
when: CONTEXT_HAS_GALLERY
}, {
id: extensionsFilterSubMenu,
when: CONTEXT_HAS_GALLERY,
group: '1_predefined',
order: 2,
}],
menuTitles: {
[extensionsFilterSubMenu.id]: localize('recently published filter', "Recently Published")
},
run: () => this.extensionsWorkbenchService.openSearch('@recentlyPublished ')
});
const extensionsCategoryFilterSubMenu = new MenuId('extensionsCategoryFilterSubMenu');
MenuRegistry.appendMenuItem(extensionsFilterSubMenu, {
submenu: extensionsCategoryFilterSubMenu,
title: localize('filter by category', "Category"),
when: CONTEXT_HAS_GALLERY,
group: '2_categories',
order: 1,
});
EXTENSION_CATEGORIES.forEach((category, index) => {
this.registerExtensionAction({
id: `extensions.actions.searchByCategory.${category}`,
title: category,