diff --git a/packages/navigator/src/browser/navigator-contribution.ts b/packages/navigator/src/browser/navigator-contribution.ts index 210d1574f2997..c47348f460206 100644 --- a/packages/navigator/src/browser/navigator-contribution.ts +++ b/packages/navigator/src/browser/navigator-contribution.ts @@ -115,7 +115,6 @@ export class FileNavigatorContribution extends AbstractViewContribution { @@ -137,12 +136,19 @@ export class FileNavigatorContribution extends AbstractViewContribution true }); registry.registerCommand(FileNavigatorCommands.COLLAPSE_ALL, { - execute: () => this.collapseFileNavigatorTree(), - isEnabled: () => this.workspaceService.opened, - isVisible: () => this.workspaceService.opened + execute: widget => this.withWidget(widget, () => this.collapseFileNavigatorTree()), + isEnabled: widget => this.withWidget(widget, () => this.workspaceService.opened), + isVisible: wodget => this.withWidget(wodget, () => this.workspaceService.opened) }); } + protected withWidget(widget: Widget | undefined = this.tryGetWidget(), cb: (navigator: FileNavigatorWidget) => T): T | false { + if (widget instanceof FileNavigatorWidget && widget.id === FILE_NAVIGATOR_ID) { + return cb(widget); + } + return false; + } + registerMenus(registry: MenuModelRegistry): void { super.registerMenus(registry); registry.registerMenuAction(SHELL_TABBAR_CONTEXT_MENU, {