Skip to content

Commit ef14938

Browse files
committed
F6 and shift+F6 also focus on activity bar
1 parent 9d68bd2 commit ef14938

5 files changed

Lines changed: 25 additions & 5 deletions

File tree

src/vs/workbench/browser/actions/navigationActions.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,9 @@ class NavigateDownAction extends BaseNavigationAction {
202202
}
203203

204204
function findVisibleNeighbour(layoutService: IWorkbenchLayoutService, part: Parts, next: boolean): Parts {
205-
const neighbour = part === Parts.EDITOR_PART ? (next ? Parts.STATUSBAR_PART : Parts.PANEL_PART) : part === Parts.STATUSBAR_PART ? (next ? Parts.SIDEBAR_PART : Parts.EDITOR_PART) :
206-
part === Parts.SIDEBAR_PART ? (next ? Parts.PANEL_PART : Parts.STATUSBAR_PART) : part === Parts.PANEL_PART ? (next ? Parts.EDITOR_PART : Parts.SIDEBAR_PART) : Parts.EDITOR_PART;
205+
const neighbour = part === Parts.EDITOR_PART ? (next ? Parts.STATUSBAR_PART : Parts.PANEL_PART) : part === Parts.STATUSBAR_PART ? (next ? Parts.ACTIVITYBAR_PART : Parts.EDITOR_PART) :
206+
part === Parts.ACTIVITYBAR_PART ? (next ? Parts.SIDEBAR_PART : Parts.STATUSBAR_PART) : part === Parts.SIDEBAR_PART ? (next ? Parts.PANEL_PART : Parts.ACTIVITYBAR_PART) :
207+
part === Parts.PANEL_PART ? (next ? Parts.EDITOR_PART : Parts.SIDEBAR_PART) : Parts.EDITOR_PART;
207208
if (layoutService.isVisible(neighbour) || neighbour === Parts.EDITOR_PART) {
208209
return neighbour;
209210
}
@@ -212,8 +213,8 @@ function findVisibleNeighbour(layoutService: IWorkbenchLayoutService, part: Part
212213
}
213214

214215
function focusNextOrPreviousPart(layoutService: IWorkbenchLayoutService, next: boolean): void {
215-
const currentlyFocusedPart = layoutService.hasFocus(Parts.EDITOR_PART) ? Parts.EDITOR_PART : layoutService.hasFocus(Parts.STATUSBAR_PART) ? Parts.STATUSBAR_PART :
216-
layoutService.hasFocus(Parts.SIDEBAR_PART) ? Parts.SIDEBAR_PART : layoutService.hasFocus(Parts.PANEL_PART) ? Parts.PANEL_PART : undefined;
216+
const currentlyFocusedPart = layoutService.hasFocus(Parts.EDITOR_PART) ? Parts.EDITOR_PART : layoutService.hasFocus(Parts.ACTIVITYBAR_PART) ? Parts.ACTIVITYBAR_PART :
217+
layoutService.hasFocus(Parts.STATUSBAR_PART) ? Parts.STATUSBAR_PART : layoutService.hasFocus(Parts.SIDEBAR_PART) ? Parts.SIDEBAR_PART : layoutService.hasFocus(Parts.PANEL_PART) ? Parts.PANEL_PART : undefined;
217218
let partToFocus = Parts.EDITOR_PART;
218219
if (currentlyFocusedPart) {
219220
partToFocus = findVisibleNeighbour(layoutService, currentlyFocusedPart, next);

src/vs/workbench/browser/layout.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
177177
private backupFileService!: IBackupFileService;
178178
private notificationService!: INotificationService;
179179
private themeService!: IThemeService;
180+
private activityBarService!: IActivityBarService;
180181

181182
protected readonly state = {
182183
fullscreen: false,
@@ -260,8 +261,8 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
260261
this.viewDescriptorService = accessor.get(IViewDescriptorService);
261262
this.titleService = accessor.get(ITitleService);
262263
this.notificationService = accessor.get(INotificationService);
264+
this.activityBarService = accessor.get(IActivityBarService);
263265
accessor.get(IStatusbarService); // not used, but called to ensure instantiated
264-
accessor.get(IActivityBarService); // not used, but called to ensure instantiated
265266

266267
// Listeners
267268
this.registerLayoutListeners();
@@ -846,6 +847,9 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
846847
activeViewlet.focus();
847848
}
848849
break;
850+
case Parts.ACTIVITYBAR_PART:
851+
this.activityBarService.focusActivityBar();
852+
break;
849853
default:
850854
// Status Bar, Activity Bar and Title Bar simply pass focus to container
851855
const container = this.getContainer(part);

src/vs/workbench/browser/parts/activitybar/activitybarPart.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ export class ActivitybarPart extends Part implements IActivityBarService {
168168
this.registerListeners();
169169
}
170170

171+
focusActivityBar(): void {
172+
this.compositeBar.focus();
173+
}
174+
171175
private registerListeners(): void {
172176

173177
// View Container Changes

src/vs/workbench/browser/parts/compositeBar.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,12 @@ export class CompositeBar extends Widget implements ICompositeBar {
253253
return actionBarDiv;
254254
}
255255

256+
focus(): void {
257+
if (this.compositeSwitcherBar) {
258+
this.compositeSwitcherBar.focus();
259+
}
260+
}
261+
256262
layout(dimension: Dimension): void {
257263
this.dimension = dimension;
258264
if (dimension.height === 0 || dimension.width === 0) {

src/vs/workbench/services/activityBar/browser/activityBarService.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,9 @@ export interface IActivityBarService {
2626
* Returns id of visible viewlets following the visual order.
2727
*/
2828
getVisibleViewContainerIds(): string[];
29+
30+
/**
31+
* Focuses the activity bar.
32+
*/
33+
focusActivityBar(): void;
2934
}

0 commit comments

Comments
 (0)