Skip to content

Commit

Permalink
#113757 show sidebar actions only on sidebar views
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Jan 12, 2021
1 parent 2e279d3 commit eba4da2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/vs/workbench/browser/actions/layoutActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/co
import { InEditorZenModeContext, IsCenteredLayoutContext, EditorAreaVisibleContext } from 'vs/workbench/common/editor';
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { SideBarVisibleContext } from 'vs/workbench/common/viewlet';
import { IViewDescriptorService, IViewsService, FocusedViewContext, ViewContainerLocation, IViewDescriptor } from 'vs/workbench/common/views';
import { IViewDescriptorService, IViewsService, FocusedViewContext, ViewContainerLocation, IViewDescriptor, ViewContainerLocationToString } from 'vs/workbench/common/views';
import { IQuickInputService, IQuickPickItem, IQuickPickSeparator } from 'vs/platform/quickinput/common/quickInput';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IActivityBarService } from 'vs/workbench/services/activityBar/browser/activityBarService';
Expand Down Expand Up @@ -172,7 +172,7 @@ MenuRegistry.appendMenuItems([{
id: ToggleSidebarPositionAction.ID,
title: nls.localize('move sidebar right', "Move Side Bar Right")
},
when: ContextKeyExpr.notEquals('config.workbench.sideBar.location', 'right'),
when: ContextKeyExpr.and(ContextKeyExpr.notEquals('config.workbench.sideBar.location', 'right'), ContextKeyExpr.equals('viewContainerLocation', ViewContainerLocationToString(ViewContainerLocation.Sidebar))),
order: 1
}
}, {
Expand All @@ -183,7 +183,7 @@ MenuRegistry.appendMenuItems([{
id: ToggleSidebarPositionAction.ID,
title: nls.localize('move sidebar right', "Move Side Bar Right")
},
when: ContextKeyExpr.notEquals('config.workbench.sideBar.location', 'right'),
when: ContextKeyExpr.and(ContextKeyExpr.notEquals('config.workbench.sideBar.location', 'right'), ContextKeyExpr.equals('viewLocation', ViewContainerLocationToString(ViewContainerLocation.Sidebar))),
order: 1
}
}, {
Expand All @@ -194,7 +194,7 @@ MenuRegistry.appendMenuItems([{
id: ToggleSidebarPositionAction.ID,
title: nls.localize('move sidebar left', "Move Side Bar Left")
},
when: ContextKeyExpr.equals('config.workbench.sideBar.location', 'right'),
when: ContextKeyExpr.and(ContextKeyExpr.equals('config.workbench.sideBar.location', 'right'), ContextKeyExpr.equals('viewContainerLocation', ViewContainerLocationToString(ViewContainerLocation.Sidebar))),
order: 1
}
}, {
Expand All @@ -205,7 +205,7 @@ MenuRegistry.appendMenuItems([{
id: ToggleSidebarPositionAction.ID,
title: nls.localize('move sidebar left', "Move Side Bar Left")
},
when: ContextKeyExpr.equals('config.workbench.sideBar.location', 'right'),
when: ContextKeyExpr.and(ContextKeyExpr.equals('config.workbench.sideBar.location', 'right'), ContextKeyExpr.equals('viewLocation', ViewContainerLocationToString(ViewContainerLocation.Sidebar))),
order: 1
}
}]);
Expand Down Expand Up @@ -295,7 +295,7 @@ MenuRegistry.appendMenuItems([{
id: TOGGLE_SIDEBAR_VISIBILITY_ACTION_ID,
title: nls.localize('compositePart.hideSideBarLabel', "Hide Side Bar"),
},
when: SideBarVisibleContext,
when: ContextKeyExpr.and(SideBarVisibleContext, ContextKeyExpr.equals('viewContainerLocation', ViewContainerLocationToString(ViewContainerLocation.Sidebar))),
order: 2
}
}, {
Expand All @@ -306,7 +306,7 @@ MenuRegistry.appendMenuItems([{
id: TOGGLE_SIDEBAR_VISIBILITY_ACTION_ID,
title: nls.localize('compositePart.hideSideBarLabel', "Hide Side Bar"),
},
when: SideBarVisibleContext,
when: ContextKeyExpr.and(SideBarVisibleContext, ContextKeyExpr.equals('viewLocation', ViewContainerLocationToString(ViewContainerLocation.Sidebar))),
order: 2
}
}]);
Expand Down
5 changes: 4 additions & 1 deletion src/vs/workbench/browser/parts/views/viewPane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService, ThemeIcon } from 'vs/platform/theme/common/themeService';
import { IPaneOptions, Pane, IPaneStyles } from 'vs/base/browser/ui/splitview/paneview';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { Extensions as ViewContainerExtensions, IView, FocusedViewContext, IViewDescriptorService, ViewContainerLocation, IViewsRegistry, IViewContentDescriptor, defaultViewIcon, IViewsService } from 'vs/workbench/common/views';
import { Extensions as ViewContainerExtensions, IView, FocusedViewContext, IViewDescriptorService, ViewContainerLocation, IViewsRegistry, IViewContentDescriptor, defaultViewIcon, IViewsService, ViewContainerLocationToString } from 'vs/workbench/common/views';
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { assertIsDefined } from 'vs/base/common/types';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
Expand Down Expand Up @@ -147,11 +147,14 @@ class ViewMenuActions extends CompositeMenuActions {
contextMenuId: MenuId,
@IContextKeyService contextKeyService: IContextKeyService,
@IMenuService menuService: IMenuService,
@IViewDescriptorService viewDescriptorService: IViewDescriptorService,
) {
const scopedContextKeyService = contextKeyService.createScoped();
scopedContextKeyService.createKey('view', viewId);
const viewLocationKey = scopedContextKeyService.createKey('viewLocation', ViewContainerLocationToString(viewDescriptorService.getViewLocationById(viewId)!));
super(menuId, contextMenuId, { shouldForwardArgs: true }, scopedContextKeyService, menuService);
this._register(scopedContextKeyService);
this._register(Event.filter(viewDescriptorService.onDidChangeLocation, e => e.views.some(view => view.id === viewId))(() => viewLocationKey.set(ViewContainerLocationToString(viewDescriptorService.getViewLocationById(viewId)!))));
}

}
Expand Down

0 comments on commit eba4da2

Please sign in to comment.