Skip to content

Commit e331b5f

Browse files
authored
Merge pull request #82235 from microsoft/isidorn/debugTouchbarArgs
debugCommands: check if threadId is number before using it
2 parents 9df03c6 + ba2690d commit e331b5f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/vs/workbench/contrib/debug/browser/debugCommands.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ export const DISCONNECT_LABEL = nls.localize('disconnect', "Disconnect");
6060
export const STOP_LABEL = nls.localize('stop', "Stop");
6161
export const CONTINUE_LABEL = nls.localize('continueDebug', "Continue");
6262

63-
function getThreadAndRun(accessor: ServicesAccessor, threadId: number | undefined, run: (thread: IThread) => Promise<void>): void {
63+
function getThreadAndRun(accessor: ServicesAccessor, threadIdArg: number | any, run: (thread: IThread) => Promise<void>): void {
6464
const debugService = accessor.get(IDebugService);
65+
const threadId = typeof threadIdArg === 'number' ? threadIdArg : undefined;
6566
let thread: IThread | undefined;
6667
if (threadId) {
6768
debugService.getModel().getSessions().forEach(s => {
@@ -119,21 +120,21 @@ export function registerCommands(): void {
119120

120121
CommandsRegistry.registerCommand({
121122
id: REVERSE_CONTINUE_ID,
122-
handler: (accessor: ServicesAccessor, threadId: number | undefined) => {
123+
handler: (accessor: ServicesAccessor, threadId: number | any) => {
123124
getThreadAndRun(accessor, threadId, thread => thread.reverseContinue());
124125
}
125126
});
126127

127128
CommandsRegistry.registerCommand({
128129
id: STEP_BACK_ID,
129-
handler: (accessor: ServicesAccessor, threadId: number | undefined) => {
130+
handler: (accessor: ServicesAccessor, threadId: number | any) => {
130131
getThreadAndRun(accessor, threadId, thread => thread.stepBack());
131132
}
132133
});
133134

134135
CommandsRegistry.registerCommand({
135136
id: TERMINATE_THREAD_ID,
136-
handler: (accessor: ServicesAccessor, threadId: number | undefined) => {
137+
handler: (accessor: ServicesAccessor, threadId: number | any) => {
137138
getThreadAndRun(accessor, threadId, thread => thread.terminate());
138139
}
139140
});
@@ -213,7 +214,7 @@ export function registerCommands(): void {
213214
weight: KeybindingWeight.WorkbenchContrib,
214215
primary: KeyCode.F10,
215216
when: CONTEXT_DEBUG_STATE.isEqualTo('stopped'),
216-
handler: (accessor: ServicesAccessor, threadId: number) => {
217+
handler: (accessor: ServicesAccessor, threadId: number | any) => {
217218
getThreadAndRun(accessor, threadId, (thread: IThread) => thread.next());
218219
}
219220
});
@@ -223,7 +224,7 @@ export function registerCommands(): void {
223224
weight: KeybindingWeight.WorkbenchContrib + 10, // Have a stronger weight to have priority over full screen when debugging
224225
primary: KeyCode.F11,
225226
when: CONTEXT_IN_DEBUG_MODE,
226-
handler: (accessor: ServicesAccessor, threadId: number) => {
227+
handler: (accessor: ServicesAccessor, threadId: number | any) => {
227228
getThreadAndRun(accessor, threadId, (thread: IThread) => thread.stepIn());
228229
}
229230
});
@@ -233,7 +234,7 @@ export function registerCommands(): void {
233234
weight: KeybindingWeight.WorkbenchContrib,
234235
primary: KeyMod.Shift | KeyCode.F11,
235236
when: CONTEXT_DEBUG_STATE.isEqualTo('stopped'),
236-
handler: (accessor: ServicesAccessor, threadId: number) => {
237+
handler: (accessor: ServicesAccessor, threadId: number | any) => {
237238
getThreadAndRun(accessor, threadId, (thread: IThread) => thread.stepOut());
238239
}
239240
});
@@ -243,7 +244,7 @@ export function registerCommands(): void {
243244
weight: KeybindingWeight.WorkbenchContrib,
244245
primary: KeyCode.F6,
245246
when: CONTEXT_DEBUG_STATE.isEqualTo('running'),
246-
handler: (accessor: ServicesAccessor, threadId: number) => {
247+
handler: (accessor: ServicesAccessor, threadId: number | any) => {
247248
getThreadAndRun(accessor, threadId, thread => thread.pause());
248249
}
249250
});
@@ -292,7 +293,7 @@ export function registerCommands(): void {
292293
weight: KeybindingWeight.WorkbenchContrib,
293294
primary: KeyCode.F5,
294295
when: CONTEXT_IN_DEBUG_MODE,
295-
handler: (accessor: ServicesAccessor, threadId: number | undefined) => {
296+
handler: (accessor: ServicesAccessor, threadId: number | any) => {
296297
getThreadAndRun(accessor, threadId, thread => thread.continue());
297298
}
298299
});

0 commit comments

Comments
 (0)