Skip to content

Commit 45db6b7

Browse files
committed
debug: actions to focus debug views
fixes microsoft#35153
1 parent 039ee97 commit 45db6b7

3 files changed

Lines changed: 101 additions & 8 deletions

File tree

src/vs/workbench/parts/debug/browser/debugViewlet.ts

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import 'vs/css!./media/debugViewlet';
7+
import * as nls from 'vs/nls';
78
import { Builder } from 'vs/base/browser/builder';
9+
import { Action, IAction } from 'vs/base/common/actions';
810
import * as DOM from 'vs/base/browser/dom';
911
import { TPromise } from 'vs/base/common/winjs.base';
10-
import { IAction } from 'vs/base/common/actions';
1112
import { IActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
1213
import { PersistentViewsViewlet } from 'vs/workbench/browser/parts/views/viewsViewlet';
13-
import { IDebugService, VIEWLET_ID, State } from 'vs/workbench/parts/debug/common/debug';
14+
import { IDebugService, VIEWLET_ID, State, VARIABLES_VIEW_ID, WATCH_VIEW_ID, CALLSTACK_VIEW_ID, BREAKPOINTS_VIEW_ID } from 'vs/workbench/parts/debug/common/debug';
1415
import { StartAction, ToggleReplAction, ConfigureAction } from 'vs/workbench/parts/debug/browser/debugActions';
1516
import { StartDebugActionItem } from 'vs/workbench/parts/debug/browser/debugActionItems';
1617
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
@@ -20,6 +21,7 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
2021
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
2122
import { IStorageService } from 'vs/platform/storage/common/storage';
2223
import { IThemeService } from 'vs/platform/theme/common/themeService';
24+
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
2325
import { ViewLocation } from 'vs/workbench/browser/parts/views/viewsRegistry';
2426
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
2527
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
@@ -85,6 +87,13 @@ export class DebugViewlet extends PersistentViewsViewlet {
8587
return null;
8688
}
8789

90+
public focusView(id: string): void {
91+
const view = this.getView(id);
92+
if (view) {
93+
view.focus();
94+
}
95+
}
96+
8897
private onDebugServiceStateChange(state: State): void {
8998
if (this.progressRunner) {
9099
this.progressRunner.done();
@@ -97,3 +106,75 @@ export class DebugViewlet extends PersistentViewsViewlet {
97106
}
98107
}
99108
}
109+
110+
export class FocusVariablesViewAction extends Action {
111+
112+
static ID = 'workbench.debug.action.focusVariablesView';
113+
static LABEL = nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'debugFocusVariablesView' }, 'Focus Variables');
114+
115+
constructor(id: string, label: string,
116+
@IViewletService private viewletService: IViewletService
117+
) {
118+
super(id, label);
119+
}
120+
121+
public run(): TPromise<any> {
122+
return this.viewletService.openViewlet(VIEWLET_ID).then((viewlet: DebugViewlet) => {
123+
viewlet.focusView(VARIABLES_VIEW_ID);
124+
});
125+
}
126+
}
127+
128+
export class FocusWatchViewAction extends Action {
129+
130+
static ID = 'workbench.debug.action.focusWatchView';
131+
static LABEL = nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'debugFocusWatchView' }, 'Focus Watch');
132+
133+
constructor(id: string, label: string,
134+
@IViewletService private viewletService: IViewletService
135+
) {
136+
super(id, label);
137+
}
138+
139+
public run(): TPromise<any> {
140+
return this.viewletService.openViewlet(VIEWLET_ID).then((viewlet: DebugViewlet) => {
141+
viewlet.focusView(WATCH_VIEW_ID);
142+
});
143+
}
144+
}
145+
146+
export class FocusCallStackViewAction extends Action {
147+
148+
static ID = 'workbench.debug.action.focusCallStackView';
149+
static LABEL = nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'debugFocusCallStackView' }, 'Focus CallStack');
150+
151+
constructor(id: string, label: string,
152+
@IViewletService private viewletService: IViewletService
153+
) {
154+
super(id, label);
155+
}
156+
157+
public run(): TPromise<any> {
158+
return this.viewletService.openViewlet(VIEWLET_ID).then((viewlet: DebugViewlet) => {
159+
viewlet.focusView(CALLSTACK_VIEW_ID);
160+
});
161+
}
162+
}
163+
164+
export class FocusBreakpointsViewAction extends Action {
165+
166+
static ID = 'workbench.debug.action.focusBreakpointsView';
167+
static LABEL = nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'debugFocusBreakpointsView' }, 'Focus Breakpoints');
168+
169+
constructor(id: string, label: string,
170+
@IViewletService private viewletService: IViewletService
171+
) {
172+
super(id, label);
173+
}
174+
175+
public run(): TPromise<any> {
176+
return this.viewletService.openViewlet(VIEWLET_ID).then((viewlet: DebugViewlet) => {
177+
viewlet.focusView(BREAKPOINTS_VIEW_ID);
178+
});
179+
}
180+
}

