@theia/plugin-ext 1.73.0-next.1 → 1.73.0-next.10

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.
Files changed (25) hide show
  1. package/lib/hosted/node/scanners/scanner-theia.d.ts.map +1 -1
  2. package/lib/hosted/node/scanners/scanner-theia.js +8 -1
  3. package/lib/hosted/node/scanners/scanner-theia.js.map +1 -1
  4. package/lib/main/browser/main-file-system-event-service.d.ts +5 -1
  5. package/lib/main/browser/main-file-system-event-service.d.ts.map +1 -1
  6. package/lib/main/browser/main-file-system-event-service.js +21 -2
  7. package/lib/main/browser/main-file-system-event-service.js.map +1 -1
  8. package/lib/main/browser/main-file-system-event-service.spec.d.ts +2 -0
  9. package/lib/main/browser/main-file-system-event-service.spec.d.ts.map +1 -0
  10. package/lib/main/browser/main-file-system-event-service.spec.js +65 -0
  11. package/lib/main/browser/main-file-system-event-service.spec.js.map +1 -0
  12. package/lib/main/browser/view/plugin-view-registry.d.ts +7 -0
  13. package/lib/main/browser/view/plugin-view-registry.d.ts.map +1 -1
  14. package/lib/main/browser/view/plugin-view-registry.js +82 -5
  15. package/lib/main/browser/view/plugin-view-registry.js.map +1 -1
  16. package/lib/main/browser/view/plugin-view-registry.spec.d.ts +2 -0
  17. package/lib/main/browser/view/plugin-view-registry.spec.d.ts.map +1 -0
  18. package/lib/main/browser/view/plugin-view-registry.spec.js +80 -0
  19. package/lib/main/browser/view/plugin-view-registry.spec.js.map +1 -0
  20. package/package.json +29 -29
  21. package/src/hosted/node/scanners/scanner-theia.ts +9 -1
  22. package/src/main/browser/main-file-system-event-service.spec.ts +78 -0
  23. package/src/main/browser/main-file-system-event-service.ts +22 -2
  24. package/src/main/browser/view/plugin-view-registry.spec.ts +105 -0
  25. package/src/main/browser/view/plugin-view-registry.ts +88 -5
@@ -111,6 +111,9 @@ export class PluginViewRegistry implements FrontendApplicationContribution {
111
111
  private readonly viewClauseContexts = new Map<string, Set<string> | undefined>();
112
112
  private readonly viewContainerClauseContexts = new Map<string, Set<string> | undefined>();
113
113
 
114
+ private readonly viewMenuLabelToContainerIds = new Map<string, Set<string>>();
115
+ private readonly viewMenuDisposables = new Map<string, Disposable>();
116
+
114
117
  private readonly viewDataProviders = new Map<string, ViewDataProvider>();
115
118
  private readonly viewDataState = new Map<string, object>();
116
119
 
@@ -374,13 +377,10 @@ export class PluginViewRegistry implements FrontendApplicationContribution {
374
377
  }, {
375
378
  execute: () => this.toggleViewContainer(id)
376
379
  }));
377
- toDispose.push(this.menus.registerMenuAction(CommonMenus.VIEW_VIEWS, {
378
- commandId: toggleCommandId,
379
- label: options.label,
380
- when
381
- }));
380
+ toDispose.push(this.registerViewMenuAction(id, options.label));
382
381
  toDispose.push(this.quickView?.registerItem({
383
382
  label: options.label,
383
+ description: this.getLocationDescription(location),
384
384
  when,
385
385
  open: async () => {
386
386
  const widget = await this.openViewContainer(id);
@@ -408,6 +408,88 @@ export class PluginViewRegistry implements FrontendApplicationContribution {
408
408
  return toDispose;
409
409
  }
410
410
 
411
+ protected getLocationDescription(location: string | undefined): string | undefined {
412
+ switch (location) {
413
+ case 'left': return nls.localizeByDefault('Side Bar');
414
+ case 'right': return nls.localizeByDefault('Secondary Side Bar');
415
+ case 'bottom': return nls.localizeByDefault('Panel');
416
+ default: return undefined;
417
+ }
418
+ }
419
+
420
+ protected getContainerLocation(viewContainerId: string): string | undefined {
421
+ if (PluginViewRegistry.BUILTIN_VIEW_CONTAINERS.has(viewContainerId)) {
422
+ return 'left';
423
+ }
424
+ return this.viewContainers.get(viewContainerId)?.location;
425
+ }
426
+
427
+ protected getViewQuickPickDescription(viewContainerId: string): string | undefined {
428
+ const locationDescription = this.getLocationDescription(this.getContainerLocation(viewContainerId));
429
+ const containerLabel = this.viewContainers.get(viewContainerId)?.options.label;
430
+ if (locationDescription && containerLabel) {
431
+ return `${locationDescription} / ${containerLabel}`;
432
+ }
433
+ return locationDescription;
434
+ }
435
+
436
+ protected registerViewMenuAction(containerId: string, label: string): Disposable {
437
+ let ids = this.viewMenuLabelToContainerIds.get(label);
438
+ if (!ids) {
439
+ ids = new Set();
440
+ this.viewMenuLabelToContainerIds.set(label, ids);
441
+ }
442
+ ids.add(containerId);
443
+ this.refreshViewMenuLabel(label);
444
+ return Disposable.create(() => {
445
+ const set = this.viewMenuLabelToContainerIds.get(label);
446
+ if (set) {
447
+ set.delete(containerId);
448
+ if (set.size === 0) {
449
+ this.viewMenuLabelToContainerIds.delete(label);
450
+ }
451
+ }
452
+ const disposable = this.viewMenuDisposables.get(containerId);
453
+ if (disposable) {
454
+ disposable.dispose();
455
+ this.viewMenuDisposables.delete(containerId);
456
+ }
457
+ this.refreshViewMenuLabel(label);
458
+ });
459
+ }
460
+
461
+ protected refreshViewMenuLabel(label: string): void {
462
+ const ids = this.viewMenuLabelToContainerIds.get(label);
463
+ if (!ids) {
464
+ return;
465
+ }
466
+ const useSuffix = ids.size > 1;
467
+ for (const id of ids) {
468
+ const existing = this.viewMenuDisposables.get(id);
469
+ if (existing) {
470
+ existing.dispose();
471
+ this.viewMenuDisposables.delete(id);
472
+ }
473
+ const containerInfo = this.viewContainers.get(id);
474
+ if (!containerInfo) {
475
+ continue;
476
+ }
477
+ let menuLabel = label;
478
+ if (useSuffix) {
479
+ const description = this.getLocationDescription(containerInfo.location);
480
+ if (description) {
481
+ menuLabel = `${label} (${description})`;
482
+ }
483
+ }
484
+ const disposable = this.menus.registerMenuAction(CommonMenus.VIEW_VIEWS, {
485
+ commandId: `plugin.view-container.${id}.toggle`,
486
+ label: menuLabel,
487
+ when: containerInfo.when
488
+ });
489
+ this.viewMenuDisposables.set(id, disposable);
490
+ }
491
+ }
492
+
411
493
  protected isViewContainerVisible(containerId: string): boolean {
412
494
  const info = this.viewContainers.get(containerId);
413
495
  if (!info) {
@@ -471,6 +553,7 @@ export class PluginViewRegistry implements FrontendApplicationContribution {
471
553
  }
472
554
  toDispose.push(this.quickView?.registerItem({
473
555
  label: view.name,
556
+ description: this.getViewQuickPickDescription(viewContainerId),
474
557
  when: view.when,
475
558
  open: () => this.openView(view.id, { activate: true })
476
559
  }));