src/vs/workbench/parts/debug/common/debug.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
2121
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
2222

2323
export const VIEWLET_ID = 'workbench.view.debug';
24+
export const VARIABLES_VIEW_ID = 'workbench.debug.variablesView';
25+
export const WATCH_VIEW_ID = 'workbench.debug.watchExpressionsView';
26+
export const CALLSTACK_VIEW_ID = 'workbench.debug.callStackView';
27+
export const BREAKPOINTS_VIEW_ID = 'workbench.debug.breakPointsView';
2428
export const REPL_ID = 'workbench.panel.repl';
2529
export const DEBUG_SERVICE_ID = 'debugService';
2630
export const CONTEXT_DEBUG_TYPE = new RawContextKey<string>('debugType', undefined);

src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ import { ToggleViewletAction, Extensions as ViewletExtensions, ViewletRegistry,
1717
import { TogglePanelAction, Extensions as PanelExtensions, PanelRegistry, PanelDescriptor } from 'vs/workbench/browser/panel';
1818
import { VariablesView, WatchExpressionsView, CallStackView, BreakpointsView } from 'vs/workbench/parts/debug/electron-browser/debugViews';
1919
import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
20-
import { IDebugService, VIEWLET_ID, REPL_ID, CONTEXT_NOT_IN_DEBUG_MODE, CONTEXT_IN_DEBUG_MODE, INTERNAL_CONSOLE_OPTIONS_SCHEMA, CONTEXT_DEBUG_STATE } from 'vs/workbench/parts/debug/common/debug';
20+
import {
21+
IDebugService, VIEWLET_ID, REPL_ID, CONTEXT_NOT_IN_DEBUG_MODE, CONTEXT_IN_DEBUG_MODE, INTERNAL_CONSOLE_OPTIONS_SCHEMA,
22+
CONTEXT_DEBUG_STATE, VARIABLES_VIEW_ID, CALLSTACK_VIEW_ID, WATCH_VIEW_ID, BREAKPOINTS_VIEW_ID
23+
} from 'vs/workbench/parts/debug/common/debug';
2124
import { IPartService } from 'vs/workbench/services/part/common/partService';
2225
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
2326
import { DebugEditorModelManager } from 'vs/workbench/parts/debug/browser/debugEditorModelManager';
@@ -38,7 +41,7 @@ import { ViewLocation, ViewsRegistry } from 'vs/workbench/browser/parts/views/vi
3841
import { isMacintosh } from 'vs/base/common/platform';
3942
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
4043
import URI from 'vs/base/common/uri';
41-
import { DebugViewlet } from 'vs/workbench/parts/debug/browser/debugViewlet';
44+
import { DebugViewlet, FocusVariablesViewAction, FocusBreakpointsViewAction, FocusCallStackViewAction, FocusWatchViewAction } from 'vs/workbench/parts/debug/browser/debugViewlet';
4245
import { Repl } from 'vs/workbench/parts/debug/electron-browser/repl';
4346
import { DebugQuickOpenHandler } from 'vs/workbench/parts/debug/browser/debugQuickOpen';
4447

@@ -98,10 +101,10 @@ Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(new PanelDescri
98101
Registry.as<PanelRegistry>(PanelExtensions.Panels).setDefaultPanelId(REPL_ID);
99102

100103
// Register default debug views
101-
ViewsRegistry.registerViews([{ id: 'workbench.debug.variablesView', name: nls.localize('variables', "Variables"), ctor: VariablesView, order: 10, size: 40, location: ViewLocation.Debug, canToggleVisibility: true }]);
102-
ViewsRegistry.registerViews([{ id: 'workbench.debug.watchExpressionsView', name: nls.localize('watch', "Watch"), ctor: WatchExpressionsView, order: 20, size: 10, location: ViewLocation.Debug, canToggleVisibility: true }]);
103-
ViewsRegistry.registerViews([{ id: 'workbench.debug.callStackView', name: nls.localize('callStack', "Call Stack"), ctor: CallStackView, order: 30, size: 30, location: ViewLocation.Debug, canToggleVisibility: true }]);
104-
ViewsRegistry.registerViews([{ id: 'workbench.debug.breakPointsView', name: nls.localize('breakpoints', "Breakpoints"), ctor: BreakpointsView, order: 40, size: 20, location: ViewLocation.Debug, canToggleVisibility: true }]);
104+
ViewsRegistry.registerViews([{ id: VARIABLES_VIEW_ID, name: nls.localize('variables', "Variables"), ctor: VariablesView, order: 10, size: 40, location: ViewLocation.Debug, canToggleVisibility: true }]);
105+
ViewsRegistry.registerViews([{ id: WATCH_VIEW_ID, name: nls.localize('watch', "Watch"), ctor: WatchExpressionsView, order: 20, size: 10, location: ViewLocation.Debug, canToggleVisibility: true }]);
106+
ViewsRegistry.registerViews([{ id: CALLSTACK_VIEW_ID, name: nls.localize('callStack', "Call Stack"), ctor: CallStackView, order: 30, size: 30, location: ViewLocation.Debug, canToggleVisibility: true }]);
107+
ViewsRegistry.registerViews([{ id: BREAKPOINTS_VIEW_ID, name: nls.localize('breakpoints', "Breakpoints"), ctor: BreakpointsView, order: 40, size: 20, location: ViewLocation.Debug, canToggleVisibility: true }]);
105108

106109
// register action to open viewlet
107110
const registry = Registry.as<IWorkbenchActionRegistry>(WorkbenchActionRegistryExtensions.WorkbenchActions);
@@ -134,6 +137,11 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(DisableAllBreakpointsA
134137
registry.registerWorkbenchAction(new SyncActionDescriptor(ClearReplAction, ClearReplAction.ID, ClearReplAction.LABEL), 'Debug: Clear Console', debugCategory);
135138
registry.registerWorkbenchAction(new SyncActionDescriptor(FocusReplAction, FocusReplAction.ID, FocusReplAction.LABEL), 'Debug: Focus Debug Console', debugCategory);
136139
registry.registerWorkbenchAction(new SyncActionDescriptor(SelectAndStartAction, SelectAndStartAction.ID, SelectAndStartAction.LABEL), 'Debug: Select and Start Debugging', debugCategory);
140+
registry.registerWorkbenchAction(new SyncActionDescriptor(FocusVariablesViewAction, FocusVariablesViewAction.ID, FocusVariablesViewAction.LABEL), 'Debug: Focus Variables', debugCategory);
141+
registry.registerWorkbenchAction(new SyncActionDescriptor(FocusWatchViewAction, FocusWatchViewAction.ID, FocusWatchViewAction.LABEL), 'Debug: Focus Watch', debugCategory);
142+
registry.registerWorkbenchAction(new SyncActionDescriptor(FocusCallStackViewAction, FocusCallStackViewAction.ID, FocusCallStackViewAction.LABEL), 'Debug: Focus CallStack', debugCategory);
143+
registry.registerWorkbenchAction(new SyncActionDescriptor(FocusBreakpointsViewAction, FocusBreakpointsViewAction.ID, FocusBreakpointsViewAction.LABEL), 'Debug: Focus Breakpoints', debugCategory);
144+
137145

138146
// Register Quick Open
139147
(<IQuickOpenRegistry>Registry.as(QuickOpenExtensions.Quickopen)).registerQuickOpenHandler(

0 commit comments

Comments
 (0)